Hi, 
 
> Thanks for taking a look. Andy and I have been throwing some thoughts
> around about this, but I'm not sure we came to a concrete solution yet
> either. My main thought is that I think that the 'flow' needs to be
> modified in the similar way that the 'push_tnl' would work in the
> datapath - updating the IP/UDP fields in a protocol-specific manner.
> Then the shared code between patch ports and this tunneling
> translation needs close attention to check everything is lined up
> correctly, restored after output translation, etc.

I have a patch that fixes tunneling over patch ports. The 14th system-userspace
test still does fail, but now the packet size in the dump flow remains 242. 

./system-traffic.at:554: ovs-ofctl dump-flows br0 | grep "in_port=2" | sed -n 
's/.*\(n\_bytes=[0-9]*\).*/\1/p'
./system-traffic.at:558: ovs-ofctl dump-flows br-underlay | grep 
"in_port=LOCAL" | sed -n 's/.*\(n\_bytes=[0-9]*\).*/\1/p'
--- -   2017-05-05 19:52:28.987111424 +0200
+++ 
/home/ezolbal/work/general_L3_tunneling/ovs/tests/system-userspace-testsuite.dir/at-groups/14/stdout
        2017-05-05 19:52:28.983508027 +0200
@@ -1,2 +1,2 @@
-n_bytes=138
+n_bytes=242

I'm little bit lost with flow statistics. Could you have a look at the patch 
below, and help me to find out if it's only a statistics bug, please?

---

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 16dae15..0d4d037 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -3141,6 +3141,33 @@ tnl_send_arp_request(struct xlate_ctx *ctx, const struct 
xport *out_dev,
     dp_packet_uninit(&packet);
 }
 
+/*
+ * Copy IP data of 'flow->tunnel' into 'flow' and 'base_flow'.
+ */
+static void
+propagate_tunnel_data_to_flow(struct flow *flow, struct flow *base_flow)
+{
+    flow->nw_dst = flow->tunnel.ip_dst;
+    flow->nw_src = flow->tunnel.ip_src;
+    flow->ipv6_dst = flow->tunnel.ipv6_dst;
+    flow->ipv6_src = flow->tunnel.ipv6_src;
+
+    flow->nw_tos = flow->tunnel.ip_tos;
+    flow->nw_ttl = flow->tunnel.ip_ttl;
+    flow->tp_dst = flow->tunnel.tp_dst;
+    flow->tp_src = flow->tunnel.tp_src;
+
+    base_flow->nw_dst = flow->nw_dst;
+    base_flow->nw_src = flow->nw_src;
+    base_flow->ipv6_dst = flow->ipv6_dst;
+    base_flow->ipv6_src = flow->ipv6_src;
+
+    base_flow->nw_tos = flow->nw_tos;
+    base_flow->nw_ttl = flow->nw_ttl;
+    base_flow->tp_dst = flow->tp_dst;
+    base_flow->tp_src = flow->tp_src;
+}
+
 static int
 build_tunnel_send(struct xlate_ctx *ctx, const struct xport *xport,
                   const struct flow *flow, odp_port_t tunnel_odp_port)
@@ -3156,6 +3183,9 @@ build_tunnel_send(struct xlate_ctx *ctx, const struct 
xport *xport,
     int err;
     char buf_sip6[INET6_ADDRSTRLEN];
     char buf_dip6[INET6_ADDRSTRLEN];
+    /* Variables to backup Ethernet and IP data of flow and base_flow. */
+    struct flow old_flow = ctx->xin->flow;
+    struct flow old_base_flow = ctx->base_flow;
 
     err = tnl_route_lookup_flow(flow, &d_ip6, &s_ip6, &out_dev);
     if (err) {
@@ -3216,6 +3246,32 @@ build_tunnel_send(struct xlate_ctx *ctx, const struct 
xport *xport,
     tnl_push_data.tnl_port = odp_to_u32(tunnel_odp_port);
     tnl_push_data.out_port = odp_to_u32(out_dev->odp_port);
 
+    /* After tunnel header has been added, MAC and IP data of flow and
+     * base_flow need to be set properly, since there is not recirculation
+     * any more when sending packet to tunnel. */
+    if (!eth_addr_is_zero(ctx->xin->flow.dl_dst)) {
+        ctx->xin->flow.dl_dst = dmac;
+        ctx->base_flow.dl_dst = ctx->xin->flow.dl_dst;
+    }
+
+    ctx->xin->flow.dl_src = smac;
+    ctx->base_flow.dl_src = ctx->xin->flow.dl_src;
+
+    propagate_tunnel_data_to_flow(&ctx->xin->flow, &ctx->base_flow);
+
+    if (!tnl_params.is_ipv6) {
+        ctx->xin->flow.dl_type = htons(ETH_TYPE_IP);
+    } else {
+        ctx->xin->flow.dl_type = htons(ETH_TYPE_IPV6);
+    }
+
+    if (tnl_push_data.tnl_type == OVS_VPORT_TYPE_GRE) {
+        ctx->xin->flow.nw_proto = IPPROTO_GRE;
+    } else {
+        ctx->xin->flow.nw_proto = IPPROTO_UDP;
+    }
+    ctx->base_flow.nw_proto = ctx->xin->flow.nw_proto;
+
     size_t push_action_size = 0;
     size_t clone_ofs = nl_msg_start_nested(ctx->odp_actions,
                                            OVS_ACTION_ATTR_CLONE);
@@ -3226,6 +3282,11 @@ build_tunnel_send(struct xlate_ctx *ctx, const struct 
xport *xport,
         /* Update the CLONE action only when combined */
         nl_msg_end_nested(ctx->odp_actions, clone_ofs);
     }
+
+    /* Restore flow and base_flow data. */
+    ctx->xin->flow = old_flow;
+    ctx->base_flow = old_base_flow;
+
     return 0;
 }
 
diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index e52ab32..1f6cd84 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -6257,6 +6257,15 @@ HEADER
        dgramSeqNo=1
        ds=127.0.0.1>2:1000
        fsSeqNo=1
+       tunnel4_out_length=0
+       tunnel4_out_protocol=47
+       tunnel4_out_src=1.1.2.88
+       tunnel4_out_dst=1.1.2.92
+       tunnel4_out_src_port=0
+       tunnel4_out_dst_port=0
+       tunnel4_out_tcp_flags=0
+       tunnel4_out_tos=0
+       tunnel_out_vni=456
        in_vlan=0
        in_priority=0
        out_vlan=0
@@ -6266,7 +6275,7 @@ HEADER
        dropEvents=0
        in_ifindex=2011
        in_format=0
-       out_ifindex=2
+       out_ifindex=1
        out_format=2
        hdr_prot=1
        pkt_len=46
-- 
2.7.4
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to