net: avoid potential false sharing in neighbor related code
There are common instances of the following construct : if (n->confirmed != now) n->confirmed = now; A C compiler could legally remove the conditional. Use READ_ONCE()/WRITE_ONCE() to avoid this problem. Signed-off-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
3828a93f5c
commit
25c7a6d1f9
@@ -57,8 +57,8 @@ static inline void __ipv4_confirm_neigh(struct net_device *dev, u32 key)
|
||||
unsigned long now = jiffies;
|
||||
|
||||
/* avoid dirtying neighbour */
|
||||
if (n->confirmed != now)
|
||||
n->confirmed = now;
|
||||
if (READ_ONCE(n->confirmed) != now)
|
||||
WRITE_ONCE(n->confirmed, now);
|
||||
}
|
||||
rcu_read_unlock_bh();
|
||||
}
|
||||
|
Reference in New Issue
Block a user