hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/net/bridge/br_stp_if.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Spanning tree protocol; interface code
34 * Linux ethernet bridge
45 *
56 * Authors:
67 * Lennert Buytenhek <buytenh@gnu.org>
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License
10
- * as published by the Free Software Foundation; either version
11
- * 2 of the License, or (at your option) any later version.
128 */
139
1410 #include <linux/kernel.h>
....@@ -117,7 +113,8 @@
117113 del_timer(&p->forward_delay_timer);
118114 del_timer(&p->hold_timer);
119115
120
- br_fdb_delete_by_port(br, p, 0, 0);
116
+ if (!rcu_access_pointer(p->backup_port))
117
+ br_fdb_delete_by_port(br, p, 0, 0);
121118 br_multicast_disable_port(p);
122119
123120 br_configuration_update(br);
....@@ -199,9 +196,19 @@
199196 br->stp_enabled = BR_NO_STP;
200197 }
201198
202
-void br_stp_set_enabled(struct net_bridge *br, unsigned long val)
199
+int br_stp_set_enabled(struct net_bridge *br, unsigned long val,
200
+ struct netlink_ext_ack *extack)
203201 {
204202 ASSERT_RTNL();
203
+
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
+
207
+ if (br_mrp_enabled(br)) {
208
+ NL_SET_ERR_MSG_MOD(extack,
209
+ "STP can't be enabled if MRP is already enabled");
210
+ return -EINVAL;
211
+ }
205212
206213 if (val) {
207214 if (br->stp_enabled == BR_NO_STP)
....@@ -210,6 +217,8 @@
210217 if (br->stp_enabled != BR_NO_STP)
211218 br_stp_stop(br);
212219 }
220
+
221
+ return 0;
213222 }
214223
215224 /* called under bridge lock */