X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=lib%2Frtnetlink.c;h=d15669a084f9a3594c5345dcf0df404469b186ef;hb=82d6256ac9f800f8cbe06cf2be41a7b76ab8b322;hp=cc175b41ea5fe05b2c8e51b6a180bb88b1b397d0;hpb=8f5b651c0af0ef4b01f0c6ad8744078649b505d1;p=openvswitch diff --git a/lib/rtnetlink.c b/lib/rtnetlink.c index cc175b41..d15669a0 100644 --- a/lib/rtnetlink.c +++ b/lib/rtnetlink.c @@ -55,7 +55,7 @@ rtnetlink_create(int multicast_group, rtnetlink_parse_func *parse, struct rtnetlink *rtn; rtn = xzalloc(sizeof *rtn); - rtn->notify_sock = 0; + rtn->notify_sock = NULL; rtn->multicast_group = multicast_group; rtn->parse = parse; rtn->change = change; @@ -89,13 +89,20 @@ rtnetlink_notifier_register(struct rtnetlink *rtn, rtnetlink_notify_func *cb, void *aux) { if (!rtn->notify_sock) { - int error = nl_sock_create(NETLINK_ROUTE, rtn->multicast_group, 0, 0, - &rtn->notify_sock); + struct nl_sock *sock; + int error; + + error = nl_sock_create(NETLINK_ROUTE, &sock); + if (!error) { + error = nl_sock_join_mcgroup(sock, rtn->multicast_group); + } if (error) { + nl_sock_destroy(sock); VLOG_WARN("could not create rtnetlink socket: %s", strerror(error)); return error; } + rtn->notify_sock = sock; } else { /* Catch up on notification work so that the new notifier won't * receive any stale notifications. */