Lines Matching refs:br
34 br_info(p->br, "port %u(%s) entered %s state\n", in br_log_state()
40 struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no) in br_get_port() argument
44 list_for_each_entry_rcu(p, &br->port_list, list) { in br_get_port()
56 struct net_bridge *br; in br_should_become_root_port() local
60 br = p->br; in br_should_become_root_port()
65 if (memcmp(&br->bridge_id, &p->designated_root, 8) <= 0) in br_should_become_root_port()
71 rp = br_get_port(br, root_port); in br_should_become_root_port()
103 static void br_root_port_block(const struct net_bridge *br, in br_root_port_block() argument
107 br_notice(br, "port %u(%s) tried to become root port (blocked)", in br_root_port_block()
114 if (br->forward_delay > 0) in br_root_port_block()
115 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_root_port_block()
119 static void br_root_selection(struct net_bridge *br) in br_root_selection() argument
124 list_for_each_entry(p, &br->port_list, list) { in br_root_selection()
129 br_root_port_block(br, p); in br_root_selection()
134 br->root_port = root_port; in br_root_selection()
137 br->designated_root = br->bridge_id; in br_root_selection()
138 br->root_path_cost = 0; in br_root_selection()
140 p = br_get_port(br, root_port); in br_root_selection()
141 br->designated_root = p->designated_root; in br_root_selection()
142 br->root_path_cost = p->designated_cost + p->path_cost; in br_root_selection()
147 void br_become_root_bridge(struct net_bridge *br) in br_become_root_bridge() argument
149 br->max_age = br->bridge_max_age; in br_become_root_bridge()
150 br->hello_time = br->bridge_hello_time; in br_become_root_bridge()
151 br->forward_delay = br->bridge_forward_delay; in br_become_root_bridge()
152 br_topology_change_detection(br); in br_become_root_bridge()
153 del_timer(&br->tcn_timer); in br_become_root_bridge()
155 if (br->dev->flags & IFF_UP) { in br_become_root_bridge()
156 br_config_bpdu_generation(br); in br_become_root_bridge()
157 mod_timer(&br->hello_timer, jiffies + br->hello_time); in br_become_root_bridge()
165 struct net_bridge *br; in br_transmit_config() local
172 br = p->br; in br_transmit_config()
174 bpdu.topology_change = br->topology_change; in br_transmit_config()
176 bpdu.root = br->designated_root; in br_transmit_config()
177 bpdu.root_path_cost = br->root_path_cost; in br_transmit_config()
178 bpdu.bridge_id = br->bridge_id; in br_transmit_config()
180 if (br_is_root_bridge(br)) in br_transmit_config()
184 = br_get_port(br, br->root_port); in br_transmit_config()
188 bpdu.max_age = br->max_age; in br_transmit_config()
189 bpdu.hello_time = br->hello_time; in br_transmit_config()
190 bpdu.forward_delay = br->forward_delay; in br_transmit_config()
192 if (bpdu.message_age < br->max_age) { in br_transmit_config()
212 + (p->br->max_age - bpdu->message_age)); in br_record_config_information()
216 static void br_record_config_timeout_values(struct net_bridge *br, in br_record_config_timeout_values() argument
219 br->max_age = bpdu->max_age; in br_record_config_timeout_values()
220 br->hello_time = bpdu->hello_time; in br_record_config_timeout_values()
221 br->forward_delay = bpdu->forward_delay; in br_record_config_timeout_values()
222 br->topology_change = bpdu->topology_change; in br_record_config_timeout_values()
226 void br_transmit_tcn(struct net_bridge *br) in br_transmit_tcn() argument
230 p = br_get_port(br, br->root_port); in br_transmit_tcn()
234 br_notice(br, "root port %u not found for topology notice\n", in br_transmit_tcn()
235 br->root_port); in br_transmit_tcn()
241 struct net_bridge *br; in br_should_become_designated_port() local
244 br = p->br; in br_should_become_designated_port()
248 if (memcmp(&p->designated_root, &br->designated_root, 8)) in br_should_become_designated_port()
251 if (br->root_path_cost < p->designated_cost) in br_should_become_designated_port()
253 else if (br->root_path_cost > p->designated_cost) in br_should_become_designated_port()
256 t = memcmp(&br->bridge_id, &p->designated_bridge, 8); in br_should_become_designated_port()
269 static void br_designated_port_selection(struct net_bridge *br) in br_designated_port_selection() argument
273 list_for_each_entry(p, &br->port_list, list) { in br_designated_port_selection()
304 if (memcmp(&bpdu->bridge_id, &p->br->bridge_id, 8)) in br_supersedes_port_info()
314 static void br_topology_change_acknowledged(struct net_bridge *br) in br_topology_change_acknowledged() argument
316 br->topology_change_detected = 0; in br_topology_change_acknowledged()
317 del_timer(&br->tcn_timer); in br_topology_change_acknowledged()
321 void br_topology_change_detection(struct net_bridge *br) in br_topology_change_detection() argument
323 int isroot = br_is_root_bridge(br); in br_topology_change_detection()
325 if (br->stp_enabled != BR_KERNEL_STP) in br_topology_change_detection()
328 br_info(br, "topology change detected, %s\n", in br_topology_change_detection()
332 br->topology_change = 1; in br_topology_change_detection()
333 mod_timer(&br->topology_change_timer, jiffies in br_topology_change_detection()
334 + br->bridge_forward_delay + br->bridge_max_age); in br_topology_change_detection()
335 } else if (!br->topology_change_detected) { in br_topology_change_detection()
336 br_transmit_tcn(br); in br_topology_change_detection()
337 mod_timer(&br->tcn_timer, jiffies + br->bridge_hello_time); in br_topology_change_detection()
340 br->topology_change_detected = 1; in br_topology_change_detection()
344 void br_config_bpdu_generation(struct net_bridge *br) in br_config_bpdu_generation() argument
348 list_for_each_entry(p, &br->port_list, list) { in br_config_bpdu_generation()
362 void br_configuration_update(struct net_bridge *br) in br_configuration_update() argument
364 br_root_selection(br); in br_configuration_update()
365 br_designated_port_selection(br); in br_configuration_update()
371 struct net_bridge *br; in br_become_designated_port() local
373 br = p->br; in br_become_designated_port()
374 p->designated_root = br->designated_root; in br_become_designated_port()
375 p->designated_cost = br->root_path_cost; in br_become_designated_port()
376 p->designated_bridge = br->bridge_id; in br_become_designated_port()
388 br_topology_change_detection(p->br); in br_make_blocking()
401 struct net_bridge *br = p->br; in br_make_forwarding() local
406 if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) { in br_make_forwarding()
408 br_topology_change_detection(br); in br_make_forwarding()
410 } else if (br->stp_enabled == BR_KERNEL_STP) in br_make_forwarding()
419 if (br->forward_delay != 0) in br_make_forwarding()
420 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_make_forwarding()
424 void br_port_state_selection(struct net_bridge *br) in br_port_state_selection() argument
429 list_for_each_entry(p, &br->port_list, list) { in br_port_state_selection()
434 if (br->stp_enabled != BR_USER_STP) { in br_port_state_selection()
435 if (p->port_no == br->root_port) { in br_port_state_selection()
454 netif_carrier_off(br->dev); in br_port_state_selection()
456 netif_carrier_on(br->dev); in br_port_state_selection()
470 struct net_bridge *br; in br_received_config_bpdu() local
473 br = p->br; in br_received_config_bpdu()
474 was_root = br_is_root_bridge(br); in br_received_config_bpdu()
478 br_configuration_update(br); in br_received_config_bpdu()
479 br_port_state_selection(br); in br_received_config_bpdu()
481 if (!br_is_root_bridge(br) && was_root) { in br_received_config_bpdu()
482 del_timer(&br->hello_timer); in br_received_config_bpdu()
483 if (br->topology_change_detected) { in br_received_config_bpdu()
484 del_timer(&br->topology_change_timer); in br_received_config_bpdu()
485 br_transmit_tcn(br); in br_received_config_bpdu()
487 mod_timer(&br->tcn_timer, in br_received_config_bpdu()
488 jiffies + br->bridge_hello_time); in br_received_config_bpdu()
492 if (p->port_no == br->root_port) { in br_received_config_bpdu()
493 br_record_config_timeout_values(br, bpdu); in br_received_config_bpdu()
494 br_config_bpdu_generation(br); in br_received_config_bpdu()
496 br_topology_change_acknowledged(br); in br_received_config_bpdu()
507 br_info(p->br, "port %u(%s) received tcn bpdu\n", in br_received_tcn_bpdu()
510 br_topology_change_detection(p->br); in br_received_tcn_bpdu()
516 int br_set_hello_time(struct net_bridge *br, unsigned long val) in br_set_hello_time() argument
523 spin_lock_bh(&br->lock); in br_set_hello_time()
524 br->bridge_hello_time = t; in br_set_hello_time()
525 if (br_is_root_bridge(br)) in br_set_hello_time()
526 br->hello_time = br->bridge_hello_time; in br_set_hello_time()
527 spin_unlock_bh(&br->lock); in br_set_hello_time()
531 int br_set_max_age(struct net_bridge *br, unsigned long val) in br_set_max_age() argument
538 spin_lock_bh(&br->lock); in br_set_max_age()
539 br->bridge_max_age = t; in br_set_max_age()
540 if (br_is_root_bridge(br)) in br_set_max_age()
541 br->max_age = br->bridge_max_age; in br_set_max_age()
542 spin_unlock_bh(&br->lock); in br_set_max_age()
547 int br_set_forward_delay(struct net_bridge *br, unsigned long val) in br_set_forward_delay() argument
551 if (br->stp_enabled != BR_NO_STP && in br_set_forward_delay()
555 spin_lock_bh(&br->lock); in br_set_forward_delay()
556 br->bridge_forward_delay = t; in br_set_forward_delay()
557 if (br_is_root_bridge(br)) in br_set_forward_delay()
558 br->forward_delay = br->bridge_forward_delay; in br_set_forward_delay()
559 spin_unlock_bh(&br->lock); in br_set_forward_delay()