]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
libnetlink: Convert GETADDRLABEL dumps to use rtnl_addrlbldump_req
authorDavid Ahern <dsahern@gmail.com>
Sat, 29 Sep 2018 17:43:15 +0000 (10:43 -0700)
committerDavid Ahern <dsahern@gmail.com>
Wed, 3 Oct 2018 01:38:29 +0000 (18:38 -0700)
Add rtnl_addrlbldump_req for address label dumps using the proper
ifaddrlblmsg as the header. Convert existing RTM_GETADDRALBEL dumps
to use it.

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

index a60af316b5051f37e6046b85ea34563a4e702530..bacaec8216f75c9bc92494866f418cbcfd9ecc53 100644 (file)
@@ -49,6 +49,8 @@ void rtnl_close(struct rtnl_handle *rth);
 
 int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
        __attribute__((warn_unused_result));
+int rtnl_addrlbldump_req(struct rtnl_handle *rth, int family)
+       __attribute__((warn_unused_result));
 int rtnl_routedump_req(struct rtnl_handle *rth, int family)
        __attribute__((warn_unused_result));
 
index 2f79c56dcead29e41c8bff2dbf9e977c779083cc..845fe4c5db27c419c08f0a74a5369b2e36203c5c 100644 (file)
@@ -118,7 +118,7 @@ static int ipaddrlabel_list(int argc, char **argv)
                return -1;
        }
 
-       if (rtnl_wilddump_request(&rth, af, RTM_GETADDRLABEL) < 0) {
+       if (rtnl_addrlbldump_req(&rth, af) < 0) {
                perror("Cannot send dump request");
                return 1;
        }
@@ -237,7 +237,7 @@ static int ipaddrlabel_flush(int argc, char **argv)
                return -1;
        }
 
-       if (rtnl_wilddump_request(&rth, af, RTM_GETADDRLABEL) < 0) {
+       if (rtnl_addrlbldump_req(&rth, af) < 0) {
                perror("Cannot send dump request");
                return -1;
        }
index fda5309ce44d77fa1ccf9d8a8697e2386e0a631b..fb5f1714c2d89484fecb2b9ca82cdbf25f000e5c 100644 (file)
@@ -22,6 +22,7 @@
 #include <errno.h>
 #include <time.h>
 #include <sys/uio.h>
+#include <linux/if_addrlabel.h>
 
 #include "libnetlink.h"
 
@@ -215,6 +216,22 @@ int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
        return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_addrlbldump_req(struct rtnl_handle *rth, int family)
+{
+       struct {
+               struct nlmsghdr nlh;
+               struct ifaddrlblmsg ifal;
+       } req = {
+               .nlh.nlmsg_len = sizeof(req),
+               .nlh.nlmsg_type = RTM_GETADDRLABEL,
+               .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+               .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+               .ifal.ifal_family = family,
+       };
+
+       return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_routedump_req(struct rtnl_handle *rth, int family)
 {
        struct {