Skip to content

Commit b03b6dd

Browse files
Vitalii Demianetsdavem330
authored andcommitted
bridge: master device stuck in no-carrier state forever when in user-stp mode
When in user-stp mode, bridge master do not follow state of its slaves, so after the following sequence of events it can stuck forever in no-carrier state: 1) turn stp off 2) put all slaves down - master device will follow their state and also go in no-carrier state 3) turn stp on with bridge-stp script returning 0 (go to the user-stp mode) Now bridge master won't follow slaves' state and will never reach running state. This patch solves the problem by making user-stp and kernel-stp behavior similar regarding master following slaves' states. Signed-off-by: Vitalii Demianets <vitas@nppfactor.kiev.ua> Acked-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent efbc368 commit b03b6dd

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

‎net/bridge/br_netlink.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <net/sock.h>
1919

2020
#include "br_private.h"
21+
#include "br_private_stp.h"
2122

2223
static inline size_t br_nlmsg_size(void)
2324
{
@@ -188,6 +189,11 @@ static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
188189

189190
p->state = new_state;
190191
br_log_state(p);
192+
193+
spin_lock_bh(&p->br->lock);
194+
br_port_state_selection(p->br);
195+
spin_unlock_bh(&p->br->lock);
196+
191197
br_ifinfo_notify(RTM_NEWLINK, p);
192198

193199
return 0;

‎net/bridge/br_stp.c‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -399,25 +399,24 @@ void br_port_state_selection(struct net_bridge *br)
399399
struct net_bridge_port *p;
400400
unsigned int liveports = 0;
401401

402-
/* Don't change port states if userspace is handling STP */
403-
if (br->stp_enabled == BR_USER_STP)
404-
return;
405-
406402
list_for_each_entry(p, &br->port_list, list) {
407403
if (p->state == BR_STATE_DISABLED)
408404
continue;
409405

410-
if (p->port_no == br->root_port) {
411-
p->config_pending = 0;
412-
p->topology_change_ack = 0;
413-
br_make_forwarding(p);
414-
} else if (br_is_designated_port(p)) {
415-
del_timer(&p->message_age_timer);
416-
br_make_forwarding(p);
417-
} else {
418-
p->config_pending = 0;
419-
p->topology_change_ack = 0;
420-
br_make_blocking(p);
406+
/* Don't change port states if userspace is handling STP */
407+
if (br->stp_enabled != BR_USER_STP) {
408+
if (p->port_no == br->root_port) {
409+
p->config_pending = 0;
410+
p->topology_change_ack = 0;
411+
br_make_forwarding(p);
412+
} else if (br_is_designated_port(p)) {
413+
del_timer(&p->message_age_timer);
414+
br_make_forwarding(p);
415+
} else {
416+
p->config_pending = 0;
417+
p->topology_change_ack = 0;
418+
br_make_blocking(p);
419+
}
421420
}
422421

423422
if (p->state == BR_STATE_FORWARDING)

0 commit comments

Comments
 (0)