Skip to contentSkip to conversation

neigh: Keep neighbour cache entries if number of them is small enough.

PATCH In review YOSHIFUJI Hideaki 1 participant 2 messages Jan 22, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 neigh: Keep neighbour cache entries if number of them is small enough.

Since we have removed NCE (Neighbour Cache Entry) reference from routing entries, the only refcnt holders of an NCE are timer (if run) and the entry's owner table. As a result, neigh_periodic_timer() purges NCEs over and over even for gateways.

It does not make sense to purge NCEs even if number of them is very small.

The number of entries can be specified by gc_thresh1.

---
 Documentation/networking/ip-sysctl.txt |    5 +++++
 net/core/neighbour.c                   |    4 ++++
 2 files changed, 9 insertions(+)
Documentation/networking/ip-sysctl.txt +5 -0
index 4976564..19ac180 100644
@@ -26,6 +26,11 @@ route/max_size - INTEGER
 	Maximum number of routes allowed in the kernel.  Increase
 	this when using large numbers of interfaces and/or routes.
 
+neigh/default/gc_thresh1 - INTEGER
+	Minimum number of entries to keep.  Garbage collector will not
+	purge entries if there are fewer than this number.
+	Default: 256
+
 neigh/default/gc_thresh3 - INTEGER
 	Maximum number of neighbor entries allowed.  Increase this
 	when using large numbers of interfaces and when communicating
net/core/neighbour.c +4 -0
index c815f28..7bd0eed 100644
@@ -778,6 +778,9 @@ static void neigh_periodic_work(struct work_struct *work)
 	nht = rcu_dereference_protected(tbl->nht,
 					lockdep_is_held(&tbl->lock));
 
+	if (atomic_read(&tbl->entries) < tbl->gc_thresh1)
+		goto out;
+
 	/*
 	 *	periodically recompute ReachableTime from random function
 	 */
@@ -832,6 +835,7 @@ next_elt:
 		nht = rcu_dereference_protected(tbl->nht,
 						lockdep_is_held(&tbl->lock));
 	}
+out:
 	/* Cycle through all hash buckets every base_reachable_time/2 ticks.
 	 * ARP entry timeouts range from 1/2 base_reachable_time to 3/2
 	 * base_reachable_time.
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 3 lines · YOSHIFUJI Hideaki

Since we have removed NCE (Neighbour Cache Entry) reference from routing entries, the only refcnt holders of an NCE are timer (if run) and the entry's owner table. As a result, neigh_periodic_timer()

Oops, I should say neigh_periodic_work()...

--yoshfuji