From: David Ahern Date: Sat, 29 Sep 2018 17:43:15 +0000 (-0700) Subject: libnetlink: Convert GETADDRLABEL dumps to use rtnl_addrlbldump_req X-Git-Tag: v4.20.0~101^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=393600231aac32a4e05a4c4c25b0d5b3d0acd17c;p=thirdparty%2Fiproute2.git libnetlink: Convert GETADDRLABEL dumps to use rtnl_addrlbldump_req 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 --- diff --git a/include/libnetlink.h b/include/libnetlink.h index a60af316b..bacaec821 100644 --- a/include/libnetlink.h +++ b/include/libnetlink.h @@ -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)); diff --git a/ip/ipaddrlabel.c b/ip/ipaddrlabel.c index 2f79c56dc..845fe4c5d 100644 --- a/ip/ipaddrlabel.c +++ b/ip/ipaddrlabel.c @@ -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; } diff --git a/lib/libnetlink.c b/lib/libnetlink.c index fda5309ce..fb5f1714c 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -22,6 +22,7 @@ #include #include #include +#include #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 {