Commit d7ddee1a authored by Gilad Naaman's avatar Gilad Naaman Committed by Jakub Kicinski
Browse files

neighbour: Define neigh_for_each_in_bucket



Introduce neigh_for_each_in_bucket in neighbour.h, to help iterate over
the neighbour table more succinctly.

Signed-off-by: default avatarGilad Naaman <gnaaman@drivenets.com>
Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20241107160444.2913124-3-gnaaman@drivenets.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 41b3caa7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -277,6 +277,12 @@ static inline void *neighbour_priv(const struct neighbour *n)

extern const struct nla_policy nda_policy[];

#define neigh_for_each_in_bucket(pos, head) hlist_for_each_entry(pos, head, hash)
#define neigh_for_each_in_bucket_rcu(pos, head) \
	hlist_for_each_entry_rcu(pos, head, hash)
#define neigh_for_each_in_bucket_safe(pos, tmp, head) \
	hlist_for_each_entry_safe(pos, tmp, head, hash)

static inline bool neigh_key_eq32(const struct neighbour *n, const void *pkey)
{
	return *(const u32 *)n->primary_key == *(const u32 *)pkey;