.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Spanning tree protocol; interface code |
---|
3 | 4 | * Linux ethernet bridge |
---|
4 | 5 | * |
---|
5 | 6 | * Authors: |
---|
6 | 7 | * 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. |
---|
12 | 8 | */ |
---|
13 | 9 | |
---|
14 | 10 | #include <linux/kernel.h> |
---|
.. | .. |
---|
117 | 113 | del_timer(&p->forward_delay_timer); |
---|
118 | 114 | del_timer(&p->hold_timer); |
---|
119 | 115 | |
---|
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); |
---|
121 | 118 | br_multicast_disable_port(p); |
---|
122 | 119 | |
---|
123 | 120 | br_configuration_update(br); |
---|
.. | .. |
---|
199 | 196 | br->stp_enabled = BR_NO_STP; |
---|
200 | 197 | } |
---|
201 | 198 | |
---|
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) |
---|
203 | 201 | { |
---|
204 | 202 | 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 | + } |
---|
205 | 212 | |
---|
206 | 213 | if (val) { |
---|
207 | 214 | if (br->stp_enabled == BR_NO_STP) |
---|
.. | .. |
---|
210 | 217 | if (br->stp_enabled != BR_NO_STP) |
---|
211 | 218 | br_stp_stop(br); |
---|
212 | 219 | } |
---|
| 220 | + |
---|
| 221 | + return 0; |
---|
213 | 222 | } |
---|
214 | 223 | |
---|
215 | 224 | /* called under bridge lock */ |
---|