diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2019-06-21 17:45:26 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-06-24 10:18:49 -0700 |
commit | bf9a8a061ddcd6a58b312466ea5da44ab54ce8cb (patch) | |
tree | b7b2fc3085074fd764f28b34a729b09dc594f2be /net/ipv6/route.c | |
parent | 3401bfb1638efdd0b721d03c51c48171a0cde8c6 (diff) | |
download | lwn-bf9a8a061ddcd6a58b312466ea5da44ab54ce8cb.tar.gz lwn-bf9a8a061ddcd6a58b312466ea5da44ab54ce8cb.zip |
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 <sbrivio@redhat.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r-- | net/ipv6/route.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 0a7c21ac0b95..7c86ef046ebb 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -5522,6 +5522,7 @@ static bool fib6_info_uses_dev(const struct fib6_info *f6i, return false; } +/* Return -1 if done with node, number of handled routes on partial dump */ int rt6_dump_route(struct fib6_info *rt, void *p_arg) { 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) struct net *net = arg->net; if (rt == net->ipv6.fib6_null_entry) - return 0; + return -1; if ((filter->flags & RTM_F_PREFIX) && !(rt->fib6_flags & RTF_PREFIX_RT)) { /* success since this is not a prefix route */ - return 1; + return -1; } if (filter->filter_set) { if ((filter->rt_type && rt->fib6_type != filter->rt_type) || (filter->dev && !fib6_info_uses_dev(rt, filter->dev)) || (filter->protocol && rt->fib6_protocol != filter->protocol)) { - return 1; + return -1; } flags |= NLM_F_DUMP_FILTERED; } - return rt6_fill_node(net, arg->skb, rt, NULL, NULL, NULL, 0, - RTM_NEWROUTE, NETLINK_CB(arg->cb->skb).portid, - arg->cb->nlh->nlmsg_seq, flags); + if (rt6_fill_node(net, arg->skb, rt, NULL, NULL, NULL, 0, RTM_NEWROUTE, + NETLINK_CB(arg->cb->skb).portid, + arg->cb->nlh->nlmsg_seq, flags)) + return 0; + + return -1; } static int inet6_rtm_valid_getroute_req(struct sk_buff *skb, |