Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Florian Fainelli and committed by
David S. Miller
775dd692 a0efb80c

+17 -11
+1 -1
net/bridge/br_if.c
··· 332 332 p->port_no = index; 333 333 p->flags = BR_LEARNING | BR_FLOOD; 334 334 br_init_port(p); 335 - p->state = BR_STATE_DISABLED; 335 + br_set_state(p, BR_STATE_DISABLED); 336 336 br_stp_port_timer_init(p); 337 337 br_multicast_add_port(p); 338 338
+1 -1
net/bridge/br_netlink.c
··· 301 301 (!netif_oper_up(p->dev) && state != BR_STATE_DISABLED)) 302 302 return -ENETDOWN; 303 303 304 - p->state = state; 304 + br_set_state(p, state); 305 305 br_log_state(p); 306 306 br_port_state_selection(p->br); 307 307 return 0;
+1
net/bridge/br_private.h
··· 766 766 767 767 /* br_stp.c */ 768 768 void br_log_state(const struct net_bridge_port *p); 769 + void br_set_state(struct net_bridge_port *p, unsigned int state); 769 770 struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no); 770 771 void br_init_port(struct net_bridge_port *p); 771 772 void br_become_designated_port(struct net_bridge_port *p);
+10 -5
net/bridge/br_stp.c
··· 36 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 44 /* called under bridge lock */ 40 45 struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no) 41 46 { ··· 112 107 br_notice(br, "port %u(%s) tried to become root port (blocked)", 113 108 (unsigned int) p->port_no, p->dev->name); 114 109 115 - p->state = BR_STATE_LISTENING; 110 + br_set_state(p, BR_STATE_LISTENING); 116 111 br_log_state(p); 117 112 br_ifinfo_notify(RTM_NEWLINK, p); 118 113 ··· 392 387 p->state == BR_STATE_LEARNING) 393 388 br_topology_change_detection(p->br); 394 389 395 - p->state = BR_STATE_BLOCKING; 390 + br_set_state(p, BR_STATE_BLOCKING); 396 391 br_log_state(p); 397 392 br_ifinfo_notify(RTM_NEWLINK, p); 398 393 ··· 409 404 return; 410 405 411 406 if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) { 412 - p->state = BR_STATE_FORWARDING; 407 + br_set_state(p, BR_STATE_FORWARDING); 413 408 br_topology_change_detection(br); 414 409 del_timer(&p->forward_delay_timer); 415 410 } else if (br->stp_enabled == BR_KERNEL_STP) 416 - p->state = BR_STATE_LISTENING; 411 + br_set_state(p, BR_STATE_LISTENING); 417 412 else 418 - p->state = BR_STATE_LEARNING; 413 + br_set_state(p, BR_STATE_LEARNING); 419 414 420 415 br_multicast_enable_port(p); 421 416 br_log_state(p);
+2 -2
net/bridge/br_stp_if.c
··· 37 37 { 38 38 p->port_id = br_make_port_id(p->priority, p->port_no); 39 39 br_become_designated_port(p); 40 - p->state = BR_STATE_BLOCKING; 40 + br_set_state(p, BR_STATE_BLOCKING); 41 41 p->topology_change_ack = 0; 42 42 p->config_pending = 0; 43 43 } ··· 100 100 101 101 wasroot = br_is_root_bridge(br); 102 102 br_become_designated_port(p); 103 - p->state = BR_STATE_DISABLED; 103 + br_set_state(p, BR_STATE_DISABLED); 104 104 p->topology_change_ack = 0; 105 105 p->config_pending = 0; 106 106
+2 -2
net/bridge/br_stp_timer.c
··· 87 87 (unsigned int) p->port_no, p->dev->name); 88 88 spin_lock(&br->lock); 89 89 if (p->state == BR_STATE_LISTENING) { 90 - p->state = BR_STATE_LEARNING; 90 + br_set_state(p, BR_STATE_LEARNING); 91 91 mod_timer(&p->forward_delay_timer, 92 92 jiffies + br->forward_delay); 93 93 } else if (p->state == BR_STATE_LEARNING) { 94 - p->state = BR_STATE_FORWARDING; 94 + br_set_state(p, BR_STATE_FORWARDING); 95 95 if (br_is_designated_for_some_port(br)) 96 96 br_topology_change_detection(br); 97 97 netif_carrier_on(br->dev);