ip route: Add protocol, table id and device to dump request
Add protocol, table id and device to dump request if set in filter. If kernel side filtering is supported it is used to reduce the amount of data sent to userspace. Older kernels do not parse attributes on a route dump request, so these are silently ignored and ip will do the filtering in userspace. Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
parent
43fd93ae46
commit
c7e6371bc4
14
ip/iproute.c
14
ip/iproute.c
|
|
@ -1669,10 +1669,24 @@ static int iproute_flush(int do_ipv6, rtnl_filter_t filter_fn)
|
|||
static int iproute_dump_filter(struct nlmsghdr *nlh, int reqlen)
|
||||
{
|
||||
struct rtmsg *rtm = NLMSG_DATA(nlh);
|
||||
int err;
|
||||
|
||||
rtm->rtm_protocol = filter.protocol;
|
||||
if (filter.cloned)
|
||||
rtm->rtm_flags |= RTM_F_CLONED;
|
||||
|
||||
if (filter.tb) {
|
||||
err = addattr32(nlh, reqlen, RTA_TABLE, filter.tb);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (filter.oif) {
|
||||
err = addattr32(nlh, reqlen, RTA_OIF, filter.oif);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue