Commit f6a6f203 authored by Roopa Prabhu's avatar Roopa Prabhu Committed by David S. Miller

neighbour: skip NTF_EXT_LEARNED entries during forced gc

Commit 9ce33e46 ("neighbour: support for NTF_EXT_LEARNED flag")
added support for NTF_EXT_LEARNED for neighbour entries.
NTF_EXT_LEARNED entries are neigh entries managed by control
plane (eg: Ethernet VPN implementation in FRR routing suite).
Periodic gc already excludes these entries. This patch extends
it to forced gc which the earlier patch missed.

Fixes: 9ce33e46 ("neighbour: support for NTF_EXT_LEARNED flag")
Signed-off-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7c099773
...@@ -119,13 +119,14 @@ unsigned long neigh_rand_reach_time(unsigned long base) ...@@ -119,13 +119,14 @@ unsigned long neigh_rand_reach_time(unsigned long base)
EXPORT_SYMBOL(neigh_rand_reach_time); EXPORT_SYMBOL(neigh_rand_reach_time);
static bool neigh_del(struct neighbour *n, __u8 state, static bool neigh_del(struct neighbour *n, __u8 state, __u8 flags,
struct neighbour __rcu **np, struct neigh_table *tbl) struct neighbour __rcu **np, struct neigh_table *tbl)
{ {
bool retval = false; bool retval = false;
write_lock(&n->lock); write_lock(&n->lock);
if (refcount_read(&n->refcnt) == 1 && !(n->nud_state & state)) { if (refcount_read(&n->refcnt) == 1 && !(n->nud_state & state) &&
!(n->flags & flags)) {
struct neighbour *neigh; struct neighbour *neigh;
neigh = rcu_dereference_protected(n->next, neigh = rcu_dereference_protected(n->next,
...@@ -157,7 +158,7 @@ bool neigh_remove_one(struct neighbour *ndel, struct neigh_table *tbl) ...@@ -157,7 +158,7 @@ bool neigh_remove_one(struct neighbour *ndel, struct neigh_table *tbl)
while ((n = rcu_dereference_protected(*np, while ((n = rcu_dereference_protected(*np,
lockdep_is_held(&tbl->lock)))) { lockdep_is_held(&tbl->lock)))) {
if (n == ndel) if (n == ndel)
return neigh_del(n, 0, np, tbl); return neigh_del(n, 0, 0, np, tbl);
np = &n->next; np = &n->next;
} }
return false; return false;
...@@ -185,7 +186,8 @@ static int neigh_forced_gc(struct neigh_table *tbl) ...@@ -185,7 +186,8 @@ static int neigh_forced_gc(struct neigh_table *tbl)
* - nobody refers to it. * - nobody refers to it.
* - it is not permanent * - it is not permanent
*/ */
if (neigh_del(n, NUD_PERMANENT, np, tbl)) { if (neigh_del(n, NUD_PERMANENT, NTF_EXT_LEARNED, np,
tbl)) {
shrunk = 1; shrunk = 1;
continue; continue;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment