forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
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,16 @@
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 (br_mrp_enabled(br)) {
205
+ NL_SET_ERR_MSG_MOD(extack,
206
+ "STP can't be enabled if MRP is already enabled");
207
+ return -EINVAL;
208
+ }
205209
206210 if (val) {
207211 if (br->stp_enabled == BR_NO_STP)
....@@ -210,6 +214,8 @@
210214 if (br->stp_enabled != BR_NO_STP)
211215 br_stp_stop(br);
212216 }
217
+
218
+ return 0;
213219 }
214220
215221 /* called under bridge lock */