Skip to content

Commit 56a1603

Browse files
q2vendavem330
authored andcommitted
bridge: Add extack warning when enabling STP in netns.
When we create an L2 loop on a bridge in netns, we will see packets storm even if STP is enabled. # unshare -n # ip link add br0 type bridge # ip link add veth0 type veth peer name veth1 # ip link set veth0 master br0 up # ip link set veth1 master br0 up # ip link set br0 type bridge stp_state 1 # ip link set br0 up # sleep 30 # ip -s link show br0 2: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000 link/ether b6:61:98:1c:1c:b5 brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped missed mcast 956553768 12861249 0 0 0 12861249 <-. Keep TX: bytes packets errors dropped carrier collsns | increasing 1027834 11951 0 0 0 0 <-' rapidly This is because llc_rcv() drops all packets in non-root netns and BPDU is dropped. Let's add extack warning when enabling STP in netns. # unshare -n # ip link add br0 type bridge # ip link set br0 type bridge stp_state 1 Warning: bridge: STP does not work in non-root netns. Note this commit will be reverted later when we namespacify the whole LLC infra. Fixes: e730c15 ("[NET]: Make packet reception network namespace safe") Suggested-by: Harry Coin <[email protected]> Link: https://lore.kernel.org/netdev/[email protected]/ Suggested-by: Ido Schimmel <[email protected]> Signed-off-by: Kuniyuki Iwashima <[email protected]> Acked-by: Nikolay Aleksandrov <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b685f1a commit 56a1603

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/bridge/br_stp_if.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ int br_stp_set_enabled(struct net_bridge *br, unsigned long val,
201201
{
202202
ASSERT_RTNL();
203203

204+
if (!net_eq(dev_net(br->dev), &init_net))
205+
NL_SET_ERR_MSG_MOD(extack, "STP does not work in non-root netns");
206+
204207
if (br_mrp_enabled(br)) {
205208
NL_SET_ERR_MSG_MOD(extack,
206209
"STP can't be enabled if MRP is already enabled");

0 commit comments

Comments
 (0)