Commit 590e92cd authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

inet: prepare inet_base_seq() to run without RTNL

In the following patch, inet_base_seq() will no longer be called
with RTNL held.

Add READ_ONCE()/WRITE_ONCE() annotations in dev_base_seq_inc()
and inet_base_seq().
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3ddc2231
...@@ -180,8 +180,9 @@ static DECLARE_RWSEM(devnet_rename_sem); ...@@ -180,8 +180,9 @@ static DECLARE_RWSEM(devnet_rename_sem);
static inline void dev_base_seq_inc(struct net *net) static inline void dev_base_seq_inc(struct net *net)
{ {
while (++net->dev_base_seq == 0) unsigned int val = net->dev_base_seq + 1;
;
WRITE_ONCE(net->dev_base_seq, val ?: 1);
} }
static inline struct hlist_head *dev_name_hash(struct net *net, const char *name) static inline struct hlist_head *dev_name_hash(struct net *net, const char *name)
......
...@@ -1837,7 +1837,7 @@ static int in_dev_dump_addr(struct in_device *in_dev, struct sk_buff *skb, ...@@ -1837,7 +1837,7 @@ static int in_dev_dump_addr(struct in_device *in_dev, struct sk_buff *skb,
static u32 inet_base_seq(const struct net *net) static u32 inet_base_seq(const struct net *net)
{ {
u32 res = atomic_read(&net->ipv4.dev_addr_genid) + u32 res = atomic_read(&net->ipv4.dev_addr_genid) +
net->dev_base_seq; READ_ONCE(net->dev_base_seq);
/* Must not return 0 (see nl_dump_check_consistent()). /* Must not return 0 (see nl_dump_check_consistent()).
* Chose a value far away from 0. * Chose a value far away from 0.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment