xref: /linux/net/bridge/br_stp_if.c (revision ac528649f7c63bc233cc0d33cff11f767cc666e3)
12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  *	Spanning tree protocol; interface code
41da177e4SLinus Torvalds  *	Linux ethernet bridge
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  *	Authors:
71da177e4SLinus Torvalds  *	Lennert Buytenhek		<buytenh@gnu.org>
81da177e4SLinus Torvalds  */
91da177e4SLinus Torvalds 
101da177e4SLinus Torvalds #include <linux/kernel.h>
1179bb1ee4SPaul Gortmaker #include <linux/kmod.h>
126ede2463SStephen Hemminger #include <linux/etherdevice.h>
1311dc1f36SStephen Hemminger #include <linux/rtnetlink.h>
146ac311aeSElad Raz #include <net/switchdev.h>
151da177e4SLinus Torvalds 
161da177e4SLinus Torvalds #include "br_private.h"
171da177e4SLinus Torvalds #include "br_private_stp.h"
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds 
201da177e4SLinus Torvalds /* Port id is composed of priority and port number.
2114f98f25Sstephen hemminger  * NB: some bits of priority are dropped to
221da177e4SLinus Torvalds  *     make room for more ports.
231da177e4SLinus Torvalds  */
br_make_port_id(__u8 priority,__u16 port_no)241da177e4SLinus Torvalds static inline port_id br_make_port_id(__u8 priority, __u16 port_no)
251da177e4SLinus Torvalds {
261da177e4SLinus Torvalds 	return ((u16)priority << BR_PORT_BITS)
271da177e4SLinus Torvalds 		| (port_no & ((1<<BR_PORT_BITS)-1));
281da177e4SLinus Torvalds }
291da177e4SLinus Torvalds 
3014f98f25Sstephen hemminger #define BR_MAX_PORT_PRIORITY ((u16)~0 >> BR_PORT_BITS)
3114f98f25Sstephen hemminger 
321da177e4SLinus Torvalds /* called under bridge lock */
br_init_port(struct net_bridge_port * p)331da177e4SLinus Torvalds void br_init_port(struct net_bridge_port *p)
341da177e4SLinus Torvalds {
356ac311aeSElad Raz 	int err;
366ac311aeSElad Raz 
371da177e4SLinus Torvalds 	p->port_id = br_make_port_id(p->priority, p->port_no);
381da177e4SLinus Torvalds 	br_become_designated_port(p);
39775dd692SFlorian Fainelli 	br_set_state(p, BR_STATE_BLOCKING);
401da177e4SLinus Torvalds 	p->topology_change_ack = 0;
411da177e4SLinus Torvalds 	p->config_pending = 0;
426ac311aeSElad Raz 
4382dd4332SVivien Didelot 	err = __set_ageing_time(p->dev, p->br->ageing_time);
4482dd4332SVivien Didelot 	if (err)
4582dd4332SVivien Didelot 		netdev_err(p->dev, "failed to offload ageing time\n");
461da177e4SLinus Torvalds }
471da177e4SLinus Torvalds 
48dba479f3SVivien Didelot /* NO locks held */
br_stp_enable_bridge(struct net_bridge * br)491da177e4SLinus Torvalds void br_stp_enable_bridge(struct net_bridge *br)
501da177e4SLinus Torvalds {
511da177e4SLinus Torvalds 	struct net_bridge_port *p;
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds 	spin_lock_bh(&br->lock);
5476b91c32SNikolay Aleksandrov 	if (br->stp_enabled == BR_KERNEL_STP)
551da177e4SLinus Torvalds 		mod_timer(&br->hello_timer, jiffies + br->hello_time);
56f7cdee8aSNikolay Aleksandrov 	mod_delayed_work(system_long_wq, &br->gc_work, HZ / 10);
571da177e4SLinus Torvalds 
581da177e4SLinus Torvalds 	br_config_bpdu_generation(br);
591da177e4SLinus Torvalds 
601da177e4SLinus Torvalds 	list_for_each_entry(p, &br->port_list, list) {
61576eb625Sstephen hemminger 		if (netif_running(p->dev) && netif_oper_up(p->dev))
621da177e4SLinus Torvalds 			br_stp_enable_port(p);
631da177e4SLinus Torvalds 
641da177e4SLinus Torvalds 	}
651da177e4SLinus Torvalds 	spin_unlock_bh(&br->lock);
661da177e4SLinus Torvalds }
671da177e4SLinus Torvalds 
681da177e4SLinus Torvalds /* NO locks held */
br_stp_disable_bridge(struct net_bridge * br)691da177e4SLinus Torvalds void br_stp_disable_bridge(struct net_bridge *br)
701da177e4SLinus Torvalds {
711da177e4SLinus Torvalds 	struct net_bridge_port *p;
721da177e4SLinus Torvalds 
7378872ccbSAdrian Drzewiecki 	spin_lock_bh(&br->lock);
741da177e4SLinus Torvalds 	list_for_each_entry(p, &br->port_list, list) {
751da177e4SLinus Torvalds 		if (p->state != BR_STATE_DISABLED)
761da177e4SLinus Torvalds 			br_stp_disable_port(p);
771da177e4SLinus Torvalds 
781da177e4SLinus Torvalds 	}
791da177e4SLinus Torvalds 
808384b5f5SVivien Didelot 	__br_set_topology_change(br, 0);
811da177e4SLinus Torvalds 	br->topology_change_detected = 0;
8278872ccbSAdrian Drzewiecki 	spin_unlock_bh(&br->lock);
831da177e4SLinus Torvalds 
841da177e4SLinus Torvalds 	del_timer_sync(&br->hello_timer);
851da177e4SLinus Torvalds 	del_timer_sync(&br->topology_change_timer);
861da177e4SLinus Torvalds 	del_timer_sync(&br->tcn_timer);
87f7cdee8aSNikolay Aleksandrov 	cancel_delayed_work_sync(&br->gc_work);
881da177e4SLinus Torvalds }
891da177e4SLinus Torvalds 
901da177e4SLinus Torvalds /* called under bridge lock */
br_stp_enable_port(struct net_bridge_port * p)911da177e4SLinus Torvalds void br_stp_enable_port(struct net_bridge_port *p)
921da177e4SLinus Torvalds {
931da177e4SLinus Torvalds 	br_init_port(p);
941da177e4SLinus Torvalds 	br_port_state_selection(p->br);
9592899063SNikolay Aleksandrov 	br_ifinfo_notify(RTM_NEWLINK, NULL, p);
961da177e4SLinus Torvalds }
971da177e4SLinus Torvalds 
981da177e4SLinus Torvalds /* called under bridge lock */
br_stp_disable_port(struct net_bridge_port * p)991da177e4SLinus Torvalds void br_stp_disable_port(struct net_bridge_port *p)
1001da177e4SLinus Torvalds {
10128a16c97Sstephen hemminger 	struct net_bridge *br = p->br;
1021da177e4SLinus Torvalds 	int wasroot;
1031da177e4SLinus Torvalds 
1041da177e4SLinus Torvalds 	wasroot = br_is_root_bridge(br);
1051da177e4SLinus Torvalds 	br_become_designated_port(p);
106775dd692SFlorian Fainelli 	br_set_state(p, BR_STATE_DISABLED);
1071da177e4SLinus Torvalds 	p->topology_change_ack = 0;
1081da177e4SLinus Torvalds 	p->config_pending = 0;
1091da177e4SLinus Torvalds 
11092899063SNikolay Aleksandrov 	br_ifinfo_notify(RTM_NEWLINK, NULL, p);
1114ecb961cSstephen hemminger 
1121da177e4SLinus Torvalds 	del_timer(&p->message_age_timer);
1131da177e4SLinus Torvalds 	del_timer(&p->forward_delay_timer);
1141da177e4SLinus Torvalds 	del_timer(&p->hold_timer);
1151da177e4SLinus Torvalds 
1168dc35020SNikolay Aleksandrov 	if (!rcu_access_pointer(p->backup_port))
1171ea2d020SNikolay Aleksandrov 		br_fdb_delete_by_port(br, p, 0, 0);
1183fe2d7c7SHerbert Xu 	br_multicast_disable_port(p);
1191a620698SStephen Hemminger 
1201da177e4SLinus Torvalds 	br_configuration_update(br);
1211da177e4SLinus Torvalds 
1221da177e4SLinus Torvalds 	br_port_state_selection(br);
1231da177e4SLinus Torvalds 
1241da177e4SLinus Torvalds 	if (br_is_root_bridge(br) && !wasroot)
1251da177e4SLinus Torvalds 		br_become_root_bridge(br);
1261da177e4SLinus Torvalds }
1271da177e4SLinus Torvalds 
br_stp_call_user(struct net_bridge * br,char * arg)12830843315SVivien Didelot static int br_stp_call_user(struct net_bridge *br, char *arg)
12930843315SVivien Didelot {
13030843315SVivien Didelot 	char *argv[] = { BR_STP_PROG, br->dev->name, arg, NULL };
13130843315SVivien Didelot 	char *envp[] = { NULL };
13230843315SVivien Didelot 	int rc;
13330843315SVivien Didelot 
13430843315SVivien Didelot 	/* call userspace STP and report program errors */
13530843315SVivien Didelot 	rc = call_usermodehelper(BR_STP_PROG, argv, envp, UMH_WAIT_PROC);
13630843315SVivien Didelot 	if (rc > 0) {
13730843315SVivien Didelot 		if (rc & 0xff)
13830843315SVivien Didelot 			br_debug(br, BR_STP_PROG " received signal %d\n",
13930843315SVivien Didelot 				 rc & 0x7f);
14030843315SVivien Didelot 		else
14130843315SVivien Didelot 			br_debug(br, BR_STP_PROG " exited with code %d\n",
14230843315SVivien Didelot 				 (rc >> 8) & 0xff);
14330843315SVivien Didelot 	}
14430843315SVivien Didelot 
14530843315SVivien Didelot 	return rc;
14630843315SVivien Didelot }
14730843315SVivien Didelot 
br_stp_start(struct net_bridge * br)1489cde0708SStephen Hemminger static void br_stp_start(struct net_bridge *br)
1499cde0708SStephen Hemminger {
15030843315SVivien Didelot 	int err = -ENOENT;
1519cde0708SStephen Hemminger 
152ff621985SHannes Frederic Sowa 	if (net_eq(dev_net(br->dev), &init_net))
15330843315SVivien Didelot 		err = br_stp_call_user(br, "start");
15430843315SVivien Didelot 
15530843315SVivien Didelot 	if (err && err != -ENOENT)
15630843315SVivien Didelot 		br_err(br, "failed to start userspace STP (%d)\n", err);
157be4f154dSHerbert Xu 
158be4f154dSHerbert Xu 	spin_lock_bh(&br->lock);
159be4f154dSHerbert Xu 
160be4f154dSHerbert Xu 	if (br->bridge_forward_delay < BR_MIN_FORWARD_DELAY)
161be4f154dSHerbert Xu 		__br_set_forward_delay(br, BR_MIN_FORWARD_DELAY);
1624b6c7879SVlad Yasevich 	else if (br->bridge_forward_delay > BR_MAX_FORWARD_DELAY)
163be4f154dSHerbert Xu 		__br_set_forward_delay(br, BR_MAX_FORWARD_DELAY);
164be4f154dSHerbert Xu 
16530843315SVivien Didelot 	if (!err) {
1669cde0708SStephen Hemminger 		br->stp_enabled = BR_USER_STP;
16728a16c97Sstephen hemminger 		br_debug(br, "userspace STP started\n");
1689cde0708SStephen Hemminger 	} else {
1699cde0708SStephen Hemminger 		br->stp_enabled = BR_KERNEL_STP;
17028a16c97Sstephen hemminger 		br_debug(br, "using kernel STP\n");
1719cde0708SStephen Hemminger 
1729cde0708SStephen Hemminger 		/* To start timers on any ports left in blocking */
173aeb07324SNikolay Aleksandrov 		if (br->dev->flags & IFF_UP)
1746d18c732SXin Long 			mod_timer(&br->hello_timer, jiffies + br->hello_time);
1759cde0708SStephen Hemminger 		br_port_state_selection(br);
1769cde0708SStephen Hemminger 	}
177be4f154dSHerbert Xu 
178be4f154dSHerbert Xu 	spin_unlock_bh(&br->lock);
1799cde0708SStephen Hemminger }
1809cde0708SStephen Hemminger 
br_stp_stop(struct net_bridge * br)1819cde0708SStephen Hemminger static void br_stp_stop(struct net_bridge *br)
1829cde0708SStephen Hemminger {
18330843315SVivien Didelot 	int err;
1849cde0708SStephen Hemminger 
1859cde0708SStephen Hemminger 	if (br->stp_enabled == BR_USER_STP) {
18630843315SVivien Didelot 		err = br_stp_call_user(br, "stop");
18730843315SVivien Didelot 		if (err)
18830843315SVivien Didelot 			br_err(br, "failed to stop userspace STP (%d)\n", err);
1899cde0708SStephen Hemminger 
1909cde0708SStephen Hemminger 		/* To start timers on any ports left in blocking */
1919cde0708SStephen Hemminger 		spin_lock_bh(&br->lock);
1929cde0708SStephen Hemminger 		br_port_state_selection(br);
1939cde0708SStephen Hemminger 		spin_unlock_bh(&br->lock);
1949cde0708SStephen Hemminger 	}
1959cde0708SStephen Hemminger 
1969cde0708SStephen Hemminger 	br->stp_enabled = BR_NO_STP;
1979cde0708SStephen Hemminger }
1989cde0708SStephen Hemminger 
br_stp_set_enabled(struct net_bridge * br,unsigned long val,struct netlink_ext_ack * extack)199419dba8aSHoratiu Vultur int br_stp_set_enabled(struct net_bridge *br, unsigned long val,
200419dba8aSHoratiu Vultur 		       struct netlink_ext_ack *extack)
2019cde0708SStephen Hemminger {
2029cde0708SStephen Hemminger 	ASSERT_RTNL();
2039cde0708SStephen Hemminger 
204419dba8aSHoratiu Vultur 	if (br_mrp_enabled(br)) {
205419dba8aSHoratiu Vultur 		NL_SET_ERR_MSG_MOD(extack,
206c75a33c8SJacob Keller 				   "STP can't be enabled if MRP is already enabled");
207419dba8aSHoratiu Vultur 		return -EINVAL;
208419dba8aSHoratiu Vultur 	}
209419dba8aSHoratiu Vultur 
2109cde0708SStephen Hemminger 	if (val) {
2119cde0708SStephen Hemminger 		if (br->stp_enabled == BR_NO_STP)
2129cde0708SStephen Hemminger 			br_stp_start(br);
2139cde0708SStephen Hemminger 	} else {
2149cde0708SStephen Hemminger 		if (br->stp_enabled != BR_NO_STP)
2159cde0708SStephen Hemminger 			br_stp_stop(br);
2169cde0708SStephen Hemminger 	}
217419dba8aSHoratiu Vultur 
218419dba8aSHoratiu Vultur 	return 0;
2199cde0708SStephen Hemminger }
2209cde0708SStephen Hemminger 
2211da177e4SLinus Torvalds /* called under bridge lock */
br_stp_change_bridge_id(struct net_bridge * br,const unsigned char * addr)2224505a3efSStephen Hemminger void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr)
2231da177e4SLinus Torvalds {
2249a7b6ef9SJoe Perches 	/* should be aligned on 2 bytes for ether_addr_equal() */
22519bb3506SEvgeny Kravtsunov 	unsigned short oldaddr_aligned[ETH_ALEN >> 1];
22619bb3506SEvgeny Kravtsunov 	unsigned char *oldaddr = (unsigned char *)oldaddr_aligned;
2271da177e4SLinus Torvalds 	struct net_bridge_port *p;
2281da177e4SLinus Torvalds 	int wasroot;
2291da177e4SLinus Torvalds 
2301da177e4SLinus Torvalds 	wasroot = br_is_root_bridge(br);
2311da177e4SLinus Torvalds 
232a4b816d8SToshiaki Makita 	br_fdb_change_mac_address(br, addr);
233a4b816d8SToshiaki Makita 
2341da177e4SLinus Torvalds 	memcpy(oldaddr, br->bridge_id.addr, ETH_ALEN);
2351da177e4SLinus Torvalds 	memcpy(br->bridge_id.addr, addr, ETH_ALEN);
236*2f23e5ceSJakub Kicinski 	eth_hw_addr_set(br->dev, addr);
2371da177e4SLinus Torvalds 
2381da177e4SLinus Torvalds 	list_for_each_entry(p, &br->port_list, list) {
2399a7b6ef9SJoe Perches 		if (ether_addr_equal(p->designated_bridge.addr, oldaddr))
2401da177e4SLinus Torvalds 			memcpy(p->designated_bridge.addr, addr, ETH_ALEN);
2411da177e4SLinus Torvalds 
2429a7b6ef9SJoe Perches 		if (ether_addr_equal(p->designated_root.addr, oldaddr))
2431da177e4SLinus Torvalds 			memcpy(p->designated_root.addr, addr, ETH_ALEN);
2441da177e4SLinus Torvalds 	}
2451da177e4SLinus Torvalds 
2461da177e4SLinus Torvalds 	br_configuration_update(br);
2471da177e4SLinus Torvalds 	br_port_state_selection(br);
2481da177e4SLinus Torvalds 	if (br_is_root_bridge(br) && !wasroot)
2491da177e4SLinus Torvalds 		br_become_root_bridge(br);
2501da177e4SLinus Torvalds }
2511da177e4SLinus Torvalds 
2529a7b6ef9SJoe Perches /* should be aligned on 2 bytes for ether_addr_equal() */
25319bb3506SEvgeny Kravtsunov static const unsigned short br_mac_zero_aligned[ETH_ALEN >> 1];
2541da177e4SLinus Torvalds 
2551da177e4SLinus Torvalds /* called under bridge lock */
br_stp_recalculate_bridge_id(struct net_bridge * br)256edf947f1Sstephen hemminger bool br_stp_recalculate_bridge_id(struct net_bridge *br)
2571da177e4SLinus Torvalds {
25819bb3506SEvgeny Kravtsunov 	const unsigned char *br_mac_zero =
25919bb3506SEvgeny Kravtsunov 			(const unsigned char *)br_mac_zero_aligned;
2601da177e4SLinus Torvalds 	const unsigned char *addr = br_mac_zero;
2611da177e4SLinus Torvalds 	struct net_bridge_port *p;
2621da177e4SLinus Torvalds 
26392c0574fSStephen Hemminger 	/* user has chosen a value so keep it */
264b2748267SJiri Pirko 	if (br->dev->addr_assign_type == NET_ADDR_SET)
2651459a3ccSBalaji G 		return false;
26692c0574fSStephen Hemminger 
2671da177e4SLinus Torvalds 	list_for_each_entry(p, &br->port_list, list) {
2681da177e4SLinus Torvalds 		if (addr == br_mac_zero ||
269554c9a8eSStephen Hemminger 		    memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0)
2701da177e4SLinus Torvalds 			addr = p->dev->dev_addr;
2711da177e4SLinus Torvalds 
2721da177e4SLinus Torvalds 	}
2731da177e4SLinus Torvalds 
2749a7b6ef9SJoe Perches 	if (ether_addr_equal(br->bridge_id.addr, addr))
275edf947f1Sstephen hemminger 		return false;	/* no change */
276edf947f1Sstephen hemminger 
2771da177e4SLinus Torvalds 	br_stp_change_bridge_id(br, addr);
278edf947f1Sstephen hemminger 	return true;
2791da177e4SLinus Torvalds }
2801da177e4SLinus Torvalds 
2812dab80a8SNikolay Aleksandrov /* Acquires and releases bridge lock */
br_stp_set_bridge_priority(struct net_bridge * br,u16 newprio)2821da177e4SLinus Torvalds void br_stp_set_bridge_priority(struct net_bridge *br, u16 newprio)
2831da177e4SLinus Torvalds {
2841da177e4SLinus Torvalds 	struct net_bridge_port *p;
2851da177e4SLinus Torvalds 	int wasroot;
2861da177e4SLinus Torvalds 
2872dab80a8SNikolay Aleksandrov 	spin_lock_bh(&br->lock);
2881da177e4SLinus Torvalds 	wasroot = br_is_root_bridge(br);
2891da177e4SLinus Torvalds 
2901da177e4SLinus Torvalds 	list_for_each_entry(p, &br->port_list, list) {
2911da177e4SLinus Torvalds 		if (p->state != BR_STATE_DISABLED &&
2921da177e4SLinus Torvalds 		    br_is_designated_port(p)) {
2931da177e4SLinus Torvalds 			p->designated_bridge.prio[0] = (newprio >> 8) & 0xFF;
2941da177e4SLinus Torvalds 			p->designated_bridge.prio[1] = newprio & 0xFF;
2951da177e4SLinus Torvalds 		}
2961da177e4SLinus Torvalds 
2971da177e4SLinus Torvalds 	}
2981da177e4SLinus Torvalds 
2991da177e4SLinus Torvalds 	br->bridge_id.prio[0] = (newprio >> 8) & 0xFF;
3001da177e4SLinus Torvalds 	br->bridge_id.prio[1] = newprio & 0xFF;
3011da177e4SLinus Torvalds 	br_configuration_update(br);
3021da177e4SLinus Torvalds 	br_port_state_selection(br);
3031da177e4SLinus Torvalds 	if (br_is_root_bridge(br) && !wasroot)
3041da177e4SLinus Torvalds 		br_become_root_bridge(br);
3052dab80a8SNikolay Aleksandrov 	spin_unlock_bh(&br->lock);
3061da177e4SLinus Torvalds }
3071da177e4SLinus Torvalds 
3081da177e4SLinus Torvalds /* called under bridge lock */
br_stp_set_port_priority(struct net_bridge_port * p,unsigned long newprio)30914f98f25Sstephen hemminger int br_stp_set_port_priority(struct net_bridge_port *p, unsigned long newprio)
3101da177e4SLinus Torvalds {
31114f98f25Sstephen hemminger 	port_id new_port_id;
3121da177e4SLinus Torvalds 
31314f98f25Sstephen hemminger 	if (newprio > BR_MAX_PORT_PRIORITY)
31414f98f25Sstephen hemminger 		return -ERANGE;
31514f98f25Sstephen hemminger 
31614f98f25Sstephen hemminger 	new_port_id = br_make_port_id(newprio, p->port_no);
3171da177e4SLinus Torvalds 	if (br_is_designated_port(p))
3181da177e4SLinus Torvalds 		p->designated_port = new_port_id;
3191da177e4SLinus Torvalds 
3201da177e4SLinus Torvalds 	p->port_id = new_port_id;
3211da177e4SLinus Torvalds 	p->priority = newprio;
3221da177e4SLinus Torvalds 	if (!memcmp(&p->br->bridge_id, &p->designated_bridge, 8) &&
3231da177e4SLinus Torvalds 	    p->port_id < p->designated_port) {
3241da177e4SLinus Torvalds 		br_become_designated_port(p);
3251da177e4SLinus Torvalds 		br_port_state_selection(p->br);
3261da177e4SLinus Torvalds 	}
32714f98f25Sstephen hemminger 
32814f98f25Sstephen hemminger 	return 0;
3291da177e4SLinus Torvalds }
3301da177e4SLinus Torvalds 
3311da177e4SLinus Torvalds /* called under bridge lock */
br_stp_set_path_cost(struct net_bridge_port * p,unsigned long path_cost)33214f98f25Sstephen hemminger int br_stp_set_path_cost(struct net_bridge_port *p, unsigned long path_cost)
3331da177e4SLinus Torvalds {
33414f98f25Sstephen hemminger 	if (path_cost < BR_MIN_PATH_COST ||
33514f98f25Sstephen hemminger 	    path_cost > BR_MAX_PATH_COST)
33614f98f25Sstephen hemminger 		return -ERANGE;
33714f98f25Sstephen hemminger 
3388f3359bdSstephen hemminger 	p->flags |= BR_ADMIN_COST;
3391da177e4SLinus Torvalds 	p->path_cost = path_cost;
3401da177e4SLinus Torvalds 	br_configuration_update(p->br);
3411da177e4SLinus Torvalds 	br_port_state_selection(p->br);
34214f98f25Sstephen hemminger 	return 0;
3431da177e4SLinus Torvalds }
3441da177e4SLinus Torvalds 
br_show_bridge_id(char * buf,const struct bridge_id * id)3451da177e4SLinus Torvalds ssize_t br_show_bridge_id(char *buf, const struct bridge_id *id)
3461da177e4SLinus Torvalds {
3471da177e4SLinus Torvalds 	return sprintf(buf, "%.2x%.2x.%.2x%.2x%.2x%.2x%.2x%.2x\n",
3481da177e4SLinus Torvalds 	       id->prio[0], id->prio[1],
3491da177e4SLinus Torvalds 	       id->addr[0], id->addr[1], id->addr[2],
3501da177e4SLinus Torvalds 	       id->addr[3], id->addr[4], id->addr[5]);
3511da177e4SLinus Torvalds }
352