diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2014-09-30 19:13:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-01 22:03:50 -0400 |
commit | 775dd692bd34f9201ed2aa775a0edcba4f973f3e (patch) | |
tree | 65c977fb1c697077c0fa4e2506e1847d3899133b /net/bridge/br_stp.c | |
parent | a0efb80ce3abacfd22a4284c3730924fc2f1f077 (diff) |
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: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_stp.c')
-rw-r--r-- | net/bridge/br_stp.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c index 3c86f0538cbb..2b047bcf42a4 100644 --- a/net/bridge/br_stp.c +++ b/net/bridge/br_stp.c | |||
@@ -36,6 +36,11 @@ void br_log_state(const struct net_bridge_port *p) | |||
36 | br_port_state_names[p->state]); | 36 | br_port_state_names[p->state]); |
37 | } | 37 | } |
38 | 38 | ||
39 | void br_set_state(struct net_bridge_port *p, unsigned int state) | ||
40 | { | ||
41 | p->state = state; | ||
42 | } | ||
43 | |||
39 | /* called under bridge lock */ | 44 | /* called under bridge lock */ |
40 | struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no) | 45 | struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no) |
41 | { | 46 | { |
@@ -107,7 +112,7 @@ static void br_root_port_block(const struct net_bridge *br, | |||
107 | br_notice(br, "port %u(%s) tried to become root port (blocked)", | 112 | br_notice(br, "port %u(%s) tried to become root port (blocked)", |
108 | (unsigned int) p->port_no, p->dev->name); | 113 | (unsigned int) p->port_no, p->dev->name); |
109 | 114 | ||
110 | p->state = BR_STATE_LISTENING; | 115 | br_set_state(p, BR_STATE_LISTENING); |
111 | br_log_state(p); | 116 | br_log_state(p); |
112 | br_ifinfo_notify(RTM_NEWLINK, p); | 117 | br_ifinfo_notify(RTM_NEWLINK, p); |
113 | 118 | ||
@@ -387,7 +392,7 @@ static void br_make_blocking(struct net_bridge_port *p) | |||
387 | p->state == BR_STATE_LEARNING) | 392 | p->state == BR_STATE_LEARNING) |
388 | br_topology_change_detection(p->br); | 393 | br_topology_change_detection(p->br); |
389 | 394 | ||
390 | p->state = BR_STATE_BLOCKING; | 395 | br_set_state(p, BR_STATE_BLOCKING); |
391 | br_log_state(p); | 396 | br_log_state(p); |
392 | br_ifinfo_notify(RTM_NEWLINK, p); | 397 | br_ifinfo_notify(RTM_NEWLINK, p); |
393 | 398 | ||
@@ -404,13 +409,13 @@ static void br_make_forwarding(struct net_bridge_port *p) | |||
404 | return; | 409 | return; |
405 | 410 | ||
406 | if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) { | 411 | if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) { |
407 | p->state = BR_STATE_FORWARDING; | 412 | br_set_state(p, BR_STATE_FORWARDING); |
408 | br_topology_change_detection(br); | 413 | br_topology_change_detection(br); |
409 | del_timer(&p->forward_delay_timer); | 414 | del_timer(&p->forward_delay_timer); |
410 | } else if (br->stp_enabled == BR_KERNEL_STP) | 415 | } else if (br->stp_enabled == BR_KERNEL_STP) |
411 | p->state = BR_STATE_LISTENING; | 416 | br_set_state(p, BR_STATE_LISTENING); |
412 | else | 417 | else |
413 | p->state = BR_STATE_LEARNING; | 418 | br_set_state(p, BR_STATE_LEARNING); |
414 | 419 | ||
415 | br_multicast_enable_port(p); | 420 | br_multicast_enable_port(p); |
416 | br_log_state(p); | 421 | br_log_state(p); |