From: David Ahern <dsahern@kernel.org>
To: stephen@networkplumber.org
Cc: netdev@vger.kernel.org, David Ahern <dsahern@gmail.com>
Subject: [PATCH v2 iproute-next 03/10] libnetlink: Add helper to add a group via setsockopt
Date: Fri, 7 Jun 2019 15:38:09 -0700 [thread overview]
Message-ID: <20190607223816.27512-4-dsahern@kernel.org> (raw)
In-Reply-To: <20190607223816.27512-1-dsahern@kernel.org>
From: David Ahern <dsahern@gmail.com>
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 | 3 ++-
lib/libnetlink.c | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/libnetlink.h b/include/libnetlink.h
index 503b3ec11bb6..599b2c592f68 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -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);
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 6ae51a9dba14..eb85bbdf01ee 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -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) {
--
2.11.0
next prev parent reply other threads:[~2019-06-07 22:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-07 22:38 [PATCH v2 iproute-next 00/10] ip: Add support for nexthop objects David Ahern
2019-06-07 22:38 ` [PATCH v2 iproute-next 01/10] libnetlink: Set NLA_F_NESTED in rta_nest David Ahern
2019-06-07 22:38 ` [PATCH v2 iproute-next 02/10] lwtunnel: Pass encap and encap_type attributes to lwt_parse_encap David Ahern
2019-06-07 22:38 ` David Ahern [this message]
2019-06-07 22:38 ` [PATCH v2 iproute-next 04/10] uapi: Import nexthop object API David Ahern
2019-06-07 22:38 ` [PATCH v2 iproute-next 05/10] libnetlink: Add helper to create nexthop dump request David Ahern
2019-06-07 22:38 ` [PATCH v2 iproute-next 06/10] ip route: Export print_rt_flags, print_rta_if and print_rta_gateway David Ahern
2019-06-07 22:38 ` [PATCH v2 iproute-next 07/10] Add support for nexthop objects David Ahern
2019-06-07 22:38 ` [PATCH v2 iproute-next 08/10] ip: Add man page for nexthop command David Ahern
2019-06-07 22:38 ` [PATCH v2 iproute-next 09/10] ip route: Add option to use nexthop objects David Ahern
2019-06-07 22:38 ` [PATCH v2 iproute-next 10/10] ipmonitor: Add nexthop option to monitor David Ahern
2019-06-07 23:37 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190607223816.27512-4-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.