]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
libnetlink: Convert GETNEIGH dumps to use rtnl_neighdump_req
authorDavid Ahern <dsahern@gmail.com>
Sat, 29 Sep 2018 16:42:40 +0000 (09:42 -0700)
committerDavid Ahern <dsahern@gmail.com>
Wed, 3 Oct 2018 01:38:59 +0000 (18:38 -0700)
Add rtnl_neighdump_req for neighbor dumps using the proper ndmsg
as the header. Convert existing rtnl_wilddump_request for RTM_GETNEIGH
to use it.

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

index 5f6bbe55fe4a9988ec4c7eb58fd0fd7e28432b79..e22ccbb82ce28061ea3f8400f9d9e516205106d2 100644 (file)
@@ -55,6 +55,8 @@ int rtnl_routedump_req(struct rtnl_handle *rth, int family)
        __attribute__((warn_unused_result));
 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_mdbdump_req(struct rtnl_handle *rth, int family)
        __attribute__((warn_unused_result));
 int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
index 89e4d6a2a6620558bee97b66dfc5586d219e7594..fd0f95a24194da2f9645e51b81e8995679ad290e 100644 (file)
@@ -266,6 +266,22 @@ int rtnl_ruledump_req(struct rtnl_handle *rth, int family)
        return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_neighdump_req(struct rtnl_handle *rth, int family)
+{
+       struct {
+               struct nlmsghdr nlh;
+               struct ndmsg ndm;
+       } req = {
+               .nlh.nlmsg_len = sizeof(req),
+               .nlh.nlmsg_type = RTM_GETNEIGH,
+               .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+               .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+               .ndm.ndm_family = family,
+       };
+
+       return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
 {
        struct {
index 67d86b67957b8a308c5b7db006745ab9a1f436f5..ce7c09978c2b7b96aeec442f639cad153fb72a51 100644 (file)
@@ -424,7 +424,7 @@ static int do_one_request(struct nlmsghdr *n)
 
 static void load_initial_table(void)
 {
-       if (rtnl_wilddump_request(&rth, AF_INET, RTM_GETNEIGH) < 0) {
+       if (rtnl_neighdump_req(&rth, AF_INET) < 0) {
                perror("dump request failed");
                exit(1);
        }