diff options
| author | Ben Pfaff <blp@nicira.com> | 2011-01-09 16:57:45 -0800 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2011-01-27 09:26:05 -0800 |
| commit | cceb11f5b12d09cc8afc87ca4fd03e941234d439 (patch) | |
| tree | 9dcdb79b49856023c9f63f4595d82c4a18b37ecf /vswitchd/ovs-brcompatd.c | |
| parent | 18c58479a14f760fb03c2062f9a35961fc74ebb5 (diff) | |
| download | openvswitch-cceb11f5b12d09cc8afc87ca4fd03e941234d439.tar.gz | |
netlink-socket: Add functions for joining and leaving multicast groups.
When this library was originally implemented, support for Linux 2.4 was
important. The Netlink implementation in Linux only added support for
joining and leaving multicast groups after a socket is bound as of Linux
2.6.14, so the library did not support it either. But the current version
of Open vSwitch targets Linux 2.6.18 and over, so it's fine to add this
support now, and this commit does so.
This will be used more extensively in upcoming commits.
Reviewed by Justin Pettit.
Diffstat (limited to 'vswitchd/ovs-brcompatd.c')
| -rw-r--r-- | vswitchd/ovs-brcompatd.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/vswitchd/ovs-brcompatd.c b/vswitchd/ovs-brcompatd.c index 24b28a217..992b8e21b 100644 --- a/vswitchd/ovs-brcompatd.c +++ b/vswitchd/ovs-brcompatd.c @@ -111,7 +111,7 @@ lookup_brc_multicast_group(int *multicast_group) struct nlattr *attrs[ARRAY_SIZE(brc_multicast_policy)]; int retval; - retval = nl_sock_create(NETLINK_GENERIC, 0, 0, 0, &sock); + retval = nl_sock_create(NETLINK_GENERIC, &sock); if (retval) { return retval; } @@ -156,12 +156,17 @@ brc_open(struct nl_sock **sock) return retval; } - retval = nl_sock_create(NETLINK_GENERIC, multicast_group, 0, 0, sock); + retval = nl_sock_create(NETLINK_GENERIC, sock); if (retval) { return retval; } - return 0; + retval = nl_sock_join_mcgroup(*sock, multicast_group); + if (retval) { + nl_sock_destroy(*sock); + *sock = NULL; + } + return retval; } static const struct nl_policy brc_dp_policy[] = { @@ -1318,8 +1323,16 @@ main(int argc, char *argv[]) } if (prune_timeout) { - if (nl_sock_create(NETLINK_ROUTE, RTNLGRP_LINK, 0, 0, &rtnl_sock)) { - ovs_fatal(0, "could not create rtnetlink socket"); + int error; + + error = nl_sock_create(NETLINK_ROUTE, &rtnl_sock); + if (error) { + ovs_fatal(error, "could not create rtnetlink socket"); + } + + error = nl_sock_join_mcgroup(rtnl_sock, RTNLGRP_LINK); + if (error) { + ovs_fatal(error, "could not join RTNLGRP_LINK multicast group"); } } |
