Skip to content

Commit bf9a8a0

Browse files
sbrivio-rhdavem330
authored andcommitted
ipv6/route: Change return code of rt6_dump_route() for partial node dumps
In the next patch, we are going to add optional dump of exceptions to rt6_dump_route(). Change the return code of rt6_dump_route() to accomodate partial node dumps: we might dump multiple routes per node, and might be able to dump only a given number of them, so fib6_dump_node() will need to know how many routes have been dumped on partial dump, to restart the dump from the point where it was interrupted. Note that fib6_dump_node() is the only caller and already handles all non-negative return codes as success: those become -1 to signal that we're done with the node. If we fail, return 0, as we were unable to dump the single route in the node, but we're not done with it. Signed-off-by: Stefano Brivio <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3401bfb commit bf9a8a0

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

net/ipv6/ip6_fib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ static int fib6_dump_node(struct fib6_walker *w)
465465

466466
for_each_fib6_walker_rt(w) {
467467
res = rt6_dump_route(rt, w->args);
468-
if (res < 0) {
468+
if (res >= 0) {
469469
/* Frame is full, suspend walking */
470470
w->leaf = rt;
471471
return 1;

net/ipv6/route.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5522,6 +5522,7 @@ static bool fib6_info_uses_dev(const struct fib6_info *f6i,
55225522
return false;
55235523
}
55245524

5525+
/* Return -1 if done with node, number of handled routes on partial dump */
55255526
int rt6_dump_route(struct fib6_info *rt, void *p_arg)
55265527
{
55275528
struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
@@ -5530,25 +5531,28 @@ int rt6_dump_route(struct fib6_info *rt, void *p_arg)
55305531
struct net *net = arg->net;
55315532

55325533
if (rt == net->ipv6.fib6_null_entry)
5533-
return 0;
5534+
return -1;
55345535

55355536
if ((filter->flags & RTM_F_PREFIX) &&
55365537
!(rt->fib6_flags & RTF_PREFIX_RT)) {
55375538
/* success since this is not a prefix route */
5538-
return 1;
5539+
return -1;
55395540
}
55405541
if (filter->filter_set) {
55415542
if ((filter->rt_type && rt->fib6_type != filter->rt_type) ||
55425543
(filter->dev && !fib6_info_uses_dev(rt, filter->dev)) ||
55435544
(filter->protocol && rt->fib6_protocol != filter->protocol)) {
5544-
return 1;
5545+
return -1;
55455546
}
55465547
flags |= NLM_F_DUMP_FILTERED;
55475548
}
55485549

5549-
return rt6_fill_node(net, arg->skb, rt, NULL, NULL, NULL, 0,
5550-
RTM_NEWROUTE, NETLINK_CB(arg->cb->skb).portid,
5551-
arg->cb->nlh->nlmsg_seq, flags);
5550+
if (rt6_fill_node(net, arg->skb, rt, NULL, NULL, NULL, 0, RTM_NEWROUTE,
5551+
NETLINK_CB(arg->cb->skb).portid,
5552+
arg->cb->nlh->nlmsg_seq, flags))
5553+
return 0;
5554+
5555+
return -1;
55525556
}
55535557

55545558
static int inet6_rtm_valid_getroute_req(struct sk_buff *skb,

0 commit comments

Comments
 (0)