Lines Matching refs:br
42 br_warn(p->br, "error setting offload STP state on port %u(%s)\n", in br_set_state()
45 br_info(p->br, "port %u(%s) entered %s state\n", in br_set_state()
51 struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no) in br_get_port() argument
55 list_for_each_entry_rcu(p, &br->port_list, list) { in br_get_port()
67 struct net_bridge *br; in br_should_become_root_port() local
71 br = p->br; in br_should_become_root_port()
76 if (memcmp(&br->bridge_id, &p->designated_root, 8) <= 0) in br_should_become_root_port()
82 rp = br_get_port(br, root_port); in br_should_become_root_port()
114 static void br_root_port_block(const struct net_bridge *br, in br_root_port_block() argument
118 br_notice(br, "port %u(%s) tried to become root port (blocked)", in br_root_port_block()
124 if (br->forward_delay > 0) in br_root_port_block()
125 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_root_port_block()
129 static void br_root_selection(struct net_bridge *br) in br_root_selection() argument
134 list_for_each_entry(p, &br->port_list, list) { in br_root_selection()
139 br_root_port_block(br, p); in br_root_selection()
144 br->root_port = root_port; in br_root_selection()
147 br->designated_root = br->bridge_id; in br_root_selection()
148 br->root_path_cost = 0; in br_root_selection()
150 p = br_get_port(br, root_port); in br_root_selection()
151 br->designated_root = p->designated_root; in br_root_selection()
152 br->root_path_cost = p->designated_cost + p->path_cost; in br_root_selection()
157 void br_become_root_bridge(struct net_bridge *br) in br_become_root_bridge() argument
159 br->max_age = br->bridge_max_age; in br_become_root_bridge()
160 br->hello_time = br->bridge_hello_time; in br_become_root_bridge()
161 br->forward_delay = br->bridge_forward_delay; in br_become_root_bridge()
162 br_topology_change_detection(br); in br_become_root_bridge()
163 del_timer(&br->tcn_timer); in br_become_root_bridge()
165 if (br->dev->flags & IFF_UP) { in br_become_root_bridge()
166 br_config_bpdu_generation(br); in br_become_root_bridge()
167 mod_timer(&br->hello_timer, jiffies + br->hello_time); in br_become_root_bridge()
175 struct net_bridge *br; in br_transmit_config() local
182 br = p->br; in br_transmit_config()
184 bpdu.topology_change = br->topology_change; in br_transmit_config()
186 bpdu.root = br->designated_root; in br_transmit_config()
187 bpdu.root_path_cost = br->root_path_cost; in br_transmit_config()
188 bpdu.bridge_id = br->bridge_id; in br_transmit_config()
190 if (br_is_root_bridge(br)) in br_transmit_config()
194 = br_get_port(br, br->root_port); in br_transmit_config()
198 bpdu.max_age = br->max_age; in br_transmit_config()
199 bpdu.hello_time = br->hello_time; in br_transmit_config()
200 bpdu.forward_delay = br->forward_delay; in br_transmit_config()
202 if (bpdu.message_age < br->max_age) { in br_transmit_config()
206 if (p->br->stp_enabled == BR_KERNEL_STP) in br_transmit_config()
227 static void br_record_config_timeout_values(struct net_bridge *br, in br_record_config_timeout_values() argument
230 br->max_age = bpdu->max_age; in br_record_config_timeout_values()
231 br->hello_time = bpdu->hello_time; in br_record_config_timeout_values()
232 br->forward_delay = bpdu->forward_delay; in br_record_config_timeout_values()
233 __br_set_topology_change(br, bpdu->topology_change); in br_record_config_timeout_values()
237 void br_transmit_tcn(struct net_bridge *br) in br_transmit_tcn() argument
241 p = br_get_port(br, br->root_port); in br_transmit_tcn()
245 br_notice(br, "root port %u not found for topology notice\n", in br_transmit_tcn()
246 br->root_port); in br_transmit_tcn()
252 struct net_bridge *br; in br_should_become_designated_port() local
255 br = p->br; in br_should_become_designated_port()
259 if (memcmp(&p->designated_root, &br->designated_root, 8)) in br_should_become_designated_port()
262 if (br->root_path_cost < p->designated_cost) in br_should_become_designated_port()
264 else if (br->root_path_cost > p->designated_cost) in br_should_become_designated_port()
267 t = memcmp(&br->bridge_id, &p->designated_bridge, 8); in br_should_become_designated_port()
280 static void br_designated_port_selection(struct net_bridge *br) in br_designated_port_selection() argument
284 list_for_each_entry(p, &br->port_list, list) { in br_designated_port_selection()
315 if (memcmp(&bpdu->bridge_id, &p->br->bridge_id, 8)) in br_supersedes_port_info()
325 static void br_topology_change_acknowledged(struct net_bridge *br) in br_topology_change_acknowledged() argument
327 br->topology_change_detected = 0; in br_topology_change_acknowledged()
328 del_timer(&br->tcn_timer); in br_topology_change_acknowledged()
332 void br_topology_change_detection(struct net_bridge *br) in br_topology_change_detection() argument
334 int isroot = br_is_root_bridge(br); in br_topology_change_detection()
336 if (br->stp_enabled != BR_KERNEL_STP) in br_topology_change_detection()
339 br_info(br, "topology change detected, %s\n", in br_topology_change_detection()
343 __br_set_topology_change(br, 1); in br_topology_change_detection()
344 mod_timer(&br->topology_change_timer, jiffies in br_topology_change_detection()
345 + br->bridge_forward_delay + br->bridge_max_age); in br_topology_change_detection()
346 } else if (!br->topology_change_detected) { in br_topology_change_detection()
347 br_transmit_tcn(br); in br_topology_change_detection()
348 mod_timer(&br->tcn_timer, jiffies + br->bridge_hello_time); in br_topology_change_detection()
351 br->topology_change_detected = 1; in br_topology_change_detection()
355 void br_config_bpdu_generation(struct net_bridge *br) in br_config_bpdu_generation() argument
359 list_for_each_entry(p, &br->port_list, list) { in br_config_bpdu_generation()
373 void br_configuration_update(struct net_bridge *br) in br_configuration_update() argument
375 br_root_selection(br); in br_configuration_update()
376 br_designated_port_selection(br); in br_configuration_update()
382 struct net_bridge *br; in br_become_designated_port() local
384 br = p->br; in br_become_designated_port()
385 p->designated_root = br->designated_root; in br_become_designated_port()
386 p->designated_cost = br->root_path_cost; in br_become_designated_port()
387 p->designated_bridge = br->bridge_id; in br_become_designated_port()
399 br_topology_change_detection(p->br); in br_make_blocking()
411 struct net_bridge *br = p->br; in br_make_forwarding() local
416 if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) { in br_make_forwarding()
418 br_topology_change_detection(br); in br_make_forwarding()
420 } else if (br->stp_enabled == BR_KERNEL_STP) in br_make_forwarding()
427 if (br->forward_delay != 0) in br_make_forwarding()
428 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_make_forwarding()
432 void br_port_state_selection(struct net_bridge *br) in br_port_state_selection() argument
437 list_for_each_entry(p, &br->port_list, list) { in br_port_state_selection()
442 if (br->stp_enabled != BR_USER_STP) { in br_port_state_selection()
443 if (p->port_no == br->root_port) { in br_port_state_selection()
468 netif_carrier_off(br->dev); in br_port_state_selection()
470 netif_carrier_on(br->dev); in br_port_state_selection()
484 struct net_bridge *br; in br_received_config_bpdu() local
487 br = p->br; in br_received_config_bpdu()
488 was_root = br_is_root_bridge(br); in br_received_config_bpdu()
492 br_configuration_update(br); in br_received_config_bpdu()
493 br_port_state_selection(br); in br_received_config_bpdu()
495 if (!br_is_root_bridge(br) && was_root) { in br_received_config_bpdu()
496 del_timer(&br->hello_timer); in br_received_config_bpdu()
497 if (br->topology_change_detected) { in br_received_config_bpdu()
498 del_timer(&br->topology_change_timer); in br_received_config_bpdu()
499 br_transmit_tcn(br); in br_received_config_bpdu()
501 mod_timer(&br->tcn_timer, in br_received_config_bpdu()
502 jiffies + br->bridge_hello_time); in br_received_config_bpdu()
506 if (p->port_no == br->root_port) { in br_received_config_bpdu()
507 br_record_config_timeout_values(br, bpdu); in br_received_config_bpdu()
508 br_config_bpdu_generation(br); in br_received_config_bpdu()
510 br_topology_change_acknowledged(br); in br_received_config_bpdu()
521 br_info(p->br, "port %u(%s) received tcn bpdu\n", in br_received_tcn_bpdu()
524 br_topology_change_detection(p->br); in br_received_tcn_bpdu()
530 int br_set_hello_time(struct net_bridge *br, unsigned long val) in br_set_hello_time() argument
537 spin_lock_bh(&br->lock); in br_set_hello_time()
538 br->bridge_hello_time = t; in br_set_hello_time()
539 if (br_is_root_bridge(br)) in br_set_hello_time()
540 br->hello_time = br->bridge_hello_time; in br_set_hello_time()
541 spin_unlock_bh(&br->lock); in br_set_hello_time()
545 int br_set_max_age(struct net_bridge *br, unsigned long val) in br_set_max_age() argument
552 spin_lock_bh(&br->lock); in br_set_max_age()
553 br->bridge_max_age = t; in br_set_max_age()
554 if (br_is_root_bridge(br)) in br_set_max_age()
555 br->max_age = br->bridge_max_age; in br_set_max_age()
556 spin_unlock_bh(&br->lock); in br_set_max_age()
587 int br_set_ageing_time(struct net_bridge *br, clock_t ageing_time) in br_set_ageing_time() argument
592 err = __set_ageing_time(br->dev, t); in br_set_ageing_time()
596 spin_lock_bh(&br->lock); in br_set_ageing_time()
597 br->bridge_ageing_time = t; in br_set_ageing_time()
598 br->ageing_time = t; in br_set_ageing_time()
599 spin_unlock_bh(&br->lock); in br_set_ageing_time()
601 mod_delayed_work(system_long_wq, &br->gc_work, 0); in br_set_ageing_time()
607 void __br_set_topology_change(struct net_bridge *br, unsigned char val) in __br_set_topology_change() argument
612 if (br->stp_enabled == BR_KERNEL_STP && br->topology_change != val) { in __br_set_topology_change()
618 t = 2 * br->forward_delay; in __br_set_topology_change()
619 br_debug(br, "decreasing ageing time to %lu\n", t); in __br_set_topology_change()
621 t = br->bridge_ageing_time; in __br_set_topology_change()
622 br_debug(br, "restoring ageing time to %lu\n", t); in __br_set_topology_change()
625 err = __set_ageing_time(br->dev, t); in __br_set_topology_change()
627 br_warn(br, "error offloading ageing time\n"); in __br_set_topology_change()
629 br->ageing_time = t; in __br_set_topology_change()
632 br->topology_change = val; in __br_set_topology_change()
635 void __br_set_forward_delay(struct net_bridge *br, unsigned long t) in __br_set_forward_delay() argument
637 br->bridge_forward_delay = t; in __br_set_forward_delay()
638 if (br_is_root_bridge(br)) in __br_set_forward_delay()
639 br->forward_delay = br->bridge_forward_delay; in __br_set_forward_delay()
642 int br_set_forward_delay(struct net_bridge *br, unsigned long val) in br_set_forward_delay() argument
647 spin_lock_bh(&br->lock); in br_set_forward_delay()
648 if (br->stp_enabled != BR_NO_STP && in br_set_forward_delay()
652 __br_set_forward_delay(br, t); in br_set_forward_delay()
656 spin_unlock_bh(&br->lock); in br_set_forward_delay()