[ovs-dev] [PATCH 07/11] ofproto-dpif: Avoid unnecessary copying of struct flow with patch ports.

Jarno Rajahalme jarno.rajahalme at nsn.com
Fri May 31 11:35:17 UTC 2013


Signed-off-by: Jarno Rajahalme <jarno.rajahalme at nsn.com>
---
 ofproto/ofproto-dpif.c |   29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 61f3a04..96f6452 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -5921,8 +5921,8 @@ compose_output_action__(struct xlate_ctx *ctx, uint16_t ofp_port,
 
     if (netdev_vport_is_patch(ofport->up.netdev)) {
         struct ofport_dpif *peer = ofport_get_peer(ofport);
-        struct flow old_flow = *flow;
-        const struct ofproto_dpif *peer_ofproto;
+        struct flow new_flow;
+        struct ofproto_dpif *peer_ofproto;
         enum slow_path_reason special;
         struct ofport_dpif *in_port;
 
@@ -5937,32 +5937,35 @@ compose_output_action__(struct xlate_ctx *ctx, uint16_t ofp_port,
             return;
         }
 
-        ctx->ofproto = ofproto_dpif_cast(peer->up.ofproto);
-        flow->in_port = peer->up.ofp_port;
-        flow->metadata = htonll(0);
-        memset(&flow->tunnel, 0, sizeof flow->tunnel);
-        memset(flow->regs, 0, sizeof flow->regs);
+        new_flow = *flow;
 
-        in_port = get_ofp_port(ctx->ofproto, flow->in_port);
-        special = process_special(ctx->ofproto, flow, in_port,
+        ctx->ofproto = peer_ofproto;
+        new_flow.in_port = peer->up.ofp_port;
+        new_flow.metadata = htonll(0);
+        memset(&new_flow.tunnel, 0, sizeof new_flow.tunnel);
+        memset(new_flow.regs, 0, sizeof new_flow.regs);
+
+        in_port = get_ofp_port(ctx->ofproto, new_flow.in_port);
+        special = process_special(ctx->ofproto, &new_flow, in_port,
                                   ctx->xin->packet);
         if (special) {
             ctx->xout->slow = special;
-        } else if (!in_port || may_receive(in_port, flow)) {
+        } else if (!in_port || may_receive(in_port, &new_flow)) {
+            ctx->xin->flow = &new_flow;
             if (!in_port || stp_forward_in_state(in_port->stp_state)) {
-                xlate_table_action(ctx, flow->in_port, 0, true);
+                xlate_table_action(ctx, new_flow.in_port, 0, true);
             } else {
                 /* Forwarding is disabled by STP.  Let OFPP_NORMAL and the
                  * learning action look at the packet, then drop it. */
                 struct flow old_base_flow = ctx->base_flow;
                 size_t old_size = ctx->xout->odp_actions.size;
-                xlate_table_action(ctx, flow->in_port, 0, true);
+                xlate_table_action(ctx, new_flow.in_port, 0, true);
                 ctx->base_flow = old_base_flow;
                 ctx->xout->odp_actions.size = old_size;
             }
+            ctx->xin->flow = flow; /* Restore flow pointer */
         }
 
-        *flow = old_flow;
         ctx->ofproto = ofproto_dpif_cast(ofport->up.ofproto);
 
         if (ctx->xin->resubmit_stats) {
-- 
1.7.10.4




More information about the dev mailing list