[ovs-dev] [PATCH 14/21] ofproto: Set flow tun_key in compose_output_action()

Simon Horman horms at verge.net.au
Thu May 24 09:09:07 UTC 2012


In essence this attached the tun_key, if any,
to the output processing of a packet. This allows
it the packet to be transmitted using flow-based
tunneling as necessary.

Cc: Kyle Mestery <kmestery at cisco.com>
Signed-off-by: Simon Horman <horms at verge.net.au>

---

v4
* Set tun_flags field of flow.tun_key
* Remove debugging message

v3
* Initial release

datapath: Add flags to ovs_key_ipv4_tunnel

Add flags to ovs_key_ipv4_tunnel and set from
the tunnel's realdev flags. This allows the datapath
to have access to flags on transmit which can be
used to effect the transmission - e.g. add a tunnel id.

Signed-off-by: Simon Horman <horms at verge.net.au>
---
 ofproto/ofproto-dpif.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 2a52f37..b1354a2 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -4919,8 +4919,17 @@ compose_output_action__(struct action_xlate_ctx *ctx, uint16_t ofp_port,
     }
 
     out_port = realdev_to_txdev(ctx->ofproto, ofport, ctx->flow.vlan_tci);
-    if (out_port != odp_port && !ofport->tun) {
-        ctx->flow.vlan_tci = htons(0);
+    if (out_port != odp_port) {
+        if (ofport->tun) {
+            ctx->flow.tun_key.tun_id = ofport->tun->s.out_key;
+            ctx->flow.tun_key.tun_flags = ofport->tun->s.flags;
+            ctx->flow.tun_key.ipv4_src = ofport->tun->s.saddr;
+            ctx->flow.tun_key.ipv4_dst = ofport->tun->s.daddr;
+            ctx->flow.tun_key.ipv4_tos = ofport->tun->s.tos;
+            ctx->flow.tun_key.ipv4_ttl = ofport->tun->s.ttl;
+        } else {
+            ctx->flow.vlan_tci = htons(0);
+        }
     }
     commit_odp_actions(&ctx->flow, &ctx->base_flow, ctx->odp_actions);
     nl_msg_put_u32(ctx->odp_actions, OVS_ACTION_ATTR_OUTPUT, out_port);
@@ -5576,7 +5585,7 @@ action_xlate_ctx_init(struct action_xlate_ctx *ctx,
     ctx->ofproto = ofproto;
     ctx->flow = *flow;
     ctx->base_flow = ctx->flow;
-    ctx->base_flow.tun_key.ipv4_src = 0;
+    ctx->base_flow.tun_key.ipv4_src = htonl(0);
     ctx->base_flow.vlan_tci = initial_tci;
     ctx->rule = rule;
     ctx->packet = packet;
-- 
1.7.10.2.484.gcd07cc5




More information about the dev mailing list