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 <dsahern@gmail.com>
This commit is contained in:
David Ahern 2018-09-29 09:51:08 -07:00
parent ff41db8a75
commit efb0b383d9
3 changed files with 19 additions and 1 deletions

View File

@ -63,6 +63,8 @@ int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
int rtnl_netconfdump_req(struct rtnl_handle *rth, int family) int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result)); __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) int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));

View File

@ -346,7 +346,7 @@ static int netns_list_id(int argc, char **argv)
return -ENOTSUP; 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"); perror("Cannot send dump request");
exit(1); exit(1);
} }

View File

@ -330,6 +330,22 @@ int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
return send(rth->fd, &req, sizeof(req), 0); 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) int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
{ {
return rtnl_wilddump_req_filter(rth, family, type, RTEXT_FILTER_VF); return rtnl_wilddump_req_filter(rth, family, type, RTEXT_FILTER_VF);