Skip to content

Commit 590e92c

Browse files
edumazetdavem330
authored andcommitted
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: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3ddc223 commit 590e92c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

net/core/dev.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ static DECLARE_RWSEM(devnet_rename_sem);
180180

181181
static inline void dev_base_seq_inc(struct net *net)
182182
{
183-
while (++net->dev_base_seq == 0)
184-
;
183+
unsigned int val = net->dev_base_seq + 1;
184+
185+
WRITE_ONCE(net->dev_base_seq, val ?: 1);
185186
}
186187

187188
static inline struct hlist_head *dev_name_hash(struct net *net, const char *name)

net/ipv4/devinet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ static int in_dev_dump_addr(struct in_device *in_dev, struct sk_buff *skb,
18371837
static u32 inet_base_seq(const struct net *net)
18381838
{
18391839
u32 res = atomic_read(&net->ipv4.dev_addr_genid) +
1840-
net->dev_base_seq;
1840+
READ_ONCE(net->dev_base_seq);
18411841

18421842
/* Must not return 0 (see nl_dump_check_consistent()).
18431843
* Chose a value far away from 0.

0 commit comments

Comments
 (0)