]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
libnetlink: Convert GETNEIGHTBL dumps to use rtnl_neightbldump_req
authorDavid Ahern <dsahern@gmail.com>
Sat, 29 Sep 2018 16:47:41 +0000 (09:47 -0700)
committerDavid Ahern <dsahern@gmail.com>
Wed, 3 Oct 2018 01:39:02 +0000 (18:39 -0700)
Add rtnl_neightbldump_req for neighbor table dumps using the proper ndtmsg
as the header. Convert existing RTM_GETNEIGHTBL dumps to use it.

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

index e22ccbb82ce28061ea3f8400f9d9e516205106d2..5ccc421b4b0ec80ec5c018147c19c3a5fb5a296c 100644 (file)
@@ -57,6 +57,8 @@ int rtnl_ruledump_req(struct rtnl_handle *rth, int family)
        __attribute__((warn_unused_result));
 int rtnl_neighdump_req(struct rtnl_handle *rth, int family)
        __attribute__((warn_unused_result));
+int rtnl_neightbldump_req(struct rtnl_handle *rth, int family)
+       __attribute__((warn_unused_result));
 int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
        __attribute__((warn_unused_result));
 int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
index dd4f7c2ee6d91ac688b5d679cc61acb5ff2871a6..ce3f4614e32b47d5b891c7e7b940f4ca93a17507 100644 (file)
@@ -658,7 +658,7 @@ static int ipntable_show(int argc, char **argv)
                argc--; argv++;
        }
 
-       if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETNEIGHTBL) < 0) {
+       if (rtnl_neightbldump_req(&rth, preferred_family) < 0) {
                perror("Cannot send dump request");
                exit(1);
        }
index fd0f95a24194da2f9645e51b81e8995679ad290e..c28047e4b055d856e9818702a5270a913b13ea07 100644 (file)
@@ -282,6 +282,22 @@ int rtnl_neighdump_req(struct rtnl_handle *rth, int family)
        return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_neightbldump_req(struct rtnl_handle *rth, int family)
+{
+       struct {
+               struct nlmsghdr nlh;
+               struct ndtmsg ndtmsg;
+       } req = {
+               .nlh.nlmsg_len = sizeof(req),
+               .nlh.nlmsg_type = RTM_GETNEIGHTBL,
+               .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+               .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+               .ndtmsg.ndtm_family = family,
+       };
+
+       return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
 {
        struct {