Lines Matching refs:br
35 br_info(p->br, "port %u(%s) entered %s state\n", in br_log_state()
47 br_warn(p->br, "error setting offload STP state on port %u(%s)\n", in br_set_state()
52 struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no) in br_get_port() argument
56 list_for_each_entry_rcu(p, &br->port_list, list) { in br_get_port()
68 struct net_bridge *br; in br_should_become_root_port() local
72 br = p->br; in br_should_become_root_port()
77 if (memcmp(&br->bridge_id, &p->designated_root, 8) <= 0) in br_should_become_root_port()
83 rp = br_get_port(br, root_port); in br_should_become_root_port()
115 static void br_root_port_block(const struct net_bridge *br, in br_root_port_block() argument
119 br_notice(br, "port %u(%s) tried to become root port (blocked)", in br_root_port_block()
126 if (br->forward_delay > 0) in br_root_port_block()
127 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_root_port_block()
131 static void br_root_selection(struct net_bridge *br) in br_root_selection() argument
136 list_for_each_entry(p, &br->port_list, list) { in br_root_selection()
141 br_root_port_block(br, p); in br_root_selection()
146 br->root_port = root_port; in br_root_selection()
149 br->designated_root = br->bridge_id; in br_root_selection()
150 br->root_path_cost = 0; in br_root_selection()
152 p = br_get_port(br, root_port); in br_root_selection()
153 br->designated_root = p->designated_root; in br_root_selection()
154 br->root_path_cost = p->designated_cost + p->path_cost; in br_root_selection()
159 void br_become_root_bridge(struct net_bridge *br) in br_become_root_bridge() argument
161 br->max_age = br->bridge_max_age; in br_become_root_bridge()
162 br->hello_time = br->bridge_hello_time; in br_become_root_bridge()
163 br->forward_delay = br->bridge_forward_delay; in br_become_root_bridge()
164 br_topology_change_detection(br); in br_become_root_bridge()
165 del_timer(&br->tcn_timer); in br_become_root_bridge()
167 if (br->dev->flags & IFF_UP) { in br_become_root_bridge()
168 br_config_bpdu_generation(br); in br_become_root_bridge()
169 mod_timer(&br->hello_timer, jiffies + br->hello_time); in br_become_root_bridge()
177 struct net_bridge *br; in br_transmit_config() local
184 br = p->br; in br_transmit_config()
186 bpdu.topology_change = br->topology_change; in br_transmit_config()
188 bpdu.root = br->designated_root; in br_transmit_config()
189 bpdu.root_path_cost = br->root_path_cost; in br_transmit_config()
190 bpdu.bridge_id = br->bridge_id; in br_transmit_config()
192 if (br_is_root_bridge(br)) in br_transmit_config()
196 = br_get_port(br, br->root_port); in br_transmit_config()
200 bpdu.max_age = br->max_age; in br_transmit_config()
201 bpdu.hello_time = br->hello_time; in br_transmit_config()
202 bpdu.forward_delay = br->forward_delay; in br_transmit_config()
204 if (bpdu.message_age < br->max_age) { in br_transmit_config()
228 static void br_record_config_timeout_values(struct net_bridge *br, in br_record_config_timeout_values() argument
231 br->max_age = bpdu->max_age; in br_record_config_timeout_values()
232 br->hello_time = bpdu->hello_time; in br_record_config_timeout_values()
233 br->forward_delay = bpdu->forward_delay; in br_record_config_timeout_values()
234 br->topology_change = bpdu->topology_change; in br_record_config_timeout_values()
238 void br_transmit_tcn(struct net_bridge *br) in br_transmit_tcn() argument
242 p = br_get_port(br, br->root_port); in br_transmit_tcn()
246 br_notice(br, "root port %u not found for topology notice\n", in br_transmit_tcn()
247 br->root_port); in br_transmit_tcn()
253 struct net_bridge *br; in br_should_become_designated_port() local
256 br = p->br; in br_should_become_designated_port()
260 if (memcmp(&p->designated_root, &br->designated_root, 8)) in br_should_become_designated_port()
263 if (br->root_path_cost < p->designated_cost) in br_should_become_designated_port()
265 else if (br->root_path_cost > p->designated_cost) in br_should_become_designated_port()
268 t = memcmp(&br->bridge_id, &p->designated_bridge, 8); in br_should_become_designated_port()
281 static void br_designated_port_selection(struct net_bridge *br) in br_designated_port_selection() argument
285 list_for_each_entry(p, &br->port_list, list) { in br_designated_port_selection()
316 if (memcmp(&bpdu->bridge_id, &p->br->bridge_id, 8)) in br_supersedes_port_info()
326 static void br_topology_change_acknowledged(struct net_bridge *br) in br_topology_change_acknowledged() argument
328 br->topology_change_detected = 0; in br_topology_change_acknowledged()
329 del_timer(&br->tcn_timer); in br_topology_change_acknowledged()
333 void br_topology_change_detection(struct net_bridge *br) in br_topology_change_detection() argument
335 int isroot = br_is_root_bridge(br); in br_topology_change_detection()
337 if (br->stp_enabled != BR_KERNEL_STP) in br_topology_change_detection()
340 br_info(br, "topology change detected, %s\n", in br_topology_change_detection()
344 br->topology_change = 1; in br_topology_change_detection()
345 mod_timer(&br->topology_change_timer, jiffies in br_topology_change_detection()
346 + br->bridge_forward_delay + br->bridge_max_age); in br_topology_change_detection()
347 } else if (!br->topology_change_detected) { in br_topology_change_detection()
348 br_transmit_tcn(br); in br_topology_change_detection()
349 mod_timer(&br->tcn_timer, jiffies + br->bridge_hello_time); in br_topology_change_detection()
352 br->topology_change_detected = 1; in br_topology_change_detection()
356 void br_config_bpdu_generation(struct net_bridge *br) in br_config_bpdu_generation() argument
360 list_for_each_entry(p, &br->port_list, list) { in br_config_bpdu_generation()
374 void br_configuration_update(struct net_bridge *br) in br_configuration_update() argument
376 br_root_selection(br); in br_configuration_update()
377 br_designated_port_selection(br); in br_configuration_update()
383 struct net_bridge *br; in br_become_designated_port() local
385 br = p->br; in br_become_designated_port()
386 p->designated_root = br->designated_root; in br_become_designated_port()
387 p->designated_cost = br->root_path_cost; in br_become_designated_port()
388 p->designated_bridge = br->bridge_id; in br_become_designated_port()
400 br_topology_change_detection(p->br); in br_make_blocking()
413 struct net_bridge *br = p->br; in br_make_forwarding() local
418 if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) { in br_make_forwarding()
420 br_topology_change_detection(br); in br_make_forwarding()
422 } else if (br->stp_enabled == BR_KERNEL_STP) in br_make_forwarding()
431 if (br->forward_delay != 0) in br_make_forwarding()
432 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_make_forwarding()
436 void br_port_state_selection(struct net_bridge *br) in br_port_state_selection() argument
441 list_for_each_entry(p, &br->port_list, list) { in br_port_state_selection()
446 if (br->stp_enabled != BR_USER_STP) { in br_port_state_selection()
447 if (p->port_no == br->root_port) { in br_port_state_selection()
466 netif_carrier_off(br->dev); in br_port_state_selection()
468 netif_carrier_on(br->dev); in br_port_state_selection()
482 struct net_bridge *br; in br_received_config_bpdu() local
485 br = p->br; in br_received_config_bpdu()
486 was_root = br_is_root_bridge(br); in br_received_config_bpdu()
490 br_configuration_update(br); in br_received_config_bpdu()
491 br_port_state_selection(br); in br_received_config_bpdu()
493 if (!br_is_root_bridge(br) && was_root) { in br_received_config_bpdu()
494 del_timer(&br->hello_timer); in br_received_config_bpdu()
495 if (br->topology_change_detected) { in br_received_config_bpdu()
496 del_timer(&br->topology_change_timer); in br_received_config_bpdu()
497 br_transmit_tcn(br); in br_received_config_bpdu()
499 mod_timer(&br->tcn_timer, in br_received_config_bpdu()
500 jiffies + br->bridge_hello_time); in br_received_config_bpdu()
504 if (p->port_no == br->root_port) { in br_received_config_bpdu()
505 br_record_config_timeout_values(br, bpdu); in br_received_config_bpdu()
506 br_config_bpdu_generation(br); in br_received_config_bpdu()
508 br_topology_change_acknowledged(br); in br_received_config_bpdu()
519 br_info(p->br, "port %u(%s) received tcn bpdu\n", in br_received_tcn_bpdu()
522 br_topology_change_detection(p->br); in br_received_tcn_bpdu()
528 int br_set_hello_time(struct net_bridge *br, unsigned long val) in br_set_hello_time() argument
535 spin_lock_bh(&br->lock); in br_set_hello_time()
536 br->bridge_hello_time = t; in br_set_hello_time()
537 if (br_is_root_bridge(br)) in br_set_hello_time()
538 br->hello_time = br->bridge_hello_time; in br_set_hello_time()
539 spin_unlock_bh(&br->lock); in br_set_hello_time()
543 int br_set_max_age(struct net_bridge *br, unsigned long val) in br_set_max_age() argument
550 spin_lock_bh(&br->lock); in br_set_max_age()
551 br->bridge_max_age = t; in br_set_max_age()
552 if (br_is_root_bridge(br)) in br_set_max_age()
553 br->max_age = br->bridge_max_age; in br_set_max_age()
554 spin_unlock_bh(&br->lock); in br_set_max_age()
559 void __br_set_forward_delay(struct net_bridge *br, unsigned long t) in __br_set_forward_delay() argument
561 br->bridge_forward_delay = t; in __br_set_forward_delay()
562 if (br_is_root_bridge(br)) in __br_set_forward_delay()
563 br->forward_delay = br->bridge_forward_delay; in __br_set_forward_delay()
566 int br_set_forward_delay(struct net_bridge *br, unsigned long val) in br_set_forward_delay() argument
571 spin_lock_bh(&br->lock); in br_set_forward_delay()
572 if (br->stp_enabled != BR_NO_STP && in br_set_forward_delay()
576 __br_set_forward_delay(br, t); in br_set_forward_delay()
580 spin_unlock_bh(&br->lock); in br_set_forward_delay()