neigh: introduce neigh_confirm() helper function
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> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
a0c2ccd9b5
commit
1e84dc6b7b
@@ -53,13 +53,7 @@ static inline void __ipv4_confirm_neigh(struct net_device *dev, u32 key)
|
|||||||
|
|
||||||
rcu_read_lock_bh();
|
rcu_read_lock_bh();
|
||||||
n = __ipv4_neigh_lookup_noref(dev, key);
|
n = __ipv4_neigh_lookup_noref(dev, key);
|
||||||
if (n) {
|
neigh_confirm(n);
|
||||||
unsigned long now = jiffies;
|
|
||||||
|
|
||||||
/* avoid dirtying neighbour */
|
|
||||||
if (READ_ONCE(n->confirmed) != now)
|
|
||||||
WRITE_ONCE(n->confirmed, now);
|
|
||||||
}
|
|
||||||
rcu_read_unlock_bh();
|
rcu_read_unlock_bh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -411,13 +411,7 @@ static inline void __ipv6_confirm_neigh(struct net_device *dev,
|
|||||||
|
|
||||||
rcu_read_lock_bh();
|
rcu_read_lock_bh();
|
||||||
n = __ipv6_neigh_lookup_noref(dev, pkey);
|
n = __ipv6_neigh_lookup_noref(dev, pkey);
|
||||||
if (n) {
|
neigh_confirm(n);
|
||||||
unsigned long now = jiffies;
|
|
||||||
|
|
||||||
/* avoid dirtying neighbour */
|
|
||||||
if (READ_ONCE(n->confirmed) != now)
|
|
||||||
WRITE_ONCE(n->confirmed, now);
|
|
||||||
}
|
|
||||||
rcu_read_unlock_bh();
|
rcu_read_unlock_bh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,13 +422,7 @@ static inline void __ipv6_confirm_neigh_stub(struct net_device *dev,
|
|||||||
|
|
||||||
rcu_read_lock_bh();
|
rcu_read_lock_bh();
|
||||||
n = __ipv6_neigh_lookup_noref_stub(dev, pkey);
|
n = __ipv6_neigh_lookup_noref_stub(dev, pkey);
|
||||||
if (n) {
|
neigh_confirm(n);
|
||||||
unsigned long now = jiffies;
|
|
||||||
|
|
||||||
/* avoid dirtying neighbour */
|
|
||||||
if (READ_ONCE(n->confirmed) != now)
|
|
||||||
WRITE_ONCE(n->confirmed, now);
|
|
||||||
}
|
|
||||||
rcu_read_unlock_bh();
|
rcu_read_unlock_bh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
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);
|
void neigh_table_init(int index, struct neigh_table *tbl);
|
||||||
int neigh_table_clear(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,
|
struct neighbour *neigh_lookup(struct neigh_table *tbl, const void *pkey,
|
||||||
|
|||||||
@@ -2135,13 +2135,10 @@ static inline void sock_confirm_neigh(struct sk_buff *skb, struct neighbour *n)
|
|||||||
{
|
{
|
||||||
if (skb_get_dst_pending_confirm(skb)) {
|
if (skb_get_dst_pending_confirm(skb)) {
|
||||||
struct sock *sk = skb->sk;
|
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))
|
if (sk && READ_ONCE(sk->sk_dst_pending_confirm))
|
||||||
WRITE_ONCE(sk->sk_dst_pending_confirm, 0);
|
WRITE_ONCE(sk->sk_dst_pending_confirm, 0);
|
||||||
|
neigh_confirm(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user