mirror of
https://github.com/openvswitch/ovs
synced 2025-10-25 15:07:05 +00:00
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.
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user