[ovs-dev,no-slow,v2,4/8] ofproto-dpif: Modify process_upcall() to remove some redundant code.

Message ID 1515623246-3820-4-git-send-email-jpettit@ovn.org
State Accepted
Headers show
Series
  • [ovs-dev,no-slow,v2,1/8] ofproto-dpif: Use a fixed size userspace cookie.
Related show

Commit Message

Justin Pettit Jan. 10, 2018, 10:27 p.m.
Signed-off-by: Justin Pettit <jpettit@ovn.org>
---
v1->v2: New to the series.
---
 ofproto/ofproto-dpif-upcall.c | 45 ++++++++++++++++---------------------------
 1 file changed, 17 insertions(+), 28 deletions(-)

Comments

Ben Pfaff Jan. 11, 2018, 12:18 a.m. | #1
On Wed, Jan 10, 2018 at 02:27:22PM -0800, Justin Pettit wrote:
> Signed-off-by: Justin Pettit <jpettit@ovn.org>
> ---
> v1->v2: New to the series.

Acked-by: Ben Pfaff <blp@ovn.org>
Justin Pettit Jan. 11, 2018, 6:15 a.m. | #2
> On Jan 10, 2018, at 4:18 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> On Wed, Jan 10, 2018 at 02:27:22PM -0800, Justin Pettit wrote:
>> Signed-off-by: Justin Pettit <jpettit@ovn.org>
>> ---
>> v1->v2: New to the series.
> 
> Acked-by: Ben Pfaff <blp@ovn.org>

Great.  Thanks for the reviews!  I pushed the series.

--Justin

Patch

diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index 83007d00b46c..5ba1006893dc 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -1361,27 +1361,6 @@  process_upcall(struct udpif *udpif, struct upcall *upcall,
         break;
 
     case IPFIX_UPCALL:
-        if (upcall->ipfix) {
-            struct flow_tnl output_tunnel_key;
-            struct dpif_ipfix_actions ipfix_actions;
-
-            memset(&ipfix_actions, 0, sizeof ipfix_actions);
-
-            if (upcall->out_tun_key) {
-                odp_tun_key_from_attr(upcall->out_tun_key, &output_tunnel_key);
-            }
-
-            actions_len = dpif_read_actions(udpif, upcall, flow,
-                                            upcall->type, &ipfix_actions);
-            dpif_ipfix_bridge_sample(upcall->ipfix, packet, flow,
-                                     flow->in_port.odp_port,
-                                     upcall->cookie.ipfix.output_odp_port,
-                                     upcall->out_tun_key ?
-                                         &output_tunnel_key : NULL,
-                                     actions_len > 0 ? &ipfix_actions: NULL);
-        }
-        break;
-
     case FLOW_SAMPLE_UPCALL:
         if (upcall->ipfix) {
             struct flow_tnl output_tunnel_key;
@@ -1395,13 +1374,23 @@  process_upcall(struct udpif *udpif, struct upcall *upcall,
 
             actions_len = dpif_read_actions(udpif, upcall, flow,
                                             upcall->type, &ipfix_actions);
-            /* The flow reflects exactly the contents of the packet.
-             * Sample the packet using it. */
-            dpif_ipfix_flow_sample(upcall->ipfix, packet, flow,
-                                   &upcall->cookie, flow->in_port.odp_port,
-                                   upcall->out_tun_key ?
-                                       &output_tunnel_key : NULL,
-                                   actions_len > 0 ? &ipfix_actions: NULL);
+            if (upcall->type == IPFIX_UPCALL) {
+                dpif_ipfix_bridge_sample(upcall->ipfix, packet, flow,
+                                         flow->in_port.odp_port,
+                                         upcall->cookie.ipfix.output_odp_port,
+                                         upcall->out_tun_key ?
+                                             &output_tunnel_key : NULL,
+                                         actions_len > 0 ?
+                                             &ipfix_actions: NULL);
+            } else {
+                /* The flow reflects exactly the contents of the packet.
+                 * Sample the packet using it. */
+                dpif_ipfix_flow_sample(upcall->ipfix, packet, flow,
+                                       &upcall->cookie, flow->in_port.odp_port,
+                                       upcall->out_tun_key ?
+                                           &output_tunnel_key : NULL,
+                                       actions_len > 0 ? &ipfix_actions: NULL);
+            }
         }
         break;