[ovs-dev] [PATCH 1/3] netdev: fix netmask in netdev_get_addrs
Thadeu Lima de Souza Cascardo
cascardo at redhat.com
Tue Nov 15 09:49:45 UTC 2016
When iterating on getifaddrs result, ifa_netmask is dereferenced, but it's
already a pointer to struct sockaddr. This would result in wrong masks being
used when comparing addresses while calculating the source address given a
destination address at the routing code.
For example, the mask ::ffff:116.85.0.0 would be used, causing 172.16.100.0/24
to match 172.16.101.1, though they should not match.
This will not happen when using a dummy netdev, as netdev_get_addrs is not used
by it.
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo at redhat.com>
---
lib/netdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/netdev.c b/lib/netdev.c
index 6c4c657..ad90ef6 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -1913,7 +1913,7 @@ netdev_get_addrs(const char dev[], struct in6_addr **paddr,
sin = ALIGNED_CAST(const struct sockaddr_in *, ifa->ifa_addr);
in6_addr_set_mapped_ipv4(&addr_array[i], sin->sin_addr.s_addr);
- sin = (struct sockaddr_in *) &ifa->ifa_netmask;
+ sin = (struct sockaddr_in *) ifa->ifa_netmask;
in6_addr_set_mapped_ipv4(&mask_array[i], sin->sin_addr.s_addr);
i++;
} else if (family == AF_INET6) {
@@ -1921,7 +1921,7 @@ netdev_get_addrs(const char dev[], struct in6_addr **paddr,
sin6 = ALIGNED_CAST(const struct sockaddr_in6 *, ifa->ifa_addr);
memcpy(&addr_array[i], &sin6->sin6_addr, sizeof *addr_array);
- sin6 = (struct sockaddr_in6 *) &ifa->ifa_netmask;
+ sin6 = (struct sockaddr_in6 *) ifa->ifa_netmask;
memcpy(&mask_array[i], &sin6->sin6_addr, sizeof *mask_array);
i++;
}
--
2.7.4
More information about the dev
mailing list