From: David Ahern <dsahern@gmail.com>
To: Stefano Brivio <sbrivio@redhat.com>, David Miller <davem@davemloft.net>
Cc: Jianlin Shi <jishi@redhat.com>, Wei Wang <weiwan@google.com>,
Martin KaFai Lau <kafai@fb.com>,
Eric Dumazet <edumazet@google.com>,
Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH net v5 5/6] ipv6: Dump route exceptions if requested
Date: Tue, 18 Jun 2019 09:19:53 -0600 [thread overview]
Message-ID: <333b0a08-07dd-3c70-1268-2d9eb5646564@gmail.com> (raw)
In-Reply-To: <364403cca3d7836557f8ffe83c9c48b436be76eb.1560827176.git.sbrivio@redhat.com>
On 6/18/19 7:20 AM, Stefano Brivio wrote:
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 0f60eb3a2873..7375f3b7d310 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -4854,33 +4854,94 @@ static bool fib6_info_uses_dev(const struct fib6_info *f6i,
> return false;
> }
>
> -int rt6_dump_route(struct fib6_info *rt, void *p_arg)
> +/* Return -1 if done with node, number of handled routes on partial dump */
> +int rt6_dump_route(struct fib6_info *rt, void *p_arg, unsigned int skip)
Changing the return code of rt6_dump_route should be a separate patch.
> {
> struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
> struct fib_dump_filter *filter = &arg->filter;
> + struct rt6_exception_bucket *bucket;
> unsigned int flags = NLM_F_MULTI;
> + struct rt6_exception *rt6_ex;
> struct net *net = arg->net;
> + int i, count = 0;
>
> 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;
> - }
> + if (filter->filter_set &&
> + ((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;
> + }
> +
> + if (filter->filter_set ||
> + !filter->dump_routes || !filter->dump_exceptions) {
> 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 (filter->dump_routes) {
> + if (skip) {
> + skip--;
> + } else {
> + 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;
> + }
> + count++;
> + }
> + }
> +
> + if (!filter->dump_exceptions)
> + return -1;
> +
And the dump of the exception bucket should be a standalone function.
You will see why with net-next (it is per fib6_nh).
> + bucket = rcu_dereference(rt->rt6i_exception_bucket);
> + if (!bucket)
> + return -1;
> +
> + for (i = 0; i < FIB6_EXCEPTION_BUCKET_SIZE; i++) {
> + hlist_for_each_entry(rt6_ex, &bucket->chain, hlist) {
> + if (skip) {
> + skip--;
> + continue;
> + }
> +
> + /* Expiration of entries doesn't bump sernum, insertion
> + * does. Removal is triggered by insertion, so we can
> + * rely on the fact that if entries change between two
> + * partial dumps, this node is scanned again completely,
> + * see rt6_insert_exception() and fib6_dump_table().
> + *
> + * Count expired entries we go through as handled
> + * entries that we'll skip next time, in case of partial
> + * node dump. Otherwise, if entries expire meanwhile,
> + * we'll skip the wrong amount.
> + */
> + if (rt6_check_expired(rt6_ex->rt6i)) {
> + count++;
> + continue;
> + }
> +
> + if (rt6_fill_node(net, arg->skb, rt, &rt6_ex->rt6i->dst,
> + NULL, NULL, 0, RTM_NEWROUTE,
> + NETLINK_CB(arg->cb->skb).portid,
> + arg->cb->nlh->nlmsg_seq, flags)) {
> + return count;
> + }
> +
> + count++;
> + }
> + bucket++;
> + }
> +
> + return -1;
> }
>
> static int inet6_rtm_valid_getroute_req(struct sk_buff *skb,
>
next prev parent reply other threads:[~2019-06-18 15:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-18 13:20 [PATCH net v5 0/6] Fix listing (IPv4, IPv6) and flushing (IPv6) of cached route exceptions Stefano Brivio
2019-06-18 13:20 ` [PATCH net v5 1/6] fib_frontend, ip6_fib: Select routes or exceptions dump from RTM_F_CLONED Stefano Brivio
2019-06-18 14:49 ` David Ahern
2019-06-18 13:20 ` [PATCH net v5 2/6] ipv4/fib_frontend: Allow RTM_F_CLONED flag to be used for filtering Stefano Brivio
2019-06-18 14:49 ` David Ahern
2019-06-18 13:20 ` [PATCH net v5 3/6] ipv4: Dump route exceptions if requested Stefano Brivio
2019-06-18 14:48 ` David Ahern
2019-06-19 23:57 ` Stefano Brivio
2019-06-18 13:20 ` [PATCH net v5 4/6] Revert "net/ipv6: Bail early if user only wants cloned entries" Stefano Brivio
2019-06-18 14:51 ` David Ahern
2019-06-18 13:20 ` [PATCH net v5 5/6] ipv6: Dump route exceptions if requested Stefano Brivio
2019-06-18 15:19 ` David Ahern [this message]
2019-06-19 23:57 ` Stefano Brivio
2019-06-18 13:20 ` [PATCH net v5 6/6] ip6_fib: Don't discard nodes with valid routing information in fib6_locate_1() Stefano Brivio
2019-06-18 14:51 ` [PATCH net v5 0/6] Fix listing (IPv4, IPv6) and flushing (IPv6) of cached route exceptions David Ahern
2019-06-18 16:25 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=333b0a08-07dd-3c70-1268-2d9eb5646564@gmail.com \
--to=dsahern@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jishi@redhat.com \
--cc=kafai@fb.com \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=netdev@vger.kernel.org \
--cc=sbrivio@redhat.com \
--cc=weiwan@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).