libnetlink: linkdump_req: Only AF_UNSPEC family expects an ext_filter_mask

Only AF_UNSPEC handled by rtnl_dump_ifinfo expects an ext_filter_mask
on a dump request. Update the linkdump request functions to only set
and send ext_filter_mask for AF_UNSPEC.

Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
David Ahern 2018-10-04 14:12:39 -07:00
parent 92e03242c4
commit d97b16b2c9

View File

@ -380,14 +380,34 @@ int rtnl_nsiddump_req(struct rtnl_handle *rth, int family)
return send(rth->fd, &req, sizeof(req), 0);
}
static int __rtnl_linkdump_req(struct rtnl_handle *rth, int family)
{
struct {
struct nlmsghdr nlh;
struct ifinfomsg ifm;
} req = {
.nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)),
.nlh.nlmsg_type = RTM_GETLINK,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
.ifm.ifi_family = family,
};
return send(rth->fd, &req, sizeof(req), 0);
}
int rtnl_linkdump_req(struct rtnl_handle *rth, int family)
{
if (family == AF_UNSPEC)
return rtnl_linkdump_req_filter(rth, family, RTEXT_FILTER_VF);
return __rtnl_linkdump_req(rth, family);
}
int rtnl_linkdump_req_filter(struct rtnl_handle *rth, int family,
__u32 filt_mask)
{
if (family == AF_UNSPEC) {
struct {
struct nlmsghdr nlh;
struct ifinfomsg ifm;
@ -406,11 +426,15 @@ int rtnl_linkdump_req_filter(struct rtnl_handle *rth, int family,
};
return send(rth->fd, &req, sizeof(req), 0);
}
return __rtnl_linkdump_req(rth, family);
}
int rtnl_linkdump_req_filter_fn(struct rtnl_handle *rth, int family,
req_filter_fn_t filter_fn)
{
if (family == AF_UNSPEC) {
struct {
struct nlmsghdr nlh;
struct ifinfomsg ifm;
@ -432,6 +456,9 @@ int rtnl_linkdump_req_filter_fn(struct rtnl_handle *rth, int family,
return err;
return send(rth->fd, &req, req.nlh.nlmsg_len, 0);
}
return __rtnl_linkdump_req(rth, family);
}
int rtnl_statsdump_req_filter(struct rtnl_handle *rth, int fam, __u32 filt_mask)