diff mbox

[ovs-dev] tunneling: Fix for concomitant IPv4 and IPv6 tunnels

Message ID 1459515965-31727-1-git-send-email-cascardo@redhat.com
State Accepted
Headers show

Commit Message

Thadeu Lima de Souza Cascardo April 1, 2016, 1:06 p.m. UTC
When using an IPv6 tunnel on the same bridge as an IPv4 tunnel, the flow
received from the IPv6 tunnel would have an IPv4 address added to it, causing
problems when trying to put or execute the action on Linux datapath.

Clearing the IPv6 address when we have a valid IPv4 address fixes this problem.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
---
 ofproto/tunnel.c |  4 ++++
 tests/tunnel.at  | 27 +++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

Comments

Ben Pfaff April 21, 2016, 6:07 p.m. UTC | #1
On Fri, Apr 01, 2016 at 10:06:05AM -0300, Thadeu Lima de Souza Cascardo wrote:
> When using an IPv6 tunnel on the same bridge as an IPv4 tunnel, the flow
> received from the IPv6 tunnel would have an IPv4 address added to it, causing
> problems when trying to put or execute the action on Linux datapath.
> 
> Clearing the IPv6 address when we have a valid IPv4 address fixes this problem.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>

Applied, thanks!
diff mbox

Patch

diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c
index 7430994..18297b2 100644
--- a/ofproto/tunnel.c
+++ b/ofproto/tunnel.c
@@ -419,12 +419,16 @@  tnl_port_send(const struct ofport_dpif *ofport, struct flow *flow,
         flow->tunnel.ip_src = in6_addr_get_mapped_ipv4(&tnl_port->match.ipv6_src);
         if (!flow->tunnel.ip_src) {
             flow->tunnel.ipv6_src = tnl_port->match.ipv6_src;
+        } else {
+            flow->tunnel.ipv6_src = in6addr_any;
         }
     }
     if (!cfg->ip_dst_flow) {
         flow->tunnel.ip_dst = in6_addr_get_mapped_ipv4(&tnl_port->match.ipv6_dst);
         if (!flow->tunnel.ip_dst) {
             flow->tunnel.ipv6_dst = tnl_port->match.ipv6_dst;
+        } else {
+            flow->tunnel.ipv6_dst = in6addr_any;
         }
     }
     flow->pkt_mark = tnl_port->match.pkt_mark;
diff --git a/tests/tunnel.at b/tests/tunnel.at
index 0c033da..9f17194 100644
--- a/tests/tunnel.at
+++ b/tests/tunnel.at
@@ -524,3 +524,30 @@  Datapath actions: set(tunnel(tun_id=0x0,dst=1.1.1.1,ttl=64,geneve({class=0xffff,
 
 OVS_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([tunnel - concomitant IPv6 and IPv4 tunnels])
+OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
+                    options:remote_ip=1.1.1.1 ofport_request=1 \
+                    -- add-port br0 p2 -- set Interface p2 type=vxlan \
+                    options:remote_ip=2001:cafe::1 ofport_request=2])
+AT_DATA([flows.txt], [dnl
+in_port=1,actions=2
+in_port=2,actions=1
+])
+OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
+
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0,src=1.1.1.1,dst=1.1.1.2,ttl=64),in_port(4789)'], [0], [stdout])
+AT_CHECK([tail -1 stdout], [0],
+  [Datapath actions: set(tunnel(tun_id=0x0,ipv6_dst=2001:cafe::1,ttl=64,flags(df|key))),4789
+])
+
+AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x0,ipv6_src=2001:cafe::1,ipv6_dst=2001:cafe::2,ttl=64),in_port(4789)'], [0], [stdout])
+AT_CHECK([tail -1 stdout], [0],
+  [Datapath actions: set(tunnel(tun_id=0x0,dst=1.1.1.1,ttl=64,flags(df|key))),4789
+])
+
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP