]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
libnetlink: Add helper to add a group via setsockopt
authorDavid Ahern <dsahern@gmail.com>
Fri, 7 Jun 2019 22:38:09 +0000 (15:38 -0700)
committerDavid Ahern <dsahern@gmail.com>
Tue, 11 Jun 2019 17:30:48 +0000 (10:30 -0700)
groups > 31 have to be joined using the setsockopt. Since the nexthop
group is 32, add a helper to allow 'ip monitor' to listen for nexthop
messages.

Signed-off-by: David Ahern <dsahern@gmail.com>
include/libnetlink.h
lib/libnetlink.c

index 503b3ec11bb6bda345e663f04adedde39289c338..599b2c592f68c38af15d68cfdb3e9f36caa38407 100644 (file)
@@ -45,7 +45,8 @@ int rtnl_open(struct rtnl_handle *rth, unsigned int subscriptions)
 int rtnl_open_byproto(struct rtnl_handle *rth, unsigned int subscriptions,
                             int protocol)
        __attribute__((warn_unused_result));
-
+int rtnl_add_nl_group(struct rtnl_handle *rth, unsigned int group)
+       __attribute__((warn_unused_result));
 void rtnl_close(struct rtnl_handle *rth);
 void rtnl_set_strict_dump(struct rtnl_handle *rth);
 
index 6ae51a9dba14e11de95237e0a8dd16e6dbe4074a..eb85bbdf01eeb5e4cdb4464cb5112e9e72152fd1 100644 (file)
@@ -173,6 +173,12 @@ void rtnl_set_strict_dump(struct rtnl_handle *rth)
        rth->flags |= RTNL_HANDLE_F_STRICT_CHK;
 }
 
+int rtnl_add_nl_group(struct rtnl_handle *rth, unsigned int group)
+{
+       return setsockopt(rth->fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
+                         &group, sizeof(group));
+}
+
 void rtnl_close(struct rtnl_handle *rth)
 {
        if (rth->fd >= 0) {