[ovs-dev] [PATCH 1/3] netdev-linux: Make netdev_linux_notify_sock join RTNLGRP_IPV4_IFADDR and RTNLGRP_IPV6_IFADDR.
Alex Wang
alexw at nicira.com
Fri Jul 24 21:36:05 UTC 2015
Currently the netdev_linux_notify_sock only joins multicast group
RTNLGRP_LINK for link status change notification. Some ovs features
also require the detection of ip addresses changes and update of the
netdev-linux's cache. To achieve this, we need to make
netdev_linux_notify_sock join the multicast group RTNLGRP_IPV4_IFADDR
and RTNLGRP_IPV6_IFADDR.
Signed-off-by: Alex Wang <alexw at nicira.com>
---
lib/netdev-linux.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 0656f36..fa27312 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -554,16 +554,23 @@ netdev_linux_notify_sock(void)
{
static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
static struct nl_sock *sock;
+ unsigned int mcgroups[3] = {RTNLGRP_LINK, RTNLGRP_IPV4_IFADDR,
+ RTNLGRP_IPV6_IFADDR};
if (ovsthread_once_start(&once)) {
int error;
error = nl_sock_create(NETLINK_ROUTE, &sock);
if (!error) {
- error = nl_sock_join_mcgroup(sock, RTNLGRP_LINK);
- if (error) {
- nl_sock_destroy(sock);
- sock = NULL;
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(mcgroups); i++) {
+ error = nl_sock_join_mcgroup(sock, mcgroups[i]);
+ if (error) {
+ nl_sock_destroy(sock);
+ sock = NULL;
+ break;
+ }
}
}
ovsthread_once_done(&once);
--
1.7.9.5
More information about the dev
mailing list