libnetlink: Add helper to add a group via setsockopt

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>
This commit is contained in:
David Ahern 2019-06-07 15:38:09 -07:00
parent 7392401027
commit 9860becfe3
2 changed files with 8 additions and 1 deletions

View 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);

View 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) {