net/ipv6: Plumb support for filtering route dumps
Implement kernel side filtering of routes by table id, egress device index, protocol, and route type. If the table id is given in the filter, lookup the table and call fib6_dump_table directly for it. Move the existing route flags check for prefix only routes to the new filter. Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
18a8021a7b
commit
13e38901d4
@@ -583,10 +583,12 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
err = ip_valid_fib_dump_req(net, nlh, &arg.filter, cb->extack);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
} else if (nlmsg_len(nlh) >= sizeof(struct rtmsg)) {
|
||||
struct rtmsg *rtm = nlmsg_data(nlh);
|
||||
|
||||
s_h = cb->args[0];
|
||||
s_e = cb->args[1];
|
||||
if (rtm->rtm_flags & RTM_F_PREFIX)
|
||||
arg.filter.flags = RTM_F_PREFIX;
|
||||
}
|
||||
|
||||
w = (void *)cb->args[2];
|
||||
if (!w) {
|
||||
@@ -612,6 +614,20 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
arg.net = net;
|
||||
w->args = &arg;
|
||||
|
||||
if (arg.filter.table_id) {
|
||||
tb = fib6_get_table(net, arg.filter.table_id);
|
||||
if (!tb) {
|
||||
NL_SET_ERR_MSG_MOD(cb->extack, "FIB table does not exist");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
res = fib6_dump_table(tb, skb, cb);
|
||||
goto out;
|
||||
}
|
||||
|
||||
s_h = cb->args[0];
|
||||
s_e = cb->args[1];
|
||||
|
||||
rcu_read_lock();
|
||||
for (h = s_h; h < FIB6_TABLE_HASHSZ; h++, s_e = 0) {
|
||||
e = 0;
|
||||
@@ -621,16 +637,16 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
goto next;
|
||||
res = fib6_dump_table(tb, skb, cb);
|
||||
if (res != 0)
|
||||
goto out;
|
||||
goto out_unlock;
|
||||
next:
|
||||
e++;
|
||||
}
|
||||
}
|
||||
out:
|
||||
out_unlock:
|
||||
rcu_read_unlock();
|
||||
cb->args[1] = e;
|
||||
cb->args[0] = h;
|
||||
|
||||
out:
|
||||
res = res < 0 ? res : skb->len;
|
||||
if (res <= 0)
|
||||
fib6_dump_end(cb);
|
||||
|
Reference in New Issue
Block a user