Skip to content

Commit 8d7e5de

Browse files
Guillaume Naultdavem330
authored andcommitted
netns: don't disable BHs when locking "nsid_lock"
When peernet2id() had to lock "nsid_lock" before iterating through the nsid table, we had to disable BHs, because VXLAN can call peernet2id() from the xmit path: vxlan_xmit() -> vxlan_fdb_miss() -> vxlan_fdb_notify() -> __vxlan_fdb_notify() -> vxlan_fdb_info() -> peernet2id(). Now that peernet2id() uses RCU protection, "nsid_lock" isn't used in BH context anymore. Therefore, we can safely use plain spin_lock()/spin_unlock() and let BHs run when holding "nsid_lock". Signed-off-by: Guillaume Nault <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2dce224 commit 8d7e5de

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

net/core/net_namespace.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ int peernet2id_alloc(struct net *net, struct net *peer, gfp_t gfp)
237237
if (refcount_read(&net->count) == 0)
238238
return NETNSA_NSID_NOT_ASSIGNED;
239239

240-
spin_lock_bh(&net->nsid_lock);
240+
spin_lock(&net->nsid_lock);
241241
id = __peernet2id(net, peer);
242242
if (id >= 0) {
243-
spin_unlock_bh(&net->nsid_lock);
243+
spin_unlock(&net->nsid_lock);
244244
return id;
245245
}
246246

@@ -250,12 +250,12 @@ int peernet2id_alloc(struct net *net, struct net *peer, gfp_t gfp)
250250
* just been idr_remove()'d from there in cleanup_net().
251251
*/
252252
if (!maybe_get_net(peer)) {
253-
spin_unlock_bh(&net->nsid_lock);
253+
spin_unlock(&net->nsid_lock);
254254
return NETNSA_NSID_NOT_ASSIGNED;
255255
}
256256

257257
id = alloc_netid(net, peer, -1);
258-
spin_unlock_bh(&net->nsid_lock);
258+
spin_unlock(&net->nsid_lock);
259259

260260
put_net(peer);
261261
if (id < 0)
@@ -520,20 +520,20 @@ static void unhash_nsid(struct net *net, struct net *last)
520520
for_each_net(tmp) {
521521
int id;
522522

523-
spin_lock_bh(&tmp->nsid_lock);
523+
spin_lock(&tmp->nsid_lock);
524524
id = __peernet2id(tmp, net);
525525
if (id >= 0)
526526
idr_remove(&tmp->netns_ids, id);
527-
spin_unlock_bh(&tmp->nsid_lock);
527+
spin_unlock(&tmp->nsid_lock);
528528
if (id >= 0)
529529
rtnl_net_notifyid(tmp, RTM_DELNSID, id, 0, NULL,
530530
GFP_KERNEL);
531531
if (tmp == last)
532532
break;
533533
}
534-
spin_lock_bh(&net->nsid_lock);
534+
spin_lock(&net->nsid_lock);
535535
idr_destroy(&net->netns_ids);
536-
spin_unlock_bh(&net->nsid_lock);
536+
spin_unlock(&net->nsid_lock);
537537
}
538538

539539
static LLIST_HEAD(cleanup_list);
@@ -746,9 +746,9 @@ static int rtnl_net_newid(struct sk_buff *skb, struct nlmsghdr *nlh,
746746
return PTR_ERR(peer);
747747
}
748748

749-
spin_lock_bh(&net->nsid_lock);
749+
spin_lock(&net->nsid_lock);
750750
if (__peernet2id(net, peer) >= 0) {
751-
spin_unlock_bh(&net->nsid_lock);
751+
spin_unlock(&net->nsid_lock);
752752
err = -EEXIST;
753753
NL_SET_BAD_ATTR(extack, nla);
754754
NL_SET_ERR_MSG(extack,
@@ -757,7 +757,7 @@ static int rtnl_net_newid(struct sk_buff *skb, struct nlmsghdr *nlh,
757757
}
758758

759759
err = alloc_netid(net, peer, nsid);
760-
spin_unlock_bh(&net->nsid_lock);
760+
spin_unlock(&net->nsid_lock);
761761
if (err >= 0) {
762762
rtnl_net_notifyid(net, RTM_NEWNSID, err, NETLINK_CB(skb).portid,
763763
nlh, GFP_KERNEL);

0 commit comments

Comments
 (0)