]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
ip route: Add protocol, table id and device to dump request
authorDavid Ahern <dsahern@gmail.com>
Fri, 19 Oct 2018 22:41:39 +0000 (15:41 -0700)
committerDavid Ahern <dsahern@gmail.com>
Thu, 27 Dec 2018 23:33:59 +0000 (15:33 -0800)
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>
ip/iproute.c

index 3c0be0a96d4e3e8d2d6805c159b33d90a721a98f..5bffb9d88b5891f98744b758a607b730d1786bcc 100644 (file)
@@ -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;
 }