diff mbox series

[net-next,v2] neigh: introduce neigh_confirm() helper function

Message ID 20211123025430.22254-1-yajun.deng@linux.dev (mailing list archive)
State Accepted
Commit 1e84dc6b7bbfc4d1dd846decece4611b7e035772
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] neigh: introduce neigh_confirm() helper function | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3088 this patch: 3088
netdev/cc_maintainers success CCed 3 of 3 maintainers
netdev/build_clang success Errors and warnings before: 425 this patch: 425
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3221 this patch: 3221
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 73 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yajun Deng Nov. 23, 2021, 2:54 a.m. UTC
Add neigh_confirm() for the confirmed member in struct neighbour,
it can be called as an independent unit by other functions.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 include/net/arp.h       |  8 +-------
 include/net/ndisc.h     | 16 ++--------------
 include/net/neighbour.h | 11 +++++++++++
 include/net/sock.h      |  5 +----
 4 files changed, 15 insertions(+), 25 deletions(-)

Comments

Eric Dumazet Nov. 23, 2021, 3:46 a.m. UTC | #1
On 11/22/21 6:54 PM, Yajun Deng wrote:
> Add neigh_confirm() for the confirmed member in struct neighbour,
> it can be called as an independent unit by other functions.
> 
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
>

This seems good to me, thanks.

Reviewed-by: Eric Dumazet <edumazet@google.com>
patchwork-bot+netdevbpf@kernel.org Nov. 23, 2021, 12:20 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Tue, 23 Nov 2021 10:54:30 +0800 you wrote:
> Add neigh_confirm() for the confirmed member in struct neighbour,
> it can be called as an independent unit by other functions.
> 
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
>  include/net/arp.h       |  8 +-------
>  include/net/ndisc.h     | 16 ++--------------
>  include/net/neighbour.h | 11 +++++++++++
>  include/net/sock.h      |  5 +----
>  4 files changed, 15 insertions(+), 25 deletions(-)

Here is the summary with links:
  - [net-next,v2] neigh: introduce neigh_confirm() helper function
    https://git.kernel.org/netdev/net-next/c/1e84dc6b7bbf

You are awesome, thank you!
diff mbox series

Patch

diff --git a/include/net/arp.h b/include/net/arp.h
index 4950191f6b2b..031374ac2f22 100644
--- a/include/net/arp.h
+++ b/include/net/arp.h
@@ -53,13 +53,7 @@  static inline void __ipv4_confirm_neigh(struct net_device *dev, u32 key)
 
 	rcu_read_lock_bh();
 	n = __ipv4_neigh_lookup_noref(dev, key);
-	if (n) {
-		unsigned long now = jiffies;
-
-		/* avoid dirtying neighbour */
-		if (READ_ONCE(n->confirmed) != now)
-			WRITE_ONCE(n->confirmed, now);
-	}
+	neigh_confirm(n);
 	rcu_read_unlock_bh();
 }
 
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 04341d86585d..53cb8de0e589 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -411,13 +411,7 @@  static inline void __ipv6_confirm_neigh(struct net_device *dev,
 
 	rcu_read_lock_bh();
 	n = __ipv6_neigh_lookup_noref(dev, pkey);
-	if (n) {
-		unsigned long now = jiffies;
-
-		/* avoid dirtying neighbour */
-		if (READ_ONCE(n->confirmed) != now)
-			WRITE_ONCE(n->confirmed, now);
-	}
+	neigh_confirm(n);
 	rcu_read_unlock_bh();
 }
 
@@ -428,13 +422,7 @@  static inline void __ipv6_confirm_neigh_stub(struct net_device *dev,
 
 	rcu_read_lock_bh();
 	n = __ipv6_neigh_lookup_noref_stub(dev, pkey);
-	if (n) {
-		unsigned long now = jiffies;
-
-		/* avoid dirtying neighbour */
-		if (READ_ONCE(n->confirmed) != now)
-			WRITE_ONCE(n->confirmed, now);
-	}
+	neigh_confirm(n);
 	rcu_read_unlock_bh();
 }
 
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 38a0c1d24570..55af812c3ed5 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -321,6 +321,17 @@  static inline struct neighbour *__neigh_lookup_noref(struct neigh_table *tbl,
 	return ___neigh_lookup_noref(tbl, tbl->key_eq, tbl->hash, pkey, dev);
 }
 
+static inline void neigh_confirm(struct neighbour *n)
+{
+	if (n) {
+		unsigned long now = jiffies;
+
+		/* avoid dirtying neighbour */
+		if (READ_ONCE(n->confirmed) != now)
+			WRITE_ONCE(n->confirmed, now);
+	}
+}
+
 void neigh_table_init(int index, struct neigh_table *tbl);
 int neigh_table_clear(int index, struct neigh_table *tbl);
 struct neighbour *neigh_lookup(struct neigh_table *tbl, const void *pkey,
diff --git a/include/net/sock.h b/include/net/sock.h
index a79fc772324e..e7c231373875 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2135,13 +2135,10 @@  static inline void sock_confirm_neigh(struct sk_buff *skb, struct neighbour *n)
 {
 	if (skb_get_dst_pending_confirm(skb)) {
 		struct sock *sk = skb->sk;
-		unsigned long now = jiffies;
 
-		/* avoid dirtying neighbour */
-		if (READ_ONCE(n->confirmed) != now)
-			WRITE_ONCE(n->confirmed, now);
 		if (sk && READ_ONCE(sk->sk_dst_pending_confirm))
 			WRITE_ONCE(sk->sk_dst_pending_confirm, 0);
+		neigh_confirm(n);
 	}
 }