From: David Ahern <dsahern@kernel.org>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: idosch@mellanox.com, David Ahern <dsahern@gmail.com>
Subject: [PATCH net-next 5/7] ipv6: Refactor fib6_drop_pcpu_from
Date: Fri, 26 Apr 2019 18:56:55 -0700 [thread overview]
Message-ID: <20190427015657.24655-6-dsahern@kernel.org> (raw)
In-Reply-To: <20190427015657.24655-1-dsahern@kernel.org>
From: David Ahern <dsahern@gmail.com>
Move the existing pcpu walk in fib6_drop_pcpu_from to a new
helper, __fib6_drop_pcpu_from, that can be invoked per fib6_nh
with a reference to the from entries that need to be evicted. If
the passed in from is non-NULL then only entries associated with
that fib6_info are removed (fib entry is deleted); if the from
is NULL are entries are flushed (nexthop is deleted).
For fib6_info entries with builtin fib6_nh (ie., current code)
there is no change in behavior.
Signed-off-by: David Ahern <dsahern@gmail.com>
---
net/ipv6/ip6_fib.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 793830b2965d..aaffe4a653d8 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -874,10 +874,10 @@ static struct fib6_node *fib6_add_1(struct net *net,
return ln;
}
-static void fib6_drop_pcpu_from(struct fib6_info *f6i,
- const struct fib6_table *table)
+static void __fib6_drop_pcpu_from(struct fib6_nh *fib6_nh,
+ const struct fib6_info *from,
+ const struct fib6_table *table)
{
- struct fib6_nh *fib6_nh = &f6i->fib6_nh;
int cpu;
if (!rcu_access_pointer(fib6_nh->rt6i_pcpu))
@@ -892,17 +892,27 @@ static void fib6_drop_pcpu_from(struct fib6_info *f6i,
ppcpu_rt = per_cpu_ptr(fib6_nh->rt6i_pcpu, cpu);
pcpu_rt = *ppcpu_rt;
- if (pcpu_rt) {
- struct fib6_info *from;
+ if (pcpu_rt &&
+ (!from || rcu_access_pointer(pcpu_rt->from) == from)) {
+ struct fib6_info *pfrom;
- from = rcu_dereference_protected(pcpu_rt->from,
+ pfrom = rcu_dereference_protected(pcpu_rt->from,
lockdep_is_held(&table->tb6_lock));
rcu_assign_pointer(pcpu_rt->from, NULL);
- fib6_info_release(from);
+ fib6_info_release(pfrom);
}
}
}
+static void fib6_drop_pcpu_from(struct fib6_info *f6i,
+ const struct fib6_table *table)
+{
+ struct fib6_nh *fib6_nh;
+
+ fib6_nh = &f6i->fib6_nh;
+ __fib6_drop_pcpu_from(fib6_nh, f6i, table);
+}
+
static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
struct net *net)
{
@@ -930,8 +940,7 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
lockdep_is_held(&table->tb6_lock));
}
- if (rt->fib6_nh.rt6i_pcpu)
- fib6_drop_pcpu_from(rt, table);
+ fib6_drop_pcpu_from(rt, table);
}
}
--
2.11.0
next prev parent reply other threads:[~2019-04-27 1:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-27 1:56 [PATCH net-next 0/7] ipv4 ipv6: Move location of pcpu route cache and exceptions David Ahern
2019-04-27 1:56 ` [PATCH net-next 1/7] ipv4: Move cached routes to fib_nh_common David Ahern
2019-04-27 1:56 ` [PATCH net-next 2/7] ipv4: Pass fib_nh_common to rt_cache_route David Ahern
2019-04-27 7:32 ` kbuild test robot
2019-04-27 1:56 ` [PATCH net-next 3/7] ipv4: Move exception bucket to nh_common David Ahern
2019-04-27 1:56 ` [PATCH net-next 4/7] ipv6: Move pcpu cached routes to fib6_nh David Ahern
2019-04-27 1:56 ` David Ahern [this message]
2019-04-27 1:56 ` [PATCH net-next 6/7] ipv6: Refactor exception functions David Ahern
2019-04-27 1:56 ` [PATCH net-next 7/7] ipv6: Move exception bucket to fib6_nh David Ahern
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=20190427015657.24655-6-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=idosch@mellanox.com \
--cc=netdev@vger.kernel.org \
/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).