diff mbox

[ovs-dev,1/2] ovs-router: ignore IPv6 source addresses for IPv4 routes

Message ID 1469376447-21980-1-git-send-email-cascardo@redhat.com
State Accepted
Delegated to: Daniele Di Proietto
Headers show

Commit Message

Thadeu Lima de Souza Cascardo July 24, 2016, 4:07 p.m. UTC
Though this should not happen when we have another address on the device that is
IPv4 mapped, we should prevent adding a routing entry to IPv4 with an IPv6
source address.

This entry has been observed when the addresses list was out of date.

Cached: 172.16.10.1/32 dev br3 SRC fe80::c4d0:14ff:feb1:b54b
Cached: 172.16.10.0/24 dev br3 SRC fe80::c4d0:14ff:feb1:b54b

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
---
 lib/ovs-router.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Ben Pfaff July 27, 2016, 8:49 p.m. UTC | #1
On Sun, Jul 24, 2016 at 01:07:26PM -0300, Thadeu Lima de Souza Cascardo wrote:
> Though this should not happen when we have another address on the device that is
> IPv4 mapped, we should prevent adding a routing entry to IPv4 with an IPv6
> source address.
> 
> This entry has been observed when the addresses list was out of date.
> 
> Cached: 172.16.10.1/32 dev br3 SRC fe80::c4d0:14ff:feb1:b54b
> Cached: 172.16.10.0/24 dev br3 SRC fe80::c4d0:14ff:feb1:b54b
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>

Applied, thanks!

Does this need any backports?
Thadeu Lima de Souza Cascardo July 28, 2016, 4:17 p.m. UTC | #2
On Wed, Jul 27, 2016 at 01:49:39PM -0700, Ben Pfaff wrote:
> On Sun, Jul 24, 2016 at 01:07:26PM -0300, Thadeu Lima de Souza Cascardo wrote:
> > Though this should not happen when we have another address on the device that is
> > IPv4 mapped, we should prevent adding a routing entry to IPv4 with an IPv6
> > source address.
> > 
> > This entry has been observed when the addresses list was out of date.
> > 
> > Cached: 172.16.10.1/32 dev br3 SRC fe80::c4d0:14ff:feb1:b54b
> > Cached: 172.16.10.0/24 dev br3 SRC fe80::c4d0:14ff:feb1:b54b
> > 
> > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
> 
> Applied, thanks!
> 
> Does this need any backports?
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev

No, 2.5 didn't use netdev_get_addrs_list. That was introduced in commit
a8704b502785a9661721f041b2ee168d7a4eb460 ("tunneling: Handle multiple ip address
for given device.") by Pravin.

Cascardo.
diff mbox

Patch

diff --git a/lib/ovs-router.c b/lib/ovs-router.c
index 90e2f82..685e1ad 100644
--- a/lib/ovs-router.c
+++ b/lib/ovs-router.c
@@ -136,6 +136,7 @@  get_src_addr(const struct in6_addr *ip6_dst,
     struct in6_addr *mask, *addr6;
     int err, n_in6, i, max_plen = -1;
     struct netdev *dev;
+    bool is_ipv4;
 
     err = netdev_open(output_bridge, NULL, &dev);
     if (err) {
@@ -147,10 +148,16 @@  get_src_addr(const struct in6_addr *ip6_dst,
         goto out;
     }
 
+    is_ipv4 = IN6_IS_ADDR_V4MAPPED(ip6_dst);
+
     for (i = 0; i < n_in6; i++) {
         struct in6_addr a1, a2;
         int mask_bits;
 
+        if (is_ipv4 && !IN6_IS_ADDR_V4MAPPED(&addr6[i])) {
+            continue;
+        }
+
         a1 = ipv6_addr_bitand(ip6_dst, &mask[i]);
         a2 = ipv6_addr_bitand(&addr6[i], &mask[i]);
         mask_bits = bitmap_count1(ALIGNED_CAST(const unsigned long *, &mask[i]), 128);