From: David Ahern Date: Sat, 29 Sep 2018 16:51:08 +0000 (-0700) Subject: libnetlink: Convert GETNSID dumps to use rtnl_nsiddump_req X-Git-Tag: v4.20.0~101^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=efb0b383d98840a9caf8e0f44de18d496251c374;p=thirdparty%2Fiproute2.git libnetlink: Convert GETNSID dumps to use rtnl_nsiddump_req Add rtnl_nsiddump_req for namespace id dumps using the proper rtgenmsg as the header. Convert existing RTM_GETNSID dumps to use it. Signed-off-by: David Ahern --- diff --git a/include/libnetlink.h b/include/libnetlink.h index 5ccc421b4..f22c92ac0 100644 --- a/include/libnetlink.h +++ b/include/libnetlink.h @@ -63,6 +63,8 @@ int rtnl_mdbdump_req(struct rtnl_handle *rth, int family) __attribute__((warn_unused_result)); int rtnl_netconfdump_req(struct rtnl_handle *rth, int family) __attribute__((warn_unused_result)); +int rtnl_nsiddump_req(struct rtnl_handle *rth, int family) + __attribute__((warn_unused_result)); int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type) __attribute__((warn_unused_result)); diff --git a/ip/ipnetns.c b/ip/ipnetns.c index 368be0cbc..e8500c773 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -346,7 +346,7 @@ static int netns_list_id(int argc, char **argv) return -ENOTSUP; } - if (rtnl_wilddump_request(&rth, AF_UNSPEC, RTM_GETNSID) < 0) { + if (rtnl_nsiddump_req(&rth, AF_UNSPEC) < 0) { perror("Cannot send dump request"); exit(1); } diff --git a/lib/libnetlink.c b/lib/libnetlink.c index c28047e4b..2dd14ac5e 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -330,6 +330,22 @@ int rtnl_netconfdump_req(struct rtnl_handle *rth, int family) return send(rth->fd, &req, sizeof(req), 0); } +int rtnl_nsiddump_req(struct rtnl_handle *rth, int family) +{ + struct { + struct nlmsghdr nlh; + struct rtgenmsg rtm; + } req = { + .nlh.nlmsg_len = sizeof(req), + .nlh.nlmsg_type = RTM_GETNSID, + .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST, + .nlh.nlmsg_seq = rth->dump = ++rth->seq, + .rtm.rtgen_family = family, + }; + + return send(rth->fd, &req, sizeof(req), 0); +} + int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type) { return rtnl_wilddump_req_filter(rth, family, type, RTEXT_FILTER_VF);