Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *	Spanning tree protocol; generic parts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *	Linux ethernet bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *	Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *	Lennert Buytenhek		<buytenh@gnu.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/rculist.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <net/switchdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "br_private.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "br_private_stp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) /* since time values in bpdu are in jiffies and then scaled (1/256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * before sending, make sure that is at least one STP tick.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define MESSAGE_AGE_INCR	((HZ / 256) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) static const char *const br_port_state_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	[BR_STATE_DISABLED] = "disabled",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	[BR_STATE_LISTENING] = "listening",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	[BR_STATE_LEARNING] = "learning",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	[BR_STATE_FORWARDING] = "forwarding",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	[BR_STATE_BLOCKING] = "blocking",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) void br_set_state(struct net_bridge_port *p, unsigned int state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct switchdev_attr attr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		.orig_dev = p->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		.id = SWITCHDEV_ATTR_ID_PORT_STP_STATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		.flags = SWITCHDEV_F_DEFER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		.u.stp_state = state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	/* Don't change the state of the ports if they are driven by a different
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	 * protocol.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	if (p->flags & BR_MRP_AWARE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	p->state = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	err = switchdev_port_attr_set(p->dev, &attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	if (err && err != -EOPNOTSUPP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		br_warn(p->br, "error setting offload STP state on port %u(%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 				(unsigned int) p->port_no, p->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		br_info(p->br, "port %u(%s) entered %s state\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 				(unsigned int) p->port_no, p->dev->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 				br_port_state_names[p->state]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	if (p->br->stp_enabled == BR_KERNEL_STP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		switch (p->state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		case BR_STATE_BLOCKING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 			p->stp_xstats.transition_blk++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		case BR_STATE_FORWARDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 			p->stp_xstats.transition_fwd++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	struct net_bridge_port *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	list_for_each_entry_rcu(p, &br->port_list, list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 				lockdep_is_held(&br->lock)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		if (p->port_no == port_no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 			return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) static int br_should_become_root_port(const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 				      u16 root_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	struct net_bridge *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct net_bridge_port *rp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	int t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	br = p->br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	if (p->state == BR_STATE_DISABLED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	    br_is_designated_port(p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	if (memcmp(&br->bridge_id, &p->designated_root, 8) <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (!root_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	rp = br_get_port(br, root_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	t = memcmp(&p->designated_root, &rp->designated_root, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	if (t < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	else if (t > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	if (p->designated_cost + p->path_cost <
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	    rp->designated_cost + rp->path_cost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	else if (p->designated_cost + p->path_cost >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		 rp->designated_cost + rp->path_cost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	t = memcmp(&p->designated_bridge, &rp->designated_bridge, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	if (t < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	else if (t > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	if (p->designated_port < rp->designated_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	else if (p->designated_port > rp->designated_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (p->port_id < rp->port_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static void br_root_port_block(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 			       struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	br_notice(br, "port %u(%s) tried to become root port (blocked)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		  (unsigned int) p->port_no, p->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	br_set_state(p, BR_STATE_LISTENING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	br_ifinfo_notify(RTM_NEWLINK, NULL, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	if (br->forward_delay > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) static void br_root_selection(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	struct net_bridge_port *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	u16 root_port = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	list_for_each_entry(p, &br->port_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		if (!br_should_become_root_port(p, root_port))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		if (p->flags & BR_ROOT_BLOCK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 			br_root_port_block(br, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 			root_port = p->port_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	br->root_port = root_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	if (!root_port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		br->designated_root = br->bridge_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		br->root_path_cost = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		p = br_get_port(br, root_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		br->designated_root = p->designated_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		br->root_path_cost = p->designated_cost + p->path_cost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) void br_become_root_bridge(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	br->max_age = br->bridge_max_age;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	br->hello_time = br->bridge_hello_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	br->forward_delay = br->bridge_forward_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	br_topology_change_detection(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	del_timer(&br->tcn_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	if (br->dev->flags & IFF_UP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		br_config_bpdu_generation(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		mod_timer(&br->hello_timer, jiffies + br->hello_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) void br_transmit_config(struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	struct br_config_bpdu bpdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	struct net_bridge *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	if (timer_pending(&p->hold_timer)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		p->config_pending = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	br = p->br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	bpdu.topology_change = br->topology_change;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	bpdu.topology_change_ack = p->topology_change_ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	bpdu.root = br->designated_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	bpdu.root_path_cost = br->root_path_cost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	bpdu.bridge_id = br->bridge_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	bpdu.port_id = p->port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	if (br_is_root_bridge(br))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		bpdu.message_age = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		struct net_bridge_port *root
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 			= br_get_port(br, br->root_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		bpdu.message_age = (jiffies - root->designated_age)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			+ MESSAGE_AGE_INCR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	bpdu.max_age = br->max_age;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	bpdu.hello_time = br->hello_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	bpdu.forward_delay = br->forward_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	if (bpdu.message_age < br->max_age) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		br_send_config_bpdu(p, &bpdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		p->topology_change_ack = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		p->config_pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		if (p->br->stp_enabled == BR_KERNEL_STP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 			mod_timer(&p->hold_timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 				  round_jiffies(jiffies + BR_HOLD_TIME));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) static void br_record_config_information(struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 					 const struct br_config_bpdu *bpdu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	p->designated_root = bpdu->root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	p->designated_cost = bpdu->root_path_cost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	p->designated_bridge = bpdu->bridge_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	p->designated_port = bpdu->port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	p->designated_age = jiffies - bpdu->message_age;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	mod_timer(&p->message_age_timer, jiffies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		  + (bpdu->max_age - bpdu->message_age));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static void br_record_config_timeout_values(struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 					    const struct br_config_bpdu *bpdu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	br->max_age = bpdu->max_age;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	br->hello_time = bpdu->hello_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	br->forward_delay = bpdu->forward_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	__br_set_topology_change(br, bpdu->topology_change);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) void br_transmit_tcn(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	struct net_bridge_port *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	p = br_get_port(br, br->root_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	if (p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		br_send_tcn_bpdu(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		br_notice(br, "root port %u not found for topology notice\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 			  br->root_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) static int br_should_become_designated_port(const struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	struct net_bridge *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	int t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	br = p->br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	if (br_is_designated_port(p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	if (memcmp(&p->designated_root, &br->designated_root, 8))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	if (br->root_path_cost < p->designated_cost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	else if (br->root_path_cost > p->designated_cost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	t = memcmp(&br->bridge_id, &p->designated_bridge, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	if (t < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	else if (t > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	if (p->port_id < p->designated_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static void br_designated_port_selection(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	struct net_bridge_port *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	list_for_each_entry(p, &br->port_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		if (p->state != BR_STATE_DISABLED &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		    br_should_become_designated_port(p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 			br_become_designated_port(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) static int br_supersedes_port_info(const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 				   const struct br_config_bpdu *bpdu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	int t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	t = memcmp(&bpdu->root, &p->designated_root, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	if (t < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	else if (t > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	if (bpdu->root_path_cost < p->designated_cost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	else if (bpdu->root_path_cost > p->designated_cost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	t = memcmp(&bpdu->bridge_id, &p->designated_bridge, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	if (t < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	else if (t > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	if (memcmp(&bpdu->bridge_id, &p->br->bridge_id, 8))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	if (bpdu->port_id <= p->designated_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) static void br_topology_change_acknowledged(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	br->topology_change_detected = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	del_timer(&br->tcn_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) void br_topology_change_detection(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	int isroot = br_is_root_bridge(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	if (br->stp_enabled != BR_KERNEL_STP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	br_info(br, "topology change detected, %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		isroot ? "propagating" : "sending tcn bpdu");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	if (isroot) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		__br_set_topology_change(br, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		mod_timer(&br->topology_change_timer, jiffies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 			  + br->bridge_forward_delay + br->bridge_max_age);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	} else if (!br->topology_change_detected) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		br_transmit_tcn(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		mod_timer(&br->tcn_timer, jiffies + br->bridge_hello_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	br->topology_change_detected = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) void br_config_bpdu_generation(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	struct net_bridge_port *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	list_for_each_entry(p, &br->port_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		if (p->state != BR_STATE_DISABLED &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		    br_is_designated_port(p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 			br_transmit_config(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) static void br_reply(struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	br_transmit_config(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) void br_configuration_update(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	br_root_selection(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	br_designated_port_selection(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) void br_become_designated_port(struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	struct net_bridge *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	br = p->br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	p->designated_root = br->designated_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	p->designated_cost = br->root_path_cost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	p->designated_bridge = br->bridge_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	p->designated_port = p->port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) static void br_make_blocking(struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	if (p->state != BR_STATE_DISABLED &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	    p->state != BR_STATE_BLOCKING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		if (p->state == BR_STATE_FORWARDING ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		    p->state == BR_STATE_LEARNING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 			br_topology_change_detection(p->br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 		br_set_state(p, BR_STATE_BLOCKING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		br_ifinfo_notify(RTM_NEWLINK, NULL, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		del_timer(&p->forward_delay_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) static void br_make_forwarding(struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	struct net_bridge *br = p->br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	if (p->state != BR_STATE_BLOCKING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	if (br->stp_enabled == BR_NO_STP || br->forward_delay == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		br_set_state(p, BR_STATE_FORWARDING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		br_topology_change_detection(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		del_timer(&p->forward_delay_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	} else if (br->stp_enabled == BR_KERNEL_STP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 		br_set_state(p, BR_STATE_LISTENING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		br_set_state(p, BR_STATE_LEARNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	br_ifinfo_notify(RTM_NEWLINK, NULL, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	if (br->forward_delay != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 		mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) void br_port_state_selection(struct net_bridge *br)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	struct net_bridge_port *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	unsigned int liveports = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	list_for_each_entry(p, &br->port_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 		if (p->state == BR_STATE_DISABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		/* Don't change port states if userspace is handling STP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		if (br->stp_enabled != BR_USER_STP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 			if (p->port_no == br->root_port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 				p->config_pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 				p->topology_change_ack = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 				br_make_forwarding(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 			} else if (br_is_designated_port(p)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 				del_timer(&p->message_age_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 				br_make_forwarding(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 				p->config_pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 				p->topology_change_ack = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 				br_make_blocking(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 		if (p->state != BR_STATE_BLOCKING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 			br_multicast_enable_port(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 		/* Multicast is not disabled for the port when it goes in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 		 * blocking state because the timers will expire and stop by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 		 * themselves without sending more queries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 		if (p->state == BR_STATE_FORWARDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 			++liveports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	if (liveports == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 		netif_carrier_off(br->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 		netif_carrier_on(br->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) static void br_topology_change_acknowledge(struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	p->topology_change_ack = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	br_transmit_config(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) void br_received_config_bpdu(struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 			     const struct br_config_bpdu *bpdu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	struct net_bridge *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	int was_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	p->stp_xstats.rx_bpdu++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	br = p->br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	was_root = br_is_root_bridge(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	if (br_supersedes_port_info(p, bpdu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		br_record_config_information(p, bpdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		br_configuration_update(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		br_port_state_selection(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 		if (!br_is_root_bridge(br) && was_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 			del_timer(&br->hello_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 			if (br->topology_change_detected) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 				del_timer(&br->topology_change_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 				br_transmit_tcn(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 				mod_timer(&br->tcn_timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 					  jiffies + br->bridge_hello_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 		if (p->port_no == br->root_port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 			br_record_config_timeout_values(br, bpdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 			br_config_bpdu_generation(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 			if (bpdu->topology_change_ack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 				br_topology_change_acknowledged(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 	} else if (br_is_designated_port(p)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 		br_reply(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) void br_received_tcn_bpdu(struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	p->stp_xstats.rx_tcn++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	if (br_is_designated_port(p)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 		br_info(p->br, "port %u(%s) received tcn bpdu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 			(unsigned int) p->port_no, p->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 		br_topology_change_detection(p->br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 		br_topology_change_acknowledge(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) /* Change bridge STP parameter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) int br_set_hello_time(struct net_bridge *br, unsigned long val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	unsigned long t = clock_t_to_jiffies(val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	if (t < BR_MIN_HELLO_TIME || t > BR_MAX_HELLO_TIME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 		return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	spin_lock_bh(&br->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	br->bridge_hello_time = t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	if (br_is_root_bridge(br))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 		br->hello_time = br->bridge_hello_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	spin_unlock_bh(&br->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) int br_set_max_age(struct net_bridge *br, unsigned long val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	unsigned long t = clock_t_to_jiffies(val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	if (t < BR_MIN_MAX_AGE || t > BR_MAX_MAX_AGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 		return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 	spin_lock_bh(&br->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	br->bridge_max_age = t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 	if (br_is_root_bridge(br))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 		br->max_age = br->bridge_max_age;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	spin_unlock_bh(&br->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) int __set_ageing_time(struct net_device *dev, unsigned long t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	struct switchdev_attr attr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 		.orig_dev = dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 		.id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 		.flags = SWITCHDEV_F_SKIP_EOPNOTSUPP | SWITCHDEV_F_DEFER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 		.u.ageing_time = jiffies_to_clock_t(t),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	err = switchdev_port_attr_set(dev, &attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	if (err && err != -EOPNOTSUPP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) /* Set time interval that dynamic forwarding entries live
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)  * For pure software bridge, allow values outside the 802.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)  * standard specification for special cases:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)  *  0 - entry never ages (all permanant)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)  *  1 - entry disappears (no persistance)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)  * Offloaded switch entries maybe more restrictive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) int br_set_ageing_time(struct net_bridge *br, clock_t ageing_time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	unsigned long t = clock_t_to_jiffies(ageing_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 	err = __set_ageing_time(br->dev, t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	spin_lock_bh(&br->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 	br->bridge_ageing_time = t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	br->ageing_time = t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 	spin_unlock_bh(&br->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 	mod_delayed_work(system_long_wq, &br->gc_work, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) void __br_set_topology_change(struct net_bridge *br, unsigned char val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 	unsigned long t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 	if (br->stp_enabled == BR_KERNEL_STP && br->topology_change != val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 		/* On topology change, set the bridge ageing time to twice the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 		 * forward delay. Otherwise, restore its default ageing time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 		if (val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 			t = 2 * br->forward_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 			br_debug(br, "decreasing ageing time to %lu\n", t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 			t = br->bridge_ageing_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 			br_debug(br, "restoring ageing time to %lu\n", t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 		err = __set_ageing_time(br->dev, t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 			br_warn(br, "error offloading ageing time\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 			br->ageing_time = t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	br->topology_change = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) void __br_set_forward_delay(struct net_bridge *br, unsigned long t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	br->bridge_forward_delay = t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	if (br_is_root_bridge(br))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 		br->forward_delay = br->bridge_forward_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) int br_set_forward_delay(struct net_bridge *br, unsigned long val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 	unsigned long t = clock_t_to_jiffies(val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 	int err = -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 	spin_lock_bh(&br->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	if (br->stp_enabled != BR_NO_STP &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 	    (t < BR_MIN_FORWARD_DELAY || t > BR_MAX_FORWARD_DELAY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 		goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	__br_set_forward_delay(br, t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 	spin_unlock_bh(&br->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) }