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