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()
82 struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no) in br_get_port() argument
86 list_for_each_entry_rcu(p, &br->port_list, list, in br_get_port()
87 lockdep_is_held(&br->lock)) { in br_get_port()
99 struct net_bridge *br; in br_should_become_root_port() local
103 br = p->br; in br_should_become_root_port()
108 if (memcmp(&br->bridge_id, &p->designated_root, 8) <= 0) in br_should_become_root_port()
114 rp = br_get_port(br, root_port); in br_should_become_root_port()
146 static void br_root_port_block(const struct net_bridge *br, in br_root_port_block() argument
150 br_notice(br, "port %u(%s) tried to become root port (blocked)", in br_root_port_block()
156 if (br->forward_delay > 0) in br_root_port_block()
157 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_root_port_block()
161 static void br_root_selection(struct net_bridge *br) in br_root_selection() argument
166 list_for_each_entry(p, &br->port_list, list) { in br_root_selection()
171 br_root_port_block(br, p); in br_root_selection()
176 br->root_port = root_port; in br_root_selection()
179 br->designated_root = br->bridge_id; in br_root_selection()
180 br->root_path_cost = 0; in br_root_selection()
182 p = br_get_port(br, root_port); in br_root_selection()
183 br->designated_root = p->designated_root; in br_root_selection()
184 br->root_path_cost = p->designated_cost + p->path_cost; in br_root_selection()
189 void br_become_root_bridge(struct net_bridge *br) in br_become_root_bridge() argument
191 br->max_age = br->bridge_max_age; in br_become_root_bridge()
192 br->hello_time = br->bridge_hello_time; in br_become_root_bridge()
193 br->forward_delay = br->bridge_forward_delay; in br_become_root_bridge()
194 br_topology_change_detection(br); in br_become_root_bridge()
195 del_timer(&br->tcn_timer); in br_become_root_bridge()
197 if (br->dev->flags & IFF_UP) { in br_become_root_bridge()
198 br_config_bpdu_generation(br); in br_become_root_bridge()
199 mod_timer(&br->hello_timer, jiffies + br->hello_time); in br_become_root_bridge()
207 struct net_bridge *br; in br_transmit_config() local
214 br = p->br; in br_transmit_config()
216 bpdu.topology_change = br->topology_change; in br_transmit_config()
218 bpdu.root = br->designated_root; in br_transmit_config()
219 bpdu.root_path_cost = br->root_path_cost; in br_transmit_config()
220 bpdu.bridge_id = br->bridge_id; in br_transmit_config()
222 if (br_is_root_bridge(br)) in br_transmit_config()
226 = br_get_port(br, br->root_port); in br_transmit_config()
230 bpdu.max_age = br->max_age; in br_transmit_config()
231 bpdu.hello_time = br->hello_time; in br_transmit_config()
232 bpdu.forward_delay = br->forward_delay; in br_transmit_config()
234 if (bpdu.message_age < br->max_age) { in br_transmit_config()
238 if (p->br->stp_enabled == BR_KERNEL_STP) in br_transmit_config()
259 static void br_record_config_timeout_values(struct net_bridge *br, in br_record_config_timeout_values() argument
262 br->max_age = bpdu->max_age; in br_record_config_timeout_values()
263 br->hello_time = bpdu->hello_time; in br_record_config_timeout_values()
264 br->forward_delay = bpdu->forward_delay; in br_record_config_timeout_values()
265 __br_set_topology_change(br, bpdu->topology_change); in br_record_config_timeout_values()
269 void br_transmit_tcn(struct net_bridge *br) in br_transmit_tcn() argument
273 p = br_get_port(br, br->root_port); in br_transmit_tcn()
277 br_notice(br, "root port %u not found for topology notice\n", in br_transmit_tcn()
278 br->root_port); in br_transmit_tcn()
284 struct net_bridge *br; in br_should_become_designated_port() local
287 br = p->br; in br_should_become_designated_port()
291 if (memcmp(&p->designated_root, &br->designated_root, 8)) in br_should_become_designated_port()
294 if (br->root_path_cost < p->designated_cost) in br_should_become_designated_port()
296 else if (br->root_path_cost > p->designated_cost) in br_should_become_designated_port()
299 t = memcmp(&br->bridge_id, &p->designated_bridge, 8); in br_should_become_designated_port()
312 static void br_designated_port_selection(struct net_bridge *br) in br_designated_port_selection() argument
316 list_for_each_entry(p, &br->port_list, list) { in br_designated_port_selection()
347 if (memcmp(&bpdu->bridge_id, &p->br->bridge_id, 8)) in br_supersedes_port_info()
357 static void br_topology_change_acknowledged(struct net_bridge *br) in br_topology_change_acknowledged() argument
359 br->topology_change_detected = 0; in br_topology_change_acknowledged()
360 del_timer(&br->tcn_timer); in br_topology_change_acknowledged()
364 void br_topology_change_detection(struct net_bridge *br) in br_topology_change_detection() argument
366 int isroot = br_is_root_bridge(br); in br_topology_change_detection()
368 if (br->stp_enabled != BR_KERNEL_STP) in br_topology_change_detection()
371 br_info(br, "topology change detected, %s\n", in br_topology_change_detection()
375 __br_set_topology_change(br, 1); in br_topology_change_detection()
376 mod_timer(&br->topology_change_timer, jiffies in br_topology_change_detection()
377 + br->bridge_forward_delay + br->bridge_max_age); in br_topology_change_detection()
378 } else if (!br->topology_change_detected) { in br_topology_change_detection()
379 br_transmit_tcn(br); in br_topology_change_detection()
380 mod_timer(&br->tcn_timer, jiffies + br->bridge_hello_time); in br_topology_change_detection()
383 br->topology_change_detected = 1; in br_topology_change_detection()
387 void br_config_bpdu_generation(struct net_bridge *br) in br_config_bpdu_generation() argument
391 list_for_each_entry(p, &br->port_list, list) { in br_config_bpdu_generation()
405 void br_configuration_update(struct net_bridge *br) in br_configuration_update() argument
407 br_root_selection(br); in br_configuration_update()
408 br_designated_port_selection(br); in br_configuration_update()
414 struct net_bridge *br; in br_become_designated_port() local
416 br = p->br; in br_become_designated_port()
417 p->designated_root = br->designated_root; in br_become_designated_port()
418 p->designated_cost = br->root_path_cost; in br_become_designated_port()
419 p->designated_bridge = br->bridge_id; in br_become_designated_port()
431 br_topology_change_detection(p->br); in br_make_blocking()
443 struct net_bridge *br = p->br; in br_make_forwarding() local
448 if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) { in br_make_forwarding()
450 br_topology_change_detection(br); in br_make_forwarding()
452 } else if (br->stp_enabled == BR_KERNEL_STP) in br_make_forwarding()
459 if (br->forward_delay != 0) in br_make_forwarding()
460 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_make_forwarding()
464 void br_port_state_selection(struct net_bridge *br) in br_port_state_selection() argument
469 list_for_each_entry(p, &br->port_list, list) { in br_port_state_selection()
474 if (br->stp_enabled != BR_USER_STP) { in br_port_state_selection()
475 if (p->port_no == br->root_port) { in br_port_state_selection()
500 netif_carrier_off(br->dev); in br_port_state_selection()
502 netif_carrier_on(br->dev); in br_port_state_selection()
516 struct net_bridge *br; in br_received_config_bpdu() local
521 br = p->br; in br_received_config_bpdu()
522 was_root = br_is_root_bridge(br); in br_received_config_bpdu()
526 br_configuration_update(br); in br_received_config_bpdu()
527 br_port_state_selection(br); in br_received_config_bpdu()
529 if (!br_is_root_bridge(br) && was_root) { in br_received_config_bpdu()
530 del_timer(&br->hello_timer); in br_received_config_bpdu()
531 if (br->topology_change_detected) { in br_received_config_bpdu()
532 del_timer(&br->topology_change_timer); in br_received_config_bpdu()
533 br_transmit_tcn(br); in br_received_config_bpdu()
535 mod_timer(&br->tcn_timer, in br_received_config_bpdu()
536 jiffies + br->bridge_hello_time); in br_received_config_bpdu()
540 if (p->port_no == br->root_port) { in br_received_config_bpdu()
541 br_record_config_timeout_values(br, bpdu); in br_received_config_bpdu()
542 br_config_bpdu_generation(br); in br_received_config_bpdu()
544 br_topology_change_acknowledged(br); in br_received_config_bpdu()
557 br_info(p->br, "port %u(%s) received tcn bpdu\n", in br_received_tcn_bpdu()
560 br_topology_change_detection(p->br); in br_received_tcn_bpdu()
566 int br_set_hello_time(struct net_bridge *br, unsigned long val) in br_set_hello_time() argument
573 spin_lock_bh(&br->lock); in br_set_hello_time()
574 br->bridge_hello_time = t; in br_set_hello_time()
575 if (br_is_root_bridge(br)) in br_set_hello_time()
576 br->hello_time = br->bridge_hello_time; in br_set_hello_time()
577 spin_unlock_bh(&br->lock); in br_set_hello_time()
581 int br_set_max_age(struct net_bridge *br, unsigned long val) in br_set_max_age() argument
588 spin_lock_bh(&br->lock); in br_set_max_age()
589 br->bridge_max_age = t; in br_set_max_age()
590 if (br_is_root_bridge(br)) in br_set_max_age()
591 br->max_age = br->bridge_max_age; in br_set_max_age()
592 spin_unlock_bh(&br->lock); in br_set_max_age()
623 int br_set_ageing_time(struct net_bridge *br, clock_t ageing_time) in br_set_ageing_time() argument
628 err = __set_ageing_time(br->dev, t); in br_set_ageing_time()
632 spin_lock_bh(&br->lock); in br_set_ageing_time()
633 br->bridge_ageing_time = t; in br_set_ageing_time()
634 br->ageing_time = t; in br_set_ageing_time()
635 spin_unlock_bh(&br->lock); in br_set_ageing_time()
637 mod_delayed_work(system_long_wq, &br->gc_work, 0); in br_set_ageing_time()
644 const struct net_bridge *br; in br_get_ageing_time() local
649 br = netdev_priv(br_dev); in br_get_ageing_time()
651 return jiffies_to_clock_t(br->ageing_time); in br_get_ageing_time()
656 void __br_set_topology_change(struct net_bridge *br, unsigned char val) in __br_set_topology_change() argument
661 if (br->stp_enabled == BR_KERNEL_STP && br->topology_change != val) { in __br_set_topology_change()
667 t = 2 * br->forward_delay; in __br_set_topology_change()
668 br_debug(br, "decreasing ageing time to %lu\n", t); in __br_set_topology_change()
670 t = br->bridge_ageing_time; in __br_set_topology_change()
671 br_debug(br, "restoring ageing time to %lu\n", t); in __br_set_topology_change()
674 err = __set_ageing_time(br->dev, t); in __br_set_topology_change()
676 br_warn(br, "error offloading ageing time\n"); in __br_set_topology_change()
678 br->ageing_time = t; in __br_set_topology_change()
681 br->topology_change = val; in __br_set_topology_change()
684 void __br_set_forward_delay(struct net_bridge *br, unsigned long t) in __br_set_forward_delay() argument
686 br->bridge_forward_delay = t; in __br_set_forward_delay()
687 if (br_is_root_bridge(br)) in __br_set_forward_delay()
688 br->forward_delay = br->bridge_forward_delay; in __br_set_forward_delay()
691 int br_set_forward_delay(struct net_bridge *br, unsigned long val) in br_set_forward_delay() argument
696 spin_lock_bh(&br->lock); in br_set_forward_delay()
697 if (br->stp_enabled != BR_NO_STP && in br_set_forward_delay()
701 __br_set_forward_delay(br, t); in br_set_forward_delay()
705 spin_unlock_bh(&br->lock); in br_set_forward_delay()