Commit 775dd692 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

net: bridge: add a br_set_state helper function

In preparation for being able to propagate port states to e.g: notifiers
or other kernel parts, do not manipulate the port state directly, but
instead use a helper function which will allow us to do a bit more than
just setting the state.
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a0efb80c
...@@ -332,7 +332,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br, ...@@ -332,7 +332,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
p->port_no = index; p->port_no = index;
p->flags = BR_LEARNING | BR_FLOOD; p->flags = BR_LEARNING | BR_FLOOD;
br_init_port(p); br_init_port(p);
p->state = BR_STATE_DISABLED; br_set_state(p, BR_STATE_DISABLED);
br_stp_port_timer_init(p); br_stp_port_timer_init(p);
br_multicast_add_port(p); br_multicast_add_port(p);
......
...@@ -301,7 +301,7 @@ static int br_set_port_state(struct net_bridge_port *p, u8 state) ...@@ -301,7 +301,7 @@ static int br_set_port_state(struct net_bridge_port *p, u8 state)
(!netif_oper_up(p->dev) && state != BR_STATE_DISABLED)) (!netif_oper_up(p->dev) && state != BR_STATE_DISABLED))
return -ENETDOWN; return -ENETDOWN;
p->state = state; br_set_state(p, state);
br_log_state(p); br_log_state(p);
br_port_state_selection(p->br); br_port_state_selection(p->br);
return 0; return 0;
......
...@@ -766,6 +766,7 @@ static inline void br_nf_core_fini(void) {} ...@@ -766,6 +766,7 @@ static inline void br_nf_core_fini(void) {}
/* br_stp.c */ /* br_stp.c */
void br_log_state(const struct net_bridge_port *p); void br_log_state(const struct net_bridge_port *p);
void br_set_state(struct net_bridge_port *p, unsigned int state);
struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no); struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no);
void br_init_port(struct net_bridge_port *p); void br_init_port(struct net_bridge_port *p);
void br_become_designated_port(struct net_bridge_port *p); void br_become_designated_port(struct net_bridge_port *p);
......
...@@ -36,6 +36,11 @@ void br_log_state(const struct net_bridge_port *p) ...@@ -36,6 +36,11 @@ void br_log_state(const struct net_bridge_port *p)
br_port_state_names[p->state]); br_port_state_names[p->state]);
} }
void br_set_state(struct net_bridge_port *p, unsigned int state)
{
p->state = state;
}
/* called under bridge lock */ /* called under bridge lock */
struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no) struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no)
{ {
...@@ -107,7 +112,7 @@ static void br_root_port_block(const struct net_bridge *br, ...@@ -107,7 +112,7 @@ static void br_root_port_block(const struct net_bridge *br,
br_notice(br, "port %u(%s) tried to become root port (blocked)", br_notice(br, "port %u(%s) tried to become root port (blocked)",
(unsigned int) p->port_no, p->dev->name); (unsigned int) p->port_no, p->dev->name);
p->state = BR_STATE_LISTENING; br_set_state(p, BR_STATE_LISTENING);
br_log_state(p); br_log_state(p);
br_ifinfo_notify(RTM_NEWLINK, p); br_ifinfo_notify(RTM_NEWLINK, p);
...@@ -387,7 +392,7 @@ static void br_make_blocking(struct net_bridge_port *p) ...@@ -387,7 +392,7 @@ static void br_make_blocking(struct net_bridge_port *p)
p->state == BR_STATE_LEARNING) p->state == BR_STATE_LEARNING)
br_topology_change_detection(p->br); br_topology_change_detection(p->br);
p->state = BR_STATE_BLOCKING; br_set_state(p, BR_STATE_BLOCKING);
br_log_state(p); br_log_state(p);
br_ifinfo_notify(RTM_NEWLINK, p); br_ifinfo_notify(RTM_NEWLINK, p);
...@@ -404,13 +409,13 @@ static void br_make_forwarding(struct net_bridge_port *p) ...@@ -404,13 +409,13 @@ static void br_make_forwarding(struct net_bridge_port *p)
return; return;
if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) { if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) {
p->state = BR_STATE_FORWARDING; br_set_state(p, BR_STATE_FORWARDING);
br_topology_change_detection(br); br_topology_change_detection(br);
del_timer(&p->forward_delay_timer); del_timer(&p->forward_delay_timer);
} else if (br->stp_enabled == BR_KERNEL_STP) } else if (br->stp_enabled == BR_KERNEL_STP)
p->state = BR_STATE_LISTENING; br_set_state(p, BR_STATE_LISTENING);
else else
p->state = BR_STATE_LEARNING; br_set_state(p, BR_STATE_LEARNING);
br_multicast_enable_port(p); br_multicast_enable_port(p);
br_log_state(p); br_log_state(p);
......
...@@ -37,7 +37,7 @@ void br_init_port(struct net_bridge_port *p) ...@@ -37,7 +37,7 @@ void br_init_port(struct net_bridge_port *p)
{ {
p->port_id = br_make_port_id(p->priority, p->port_no); p->port_id = br_make_port_id(p->priority, p->port_no);
br_become_designated_port(p); br_become_designated_port(p);
p->state = BR_STATE_BLOCKING; br_set_state(p, BR_STATE_BLOCKING);
p->topology_change_ack = 0; p->topology_change_ack = 0;
p->config_pending = 0; p->config_pending = 0;
} }
...@@ -100,7 +100,7 @@ void br_stp_disable_port(struct net_bridge_port *p) ...@@ -100,7 +100,7 @@ void br_stp_disable_port(struct net_bridge_port *p)
wasroot = br_is_root_bridge(br); wasroot = br_is_root_bridge(br);
br_become_designated_port(p); br_become_designated_port(p);
p->state = BR_STATE_DISABLED; br_set_state(p, BR_STATE_DISABLED);
p->topology_change_ack = 0; p->topology_change_ack = 0;
p->config_pending = 0; p->config_pending = 0;
......
...@@ -87,11 +87,11 @@ static void br_forward_delay_timer_expired(unsigned long arg) ...@@ -87,11 +87,11 @@ static void br_forward_delay_timer_expired(unsigned long arg)
(unsigned int) p->port_no, p->dev->name); (unsigned int) p->port_no, p->dev->name);
spin_lock(&br->lock); spin_lock(&br->lock);
if (p->state == BR_STATE_LISTENING) { if (p->state == BR_STATE_LISTENING) {
p->state = BR_STATE_LEARNING; br_set_state(p, BR_STATE_LEARNING);
mod_timer(&p->forward_delay_timer, mod_timer(&p->forward_delay_timer,
jiffies + br->forward_delay); jiffies + br->forward_delay);
} else if (p->state == BR_STATE_LEARNING) { } else if (p->state == BR_STATE_LEARNING) {
p->state = BR_STATE_FORWARDING; br_set_state(p, BR_STATE_FORWARDING);
if (br_is_designated_for_some_port(br)) if (br_is_designated_for_some_port(br))
br_topology_change_detection(br); br_topology_change_detection(br);
netif_carrier_on(br->dev); netif_carrier_on(br->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment