Lines Matching refs:br
48 br_warn(p->br, "error setting offload STP state on port %u(%s)\n", in br_set_state()
51 br_info(p->br, "port %u(%s) entered %s state\n", in br_set_state()
55 if (p->br->stp_enabled == BR_KERNEL_STP) { in br_set_state()
68 struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no) in br_get_port() argument
72 list_for_each_entry_rcu(p, &br->port_list, list, in br_get_port()
73 lockdep_is_held(&br->lock)) { in br_get_port()
85 struct net_bridge *br; in br_should_become_root_port() local
89 br = p->br; in br_should_become_root_port()
94 if (memcmp(&br->bridge_id, &p->designated_root, 8) <= 0) in br_should_become_root_port()
100 rp = br_get_port(br, root_port); in br_should_become_root_port()
132 static void br_root_port_block(const struct net_bridge *br, in br_root_port_block() argument
136 br_notice(br, "port %u(%s) tried to become root port (blocked)", in br_root_port_block()
142 if (br->forward_delay > 0) in br_root_port_block()
143 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_root_port_block()
147 static void br_root_selection(struct net_bridge *br) in br_root_selection() argument
152 list_for_each_entry(p, &br->port_list, list) { in br_root_selection()
157 br_root_port_block(br, p); in br_root_selection()
162 br->root_port = root_port; in br_root_selection()
165 br->designated_root = br->bridge_id; in br_root_selection()
166 br->root_path_cost = 0; in br_root_selection()
168 p = br_get_port(br, root_port); in br_root_selection()
169 br->designated_root = p->designated_root; in br_root_selection()
170 br->root_path_cost = p->designated_cost + p->path_cost; in br_root_selection()
175 void br_become_root_bridge(struct net_bridge *br) in br_become_root_bridge() argument
177 br->max_age = br->bridge_max_age; in br_become_root_bridge()
178 br->hello_time = br->bridge_hello_time; in br_become_root_bridge()
179 br->forward_delay = br->bridge_forward_delay; in br_become_root_bridge()
180 br_topology_change_detection(br); in br_become_root_bridge()
181 del_timer(&br->tcn_timer); in br_become_root_bridge()
183 if (br->dev->flags & IFF_UP) { in br_become_root_bridge()
184 br_config_bpdu_generation(br); in br_become_root_bridge()
185 mod_timer(&br->hello_timer, jiffies + br->hello_time); in br_become_root_bridge()
193 struct net_bridge *br; in br_transmit_config() local
200 br = p->br; in br_transmit_config()
202 bpdu.topology_change = br->topology_change; in br_transmit_config()
204 bpdu.root = br->designated_root; in br_transmit_config()
205 bpdu.root_path_cost = br->root_path_cost; in br_transmit_config()
206 bpdu.bridge_id = br->bridge_id; in br_transmit_config()
208 if (br_is_root_bridge(br)) in br_transmit_config()
212 = br_get_port(br, br->root_port); in br_transmit_config()
216 bpdu.max_age = br->max_age; in br_transmit_config()
217 bpdu.hello_time = br->hello_time; in br_transmit_config()
218 bpdu.forward_delay = br->forward_delay; in br_transmit_config()
220 if (bpdu.message_age < br->max_age) { in br_transmit_config()
224 if (p->br->stp_enabled == BR_KERNEL_STP) in br_transmit_config()
245 static void br_record_config_timeout_values(struct net_bridge *br, in br_record_config_timeout_values() argument
248 br->max_age = bpdu->max_age; in br_record_config_timeout_values()
249 br->hello_time = bpdu->hello_time; in br_record_config_timeout_values()
250 br->forward_delay = bpdu->forward_delay; in br_record_config_timeout_values()
251 __br_set_topology_change(br, bpdu->topology_change); in br_record_config_timeout_values()
255 void br_transmit_tcn(struct net_bridge *br) in br_transmit_tcn() argument
259 p = br_get_port(br, br->root_port); in br_transmit_tcn()
263 br_notice(br, "root port %u not found for topology notice\n", in br_transmit_tcn()
264 br->root_port); in br_transmit_tcn()
270 struct net_bridge *br; in br_should_become_designated_port() local
273 br = p->br; in br_should_become_designated_port()
277 if (memcmp(&p->designated_root, &br->designated_root, 8)) in br_should_become_designated_port()
280 if (br->root_path_cost < p->designated_cost) in br_should_become_designated_port()
282 else if (br->root_path_cost > p->designated_cost) in br_should_become_designated_port()
285 t = memcmp(&br->bridge_id, &p->designated_bridge, 8); in br_should_become_designated_port()
298 static void br_designated_port_selection(struct net_bridge *br) in br_designated_port_selection() argument
302 list_for_each_entry(p, &br->port_list, list) { in br_designated_port_selection()
333 if (memcmp(&bpdu->bridge_id, &p->br->bridge_id, 8)) in br_supersedes_port_info()
343 static void br_topology_change_acknowledged(struct net_bridge *br) in br_topology_change_acknowledged() argument
345 br->topology_change_detected = 0; in br_topology_change_acknowledged()
346 del_timer(&br->tcn_timer); in br_topology_change_acknowledged()
350 void br_topology_change_detection(struct net_bridge *br) in br_topology_change_detection() argument
352 int isroot = br_is_root_bridge(br); in br_topology_change_detection()
354 if (br->stp_enabled != BR_KERNEL_STP) in br_topology_change_detection()
357 br_info(br, "topology change detected, %s\n", in br_topology_change_detection()
361 __br_set_topology_change(br, 1); in br_topology_change_detection()
362 mod_timer(&br->topology_change_timer, jiffies in br_topology_change_detection()
363 + br->bridge_forward_delay + br->bridge_max_age); in br_topology_change_detection()
364 } else if (!br->topology_change_detected) { in br_topology_change_detection()
365 br_transmit_tcn(br); in br_topology_change_detection()
366 mod_timer(&br->tcn_timer, jiffies + br->bridge_hello_time); in br_topology_change_detection()
369 br->topology_change_detected = 1; in br_topology_change_detection()
373 void br_config_bpdu_generation(struct net_bridge *br) in br_config_bpdu_generation() argument
377 list_for_each_entry(p, &br->port_list, list) { in br_config_bpdu_generation()
391 void br_configuration_update(struct net_bridge *br) in br_configuration_update() argument
393 br_root_selection(br); in br_configuration_update()
394 br_designated_port_selection(br); in br_configuration_update()
400 struct net_bridge *br; in br_become_designated_port() local
402 br = p->br; in br_become_designated_port()
403 p->designated_root = br->designated_root; in br_become_designated_port()
404 p->designated_cost = br->root_path_cost; in br_become_designated_port()
405 p->designated_bridge = br->bridge_id; in br_become_designated_port()
417 br_topology_change_detection(p->br); in br_make_blocking()
429 struct net_bridge *br = p->br; in br_make_forwarding() local
434 if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) { in br_make_forwarding()
436 br_topology_change_detection(br); in br_make_forwarding()
438 } else if (br->stp_enabled == BR_KERNEL_STP) in br_make_forwarding()
445 if (br->forward_delay != 0) in br_make_forwarding()
446 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_make_forwarding()
450 void br_port_state_selection(struct net_bridge *br) in br_port_state_selection() argument
455 list_for_each_entry(p, &br->port_list, list) { in br_port_state_selection()
460 if (br->stp_enabled != BR_USER_STP) { in br_port_state_selection()
461 if (p->port_no == br->root_port) { in br_port_state_selection()
486 netif_carrier_off(br->dev); in br_port_state_selection()
488 netif_carrier_on(br->dev); in br_port_state_selection()
502 struct net_bridge *br; in br_received_config_bpdu() local
507 br = p->br; in br_received_config_bpdu()
508 was_root = br_is_root_bridge(br); in br_received_config_bpdu()
512 br_configuration_update(br); in br_received_config_bpdu()
513 br_port_state_selection(br); in br_received_config_bpdu()
515 if (!br_is_root_bridge(br) && was_root) { in br_received_config_bpdu()
516 del_timer(&br->hello_timer); in br_received_config_bpdu()
517 if (br->topology_change_detected) { in br_received_config_bpdu()
518 del_timer(&br->topology_change_timer); in br_received_config_bpdu()
519 br_transmit_tcn(br); in br_received_config_bpdu()
521 mod_timer(&br->tcn_timer, in br_received_config_bpdu()
522 jiffies + br->bridge_hello_time); in br_received_config_bpdu()
526 if (p->port_no == br->root_port) { in br_received_config_bpdu()
527 br_record_config_timeout_values(br, bpdu); in br_received_config_bpdu()
528 br_config_bpdu_generation(br); in br_received_config_bpdu()
530 br_topology_change_acknowledged(br); in br_received_config_bpdu()
543 br_info(p->br, "port %u(%s) received tcn bpdu\n", in br_received_tcn_bpdu()
546 br_topology_change_detection(p->br); in br_received_tcn_bpdu()
552 int br_set_hello_time(struct net_bridge *br, unsigned long val) in br_set_hello_time() argument
559 spin_lock_bh(&br->lock); in br_set_hello_time()
560 br->bridge_hello_time = t; in br_set_hello_time()
561 if (br_is_root_bridge(br)) in br_set_hello_time()
562 br->hello_time = br->bridge_hello_time; in br_set_hello_time()
563 spin_unlock_bh(&br->lock); in br_set_hello_time()
567 int br_set_max_age(struct net_bridge *br, unsigned long val) in br_set_max_age() argument
574 spin_lock_bh(&br->lock); in br_set_max_age()
575 br->bridge_max_age = t; in br_set_max_age()
576 if (br_is_root_bridge(br)) in br_set_max_age()
577 br->max_age = br->bridge_max_age; in br_set_max_age()
578 spin_unlock_bh(&br->lock); in br_set_max_age()
609 int br_set_ageing_time(struct net_bridge *br, clock_t ageing_time) in br_set_ageing_time() argument
614 err = __set_ageing_time(br->dev, t); in br_set_ageing_time()
618 spin_lock_bh(&br->lock); in br_set_ageing_time()
619 br->bridge_ageing_time = t; in br_set_ageing_time()
620 br->ageing_time = t; in br_set_ageing_time()
621 spin_unlock_bh(&br->lock); in br_set_ageing_time()
623 mod_delayed_work(system_long_wq, &br->gc_work, 0); in br_set_ageing_time()
629 void __br_set_topology_change(struct net_bridge *br, unsigned char val) in __br_set_topology_change() argument
634 if (br->stp_enabled == BR_KERNEL_STP && br->topology_change != val) { in __br_set_topology_change()
640 t = 2 * br->forward_delay; in __br_set_topology_change()
641 br_debug(br, "decreasing ageing time to %lu\n", t); in __br_set_topology_change()
643 t = br->bridge_ageing_time; in __br_set_topology_change()
644 br_debug(br, "restoring ageing time to %lu\n", t); in __br_set_topology_change()
647 err = __set_ageing_time(br->dev, t); in __br_set_topology_change()
649 br_warn(br, "error offloading ageing time\n"); in __br_set_topology_change()
651 br->ageing_time = t; in __br_set_topology_change()
654 br->topology_change = val; in __br_set_topology_change()
657 void __br_set_forward_delay(struct net_bridge *br, unsigned long t) in __br_set_forward_delay() argument
659 br->bridge_forward_delay = t; in __br_set_forward_delay()
660 if (br_is_root_bridge(br)) in __br_set_forward_delay()
661 br->forward_delay = br->bridge_forward_delay; in __br_set_forward_delay()
664 int br_set_forward_delay(struct net_bridge *br, unsigned long val) in br_set_forward_delay() argument
669 spin_lock_bh(&br->lock); in br_set_forward_delay()
670 if (br->stp_enabled != BR_NO_STP && in br_set_forward_delay()
674 __br_set_forward_delay(br, t); in br_set_forward_delay()
678 spin_unlock_bh(&br->lock); in br_set_forward_delay()