libnetlink: Convert GETNEIGHTBL dumps to use rtnl_neightbldump_req

Add rtnl_neightbldump_req for neighbor table dumps using the proper ndtmsg
as the header. Convert existing RTM_GETNEIGHTBL dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
David Ahern 2018-09-29 09:47:41 -07:00
parent 9e0ab19c4d
commit ff41db8a75
3 changed files with 19 additions and 1 deletions

View File

@ -57,6 +57,8 @@ 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_neightbldump_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)

View File

@ -658,7 +658,7 @@ static int ipntable_show(int argc, char **argv)
argc--; argv++;
}
if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETNEIGHTBL) < 0) {
if (rtnl_neightbldump_req(&rth, preferred_family) < 0) {
perror("Cannot send dump request");
exit(1);
}

View File

@ -282,6 +282,22 @@ int rtnl_neighdump_req(struct rtnl_handle *rth, int family)
return send(rth->fd, &req, sizeof(req), 0);
}
int rtnl_neightbldump_req(struct rtnl_handle *rth, int family)
{
struct {
struct nlmsghdr nlh;
struct ndtmsg ndtmsg;
} req = {
.nlh.nlmsg_len = sizeof(req),
.nlh.nlmsg_type = RTM_GETNEIGHTBL,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
.ndtmsg.ndtm_family = family,
};
return send(rth->fd, &req, sizeof(req), 0);
}
int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
{
struct {