diff mbox

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

Message ID AT5PR84MB00029BE1A8EEE23AC39610D199FE0@AT5PR84MB0002.NAMPRD84.PROD.OUTLOOK.COM
State Not Applicable
Headers show

Commit Message

Waizel, Ariel Sept. 13, 2016, 7:08 a.m. UTC
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@hpe.com>

Comments

Thadeu Lima de Souza Cascardo Oct. 4, 2016, 4:48 p.m. UTC | #1
On Tue, Sep 13, 2016 at 07:08:52AM +0000, Waizel, Ariel wrote:
> 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@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;

Hi, Ariel.

Thanks for that. Can you resend wrapping the log text to 72 columns and add a
test? At least one test verifying that adding such routes with ovs/route/add
work as expected.

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>

Cascardo.
diff mbox

Patch

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;