]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
neighbour: Define neigh_for_each_in_bucket
authorGilad Naaman <gnaaman@drivenets.com>
Thu, 7 Nov 2024 16:04:39 +0000 (16:04 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sat, 9 Nov 2024 21:22:56 +0000 (13:22 -0800)
Introduce neigh_for_each_in_bucket in neighbour.h, to help iterate over
the neighbour table more succinctly.

Signed-off-by: Gilad Naaman <gnaaman@drivenets.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20241107160444.2913124-3-gnaaman@drivenets.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/neighbour.h

index 0402447854c74dae5613f6d7dbf96c5b77af7fdb..4b9068c5e668174891792338c1e6bd8c88a24e12 100644 (file)
@@ -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;