Lines Matching refs:br
35 br_info(p->br, "port %u(%s) entered %s state\n", in br_log_state()
52 br_warn(p->br, "error setting offload STP state on port %u(%s)\n", in br_set_state()
57 struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no) in br_get_port() argument
61 list_for_each_entry_rcu(p, &br->port_list, list) { in br_get_port()
73 struct net_bridge *br; in br_should_become_root_port() local
77 br = p->br; in br_should_become_root_port()
82 if (memcmp(&br->bridge_id, &p->designated_root, 8) <= 0) in br_should_become_root_port()
88 rp = br_get_port(br, root_port); in br_should_become_root_port()
120 static void br_root_port_block(const struct net_bridge *br, in br_root_port_block() argument
124 br_notice(br, "port %u(%s) tried to become root port (blocked)", in br_root_port_block()
131 if (br->forward_delay > 0) in br_root_port_block()
132 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_root_port_block()
136 static void br_root_selection(struct net_bridge *br) in br_root_selection() argument
141 list_for_each_entry(p, &br->port_list, list) { in br_root_selection()
146 br_root_port_block(br, p); in br_root_selection()
151 br->root_port = root_port; in br_root_selection()
154 br->designated_root = br->bridge_id; in br_root_selection()
155 br->root_path_cost = 0; in br_root_selection()
157 p = br_get_port(br, root_port); in br_root_selection()
158 br->designated_root = p->designated_root; in br_root_selection()
159 br->root_path_cost = p->designated_cost + p->path_cost; in br_root_selection()
164 void br_become_root_bridge(struct net_bridge *br) in br_become_root_bridge() argument
166 br->max_age = br->bridge_max_age; in br_become_root_bridge()
167 br->hello_time = br->bridge_hello_time; in br_become_root_bridge()
168 br->forward_delay = br->bridge_forward_delay; in br_become_root_bridge()
169 br_topology_change_detection(br); in br_become_root_bridge()
170 del_timer(&br->tcn_timer); in br_become_root_bridge()
172 if (br->dev->flags & IFF_UP) { in br_become_root_bridge()
173 br_config_bpdu_generation(br); in br_become_root_bridge()
174 mod_timer(&br->hello_timer, jiffies + br->hello_time); in br_become_root_bridge()
182 struct net_bridge *br; in br_transmit_config() local
189 br = p->br; in br_transmit_config()
191 bpdu.topology_change = br->topology_change; in br_transmit_config()
193 bpdu.root = br->designated_root; in br_transmit_config()
194 bpdu.root_path_cost = br->root_path_cost; in br_transmit_config()
195 bpdu.bridge_id = br->bridge_id; in br_transmit_config()
197 if (br_is_root_bridge(br)) in br_transmit_config()
201 = br_get_port(br, br->root_port); in br_transmit_config()
205 bpdu.max_age = br->max_age; in br_transmit_config()
206 bpdu.hello_time = br->hello_time; in br_transmit_config()
207 bpdu.forward_delay = br->forward_delay; in br_transmit_config()
209 if (bpdu.message_age < br->max_age) { in br_transmit_config()
213 if (p->br->stp_enabled == BR_KERNEL_STP) in br_transmit_config()
234 static void br_record_config_timeout_values(struct net_bridge *br, in br_record_config_timeout_values() argument
237 br->max_age = bpdu->max_age; in br_record_config_timeout_values()
238 br->hello_time = bpdu->hello_time; in br_record_config_timeout_values()
239 br->forward_delay = bpdu->forward_delay; in br_record_config_timeout_values()
240 br->topology_change = bpdu->topology_change; in br_record_config_timeout_values()
244 void br_transmit_tcn(struct net_bridge *br) in br_transmit_tcn() argument
248 p = br_get_port(br, br->root_port); in br_transmit_tcn()
252 br_notice(br, "root port %u not found for topology notice\n", in br_transmit_tcn()
253 br->root_port); in br_transmit_tcn()
259 struct net_bridge *br; in br_should_become_designated_port() local
262 br = p->br; in br_should_become_designated_port()
266 if (memcmp(&p->designated_root, &br->designated_root, 8)) in br_should_become_designated_port()
269 if (br->root_path_cost < p->designated_cost) in br_should_become_designated_port()
271 else if (br->root_path_cost > p->designated_cost) in br_should_become_designated_port()
274 t = memcmp(&br->bridge_id, &p->designated_bridge, 8); in br_should_become_designated_port()
287 static void br_designated_port_selection(struct net_bridge *br) in br_designated_port_selection() argument
291 list_for_each_entry(p, &br->port_list, list) { in br_designated_port_selection()
322 if (memcmp(&bpdu->bridge_id, &p->br->bridge_id, 8)) in br_supersedes_port_info()
332 static void br_topology_change_acknowledged(struct net_bridge *br) in br_topology_change_acknowledged() argument
334 br->topology_change_detected = 0; in br_topology_change_acknowledged()
335 del_timer(&br->tcn_timer); in br_topology_change_acknowledged()
339 void br_topology_change_detection(struct net_bridge *br) in br_topology_change_detection() argument
341 int isroot = br_is_root_bridge(br); in br_topology_change_detection()
343 if (br->stp_enabled != BR_KERNEL_STP) in br_topology_change_detection()
346 br_info(br, "topology change detected, %s\n", in br_topology_change_detection()
350 br->topology_change = 1; in br_topology_change_detection()
351 mod_timer(&br->topology_change_timer, jiffies in br_topology_change_detection()
352 + br->bridge_forward_delay + br->bridge_max_age); in br_topology_change_detection()
353 } else if (!br->topology_change_detected) { in br_topology_change_detection()
354 br_transmit_tcn(br); in br_topology_change_detection()
355 mod_timer(&br->tcn_timer, jiffies + br->bridge_hello_time); in br_topology_change_detection()
358 br->topology_change_detected = 1; in br_topology_change_detection()
362 void br_config_bpdu_generation(struct net_bridge *br) in br_config_bpdu_generation() argument
366 list_for_each_entry(p, &br->port_list, list) { in br_config_bpdu_generation()
380 void br_configuration_update(struct net_bridge *br) in br_configuration_update() argument
382 br_root_selection(br); in br_configuration_update()
383 br_designated_port_selection(br); in br_configuration_update()
389 struct net_bridge *br; in br_become_designated_port() local
391 br = p->br; in br_become_designated_port()
392 p->designated_root = br->designated_root; in br_become_designated_port()
393 p->designated_cost = br->root_path_cost; in br_become_designated_port()
394 p->designated_bridge = br->bridge_id; in br_become_designated_port()
406 br_topology_change_detection(p->br); in br_make_blocking()
419 struct net_bridge *br = p->br; in br_make_forwarding() local
424 if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) { in br_make_forwarding()
426 br_topology_change_detection(br); in br_make_forwarding()
428 } else if (br->stp_enabled == BR_KERNEL_STP) in br_make_forwarding()
436 if (br->forward_delay != 0) in br_make_forwarding()
437 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_make_forwarding()
441 void br_port_state_selection(struct net_bridge *br) in br_port_state_selection() argument
446 list_for_each_entry(p, &br->port_list, list) { in br_port_state_selection()
451 if (br->stp_enabled != BR_USER_STP) { in br_port_state_selection()
452 if (p->port_no == br->root_port) { in br_port_state_selection()
477 netif_carrier_off(br->dev); in br_port_state_selection()
479 netif_carrier_on(br->dev); in br_port_state_selection()
493 struct net_bridge *br; in br_received_config_bpdu() local
496 br = p->br; in br_received_config_bpdu()
497 was_root = br_is_root_bridge(br); in br_received_config_bpdu()
501 br_configuration_update(br); in br_received_config_bpdu()
502 br_port_state_selection(br); in br_received_config_bpdu()
504 if (!br_is_root_bridge(br) && was_root) { in br_received_config_bpdu()
505 del_timer(&br->hello_timer); in br_received_config_bpdu()
506 if (br->topology_change_detected) { in br_received_config_bpdu()
507 del_timer(&br->topology_change_timer); in br_received_config_bpdu()
508 br_transmit_tcn(br); in br_received_config_bpdu()
510 mod_timer(&br->tcn_timer, in br_received_config_bpdu()
511 jiffies + br->bridge_hello_time); in br_received_config_bpdu()
515 if (p->port_no == br->root_port) { in br_received_config_bpdu()
516 br_record_config_timeout_values(br, bpdu); in br_received_config_bpdu()
517 br_config_bpdu_generation(br); in br_received_config_bpdu()
519 br_topology_change_acknowledged(br); in br_received_config_bpdu()
530 br_info(p->br, "port %u(%s) received tcn bpdu\n", in br_received_tcn_bpdu()
533 br_topology_change_detection(p->br); in br_received_tcn_bpdu()
539 int br_set_hello_time(struct net_bridge *br, unsigned long val) in br_set_hello_time() argument
546 spin_lock_bh(&br->lock); in br_set_hello_time()
547 br->bridge_hello_time = t; in br_set_hello_time()
548 if (br_is_root_bridge(br)) in br_set_hello_time()
549 br->hello_time = br->bridge_hello_time; in br_set_hello_time()
550 spin_unlock_bh(&br->lock); in br_set_hello_time()
554 int br_set_max_age(struct net_bridge *br, unsigned long val) in br_set_max_age() argument
561 spin_lock_bh(&br->lock); in br_set_max_age()
562 br->bridge_max_age = t; in br_set_max_age()
563 if (br_is_root_bridge(br)) in br_set_max_age()
564 br->max_age = br->bridge_max_age; in br_set_max_age()
565 spin_unlock_bh(&br->lock); in br_set_max_age()
578 int br_set_ageing_time(struct net_bridge *br, u32 ageing_time) in br_set_ageing_time() argument
588 err = switchdev_port_attr_set(br->dev, &attr); in br_set_ageing_time()
592 br->ageing_time = t; in br_set_ageing_time()
593 mod_timer(&br->gc_timer, jiffies); in br_set_ageing_time()
598 void __br_set_forward_delay(struct net_bridge *br, unsigned long t) in __br_set_forward_delay() argument
600 br->bridge_forward_delay = t; in __br_set_forward_delay()
601 if (br_is_root_bridge(br)) in __br_set_forward_delay()
602 br->forward_delay = br->bridge_forward_delay; in __br_set_forward_delay()
605 int br_set_forward_delay(struct net_bridge *br, unsigned long val) in br_set_forward_delay() argument
610 spin_lock_bh(&br->lock); in br_set_forward_delay()
611 if (br->stp_enabled != BR_NO_STP && in br_set_forward_delay()
615 __br_set_forward_delay(br, t); in br_set_forward_delay()
619 spin_unlock_bh(&br->lock); in br_set_forward_delay()