neigh_periodic_work() reschedules tbl->gc_work with a delay of
BASE_REACHABLE_TIME >> 1.
neigh_table is now per-netns, and a user could hog CPU by setting
BASE_REACHABLE_TIME to a small value.
Unlike INTERVAL_PROBE_TIME_MS, BASE_REACHABLE_TIME is also used to
compute reachable_time for NUD_REACHABLE entries.
Let's floor only the GC interval at 1 second.
Suggested-by: Ido Schimmel <idosch@nvidia.com>
Link: https://lore.kernel.org/netdev/20260902143023.GA3966681@shredder/ (local)
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
net/core/neighbour.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index aa3da886eaab..d6e9c7c59a89 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1042,12 +1042,12 @@ static void neigh_periodic_work(struct work_struct *work)
lockdep_is_held(&tbl->lock));
}
out:
- /* Cycle through all hash buckets every BASE_REACHABLE_TIME/2 ticks.
+ /* Cycle through all hash buckets every max(HZ, BASE_REACHABLE_TIME/2) ticks.
* ARP entry timeouts range from 1/2 BASE_REACHABLE_TIME to 3/2
* BASE_REACHABLE_TIME.
*/
queue_delayed_work(system_power_efficient_wq, &tbl->gc_work,
- NEIGH_VAR(&tbl->parms, BASE_REACHABLE_TIME) >> 1);
+ max(HZ, NEIGH_VAR(&tbl->parms, BASE_REACHABLE_TIME) >> 1));
spin_unlock_bh(&tbl->lock);
}
--
2.56.0.385.gd3acb90ef8-goog