From: David Ahern <dsahern@kernel.org>
To: stephen@networkplumber.org
Cc: netdev@vger.kernel.org, David Ahern <dsahern@gmail.com>
Subject: [PATCH iproute2-next 5/9] libnetlink: Add helper to create nexthop dump request
Date: Wed, 29 May 2019 20:17:42 -0700 [thread overview]
Message-ID: <20190530031746.2040-6-dsahern@kernel.org> (raw)
In-Reply-To: <20190530031746.2040-1-dsahern@kernel.org>
From: David Ahern <dsahern@gmail.com>
Add rtnl_nexthopdump_req to initiate a dump request of nexthop objects.
Signed-off-by: David Ahern <dsahern@gmail.com>
---
include/libnetlink.h | 4 ++++
lib/libnetlink.c | 27 +++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/include/libnetlink.h b/include/libnetlink.h
index 599b2c592f68..1ddba8dcd220 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -93,6 +93,10 @@ int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req,
int rtnl_dump_request_n(struct rtnl_handle *rth, struct nlmsghdr *n)
__attribute__((warn_unused_result));
+int rtnl_nexthopdump_req(struct rtnl_handle *rth, int family,
+ req_filter_fn_t filter_fn)
+ __attribute__((warn_unused_result));
+
struct rtnl_ctrl_data {
int nsid;
};
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index eb85bbdf01ee..c1cdda3b8d4e 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -25,6 +25,7 @@
#include <linux/fib_rules.h>
#include <linux/if_addrlabel.h>
#include <linux/if_bridge.h>
+#include <linux/nexthop.h>
#include "libnetlink.h"
@@ -252,6 +253,32 @@ int rtnl_open(struct rtnl_handle *rth, unsigned int subscriptions)
return rtnl_open_byproto(rth, subscriptions, NETLINK_ROUTE);
}
+int rtnl_nexthopdump_req(struct rtnl_handle *rth, int family,
+ req_filter_fn_t filter_fn)
+{
+ struct {
+ struct nlmsghdr nlh;
+ struct nhmsg nhm;
+ char buf[128];
+ } req = {
+ .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)),
+ .nlh.nlmsg_type = RTM_GETNEXTHOP,
+ .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+ .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+ .nhm.nh_family = family,
+ };
+
+ if (filter_fn) {
+ int err;
+
+ err = filter_fn(&req.nlh, sizeof(req));
+ if (err)
+ return err;
+ }
+
+ return send(rth->fd, &req, sizeof(req), 0);
+}
+
int rtnl_addrdump_req(struct rtnl_handle *rth, int family,
req_filter_fn_t filter_fn)
{
--
2.11.0
next prev parent reply other threads:[~2019-05-30 4:04 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-30 3:17 [PATCH iproute2-next 0/9] ip: Add support for nexthop objects David Ahern
2019-05-30 3:17 ` [PATCH iproute2-next 1/9] libnetlink: Set NLA_F_NESTED in rta_nest David Ahern
2019-05-30 17:43 ` Stephen Hemminger
2019-05-30 17:50 ` David Ahern
2019-05-31 6:35 ` Michal Kubecek
2019-05-30 3:17 ` [PATCH iproute2-next 2/9] lwtunnel: Pass encap and encap_type attributes to lwt_parse_encap David Ahern
2019-05-30 3:17 ` [PATCH iproute2-next 3/9] libnetlink: Add helper to add a group via setsockopt David Ahern
2019-05-30 3:17 ` [PATCH iproute2-next 4/9] uapi: Import nexthop object API David Ahern
2019-05-30 3:17 ` David Ahern [this message]
2019-05-30 19:56 ` [PATCH iproute2-next 5/9] libnetlink: Add helper to create nexthop dump request Roopa Prabhu
2019-05-30 19:59 ` David Ahern
2019-05-30 3:17 ` [PATCH iproute2-next 6/9] ip route: Export print_rt_flags and print_rta_if David Ahern
2019-05-30 3:17 ` [PATCH iproute2-next 7/9] Add support for nexthop objects David Ahern
2019-05-30 17:45 ` Stephen Hemminger
2019-05-30 17:52 ` David Ahern
2019-05-30 17:45 ` Stephen Hemminger
2019-05-30 17:52 ` David Ahern
2019-05-30 17:52 ` Stephen Hemminger
2019-05-30 17:55 ` David Ahern
2019-05-30 20:01 ` Roopa Prabhu
2019-05-30 3:17 ` [PATCH iproute2-next 8/9] ip route: Add option to use " David Ahern
2019-05-30 19:59 ` Roopa Prabhu
2019-05-30 3:17 ` [PATCH iproute2-next 9/9] ipmonitor: Add nexthop option to monitor David Ahern
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=20190530031746.2040-6-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).