[ovs-dev] [PATCH] ovs-router: Fix selection of source IP address when a gateway ip is introduced

Waizel, Ariel ariel.waizel at hpe.com
Tue Sep 13 07:08:52 UTC 2016


When adding a VXLAN tunnel that connects to a VTEP residing in a different IP network, the tunnel source ip needs to be selected by best fit (longest matching netmask), based on the destination VTEP ip, and the specific route's gateway ip.

A bug in ovs-router.c made the source ip to be decided only based on the destination ip: Thus, if all source ips available to OVS and the destination ip are in different ip networks - no source ip is selected, and an error is returned.

This error accorded when  using OVS-DPDK and configuring a VXLAN tunnel where source ip and destination ip are in different networks, and a gateway ip was in place for the specific route.

The fix tries to match a source ip based on the gateway ip, if no matching source ip was found based on the destination ip - This way, the gateway becomes the first hop only if the tunnel crosses between ip networks.

Signed-off-by: Ariel Waizel <ariel.waizel at hpe.com>

diff --git a/lib/ovs-router.c b/lib/ovs-router.c
index e27514a..18d0f8e 100644
--- a/lib/ovs-router.c
+++ b/lib/ovs-router.c
@@ -198,6 +198,9 @@ ovs_router_insert__(uint8_t priority, const struct in6_addr *ip6_dst,
     p->plen = plen;
     p->priority = priority;
     err = get_src_addr(ip6_dst, output_bridge, &p->src_addr);
+    if (err && ipv6_addr_is_set(gw)) {
+        err = get_src_addr(gw, output_bridge, &p->src_addr);
+    }
     if (err) {
         free(p);
         return err;



More information about the dev mailing list