Subject: Re: [PATCH net-next v5 4/6] Convert neighbour iteration to use hlist+macro

From: Simon Horman <[email-masked]>
Date: Fri, 18 Oct 2024 12:42:00 +0100

On Thu, Oct 17, 2024 at 07:04:39AM +0000, Gilad Naaman wrote:
> Remove all usage of the bare neighbour::next pointer,
> replacing them with neighbour::hash and its for_each macro.
> 
> Signed-off-by: Gilad Naaman <[email-masked]>

...

> diff --git a/net/core/neighbour.c b/net/core/neighbour.c

...

> @@ -621,11 +620,9 @@ static struct neigh_hash_table *neigh_hash_grow(struct neigh_table *tbl,
>  
>  	for (i = 0; i < (1 << old_nht->hash_shift); i++) {
>  		struct neighbour *n, *next;
> +		struct hlist_node *tmp;
>  
> -		for (n = rcu_dereference_protected(old_nht->hash_buckets[i],
> -						   lockdep_is_held(&tbl->lock));
> -		     n != NULL;
> -		     n = next) {
> +		neigh_for_each_safe(n, tmp, &old_nht->hash_heads[i]) {
>  			hash = tbl->hash(n->primary_key, n->dev,
>  					 new_nht->hash_rnd);
>  

Hi Gilad,

With this change next is now set but otherwise unused in this function.
Probably it can be removed.

Flagged by W=1 x86_64 allmodconfig builds with gcc-14 and clang-18.

...