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; BPDU handling
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/netfilter_bridge.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/etherdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/llc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/pkt_sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <net/net_namespace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <net/llc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <net/llc_pdu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <net/stp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "br_private.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include "br_private_stp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define STP_HZ		256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define LLC_RESERVE sizeof(struct llc_pdu_un)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) static int br_send_bpdu_finish(struct net *net, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 			       struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	return dev_queue_xmit(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) static void br_send_bpdu(struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 			 const unsigned char *data, int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	skb = dev_alloc_skb(length+LLC_RESERVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	skb->dev = p->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	skb->protocol = htons(ETH_P_802_2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	skb->priority = TC_PRIO_CONTROL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	skb_reserve(skb, LLC_RESERVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	__skb_put_data(skb, data, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	llc_pdu_header_init(skb, LLC_PDU_TYPE_U, LLC_SAP_BSPAN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 			    LLC_SAP_BSPAN, LLC_PDU_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	llc_pdu_init_as_ui_cmd(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	llc_mac_hdr_init(skb, p->dev->dev_addr, p->br->group_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	skb_reset_mac_header(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		dev_net(p->dev), NULL, skb, NULL, skb->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		br_send_bpdu_finish);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static inline void br_set_ticks(unsigned char *dest, int j)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	unsigned long ticks = (STP_HZ * j)/ HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	put_unaligned_be16(ticks, dest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) static inline int br_get_ticks(const unsigned char *src)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	unsigned long ticks = get_unaligned_be16(src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	return DIV_ROUND_UP(ticks * HZ, STP_HZ);
^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) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) void br_send_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *bpdu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	unsigned char buf[35];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	if (p->br->stp_enabled != BR_KERNEL_STP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	buf[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	buf[1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	buf[2] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	buf[3] = BPDU_TYPE_CONFIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	buf[4] = (bpdu->topology_change ? 0x01 : 0) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		(bpdu->topology_change_ack ? 0x80 : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	buf[5] = bpdu->root.prio[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	buf[6] = bpdu->root.prio[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	buf[7] = bpdu->root.addr[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	buf[8] = bpdu->root.addr[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	buf[9] = bpdu->root.addr[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	buf[10] = bpdu->root.addr[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	buf[11] = bpdu->root.addr[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	buf[12] = bpdu->root.addr[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	buf[13] = (bpdu->root_path_cost >> 24) & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	buf[14] = (bpdu->root_path_cost >> 16) & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	buf[15] = (bpdu->root_path_cost >> 8) & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	buf[16] = bpdu->root_path_cost & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	buf[17] = bpdu->bridge_id.prio[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	buf[18] = bpdu->bridge_id.prio[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	buf[19] = bpdu->bridge_id.addr[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	buf[20] = bpdu->bridge_id.addr[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	buf[21] = bpdu->bridge_id.addr[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	buf[22] = bpdu->bridge_id.addr[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	buf[23] = bpdu->bridge_id.addr[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	buf[24] = bpdu->bridge_id.addr[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	buf[25] = (bpdu->port_id >> 8) & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	buf[26] = bpdu->port_id & 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	br_set_ticks(buf+27, bpdu->message_age);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	br_set_ticks(buf+29, bpdu->max_age);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	br_set_ticks(buf+31, bpdu->hello_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	br_set_ticks(buf+33, bpdu->forward_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	br_send_bpdu(p, buf, 35);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	p->stp_xstats.tx_bpdu++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) void br_send_tcn_bpdu(struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	unsigned char buf[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	if (p->br->stp_enabled != BR_KERNEL_STP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	buf[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	buf[1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	buf[2] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	buf[3] = BPDU_TYPE_TCN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	br_send_bpdu(p, buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	p->stp_xstats.tx_tcn++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * Called from llc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  * NO locks, but rcu_read_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	struct net_bridge_port *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	struct net_bridge *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	const unsigned char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	if (!pskb_may_pull(skb, 4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	/* compare of protocol id and version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	buf = skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	if (buf[0] != 0 || buf[1] != 0 || buf[2] != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	p = br_port_get_check_rcu(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	br = p->br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	spin_lock(&br->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	if (br->stp_enabled != BR_KERNEL_STP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (!(br->dev->flags & IFF_UP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	if (p->state == BR_STATE_DISABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	if (!ether_addr_equal(eth_hdr(skb)->h_dest, br->group_addr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	if (p->flags & BR_BPDU_GUARD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		br_notice(br, "BPDU received on blocked port %u(%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			  (unsigned int) p->port_no, p->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		br_stp_disable_port(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		goto out;
^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) 	buf = skb_pull(skb, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	if (buf[0] == BPDU_TYPE_CONFIG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		struct br_config_bpdu bpdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		if (!pskb_may_pull(skb, 32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		buf = skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		bpdu.topology_change = (buf[1] & 0x01) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		bpdu.topology_change_ack = (buf[1] & 0x80) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		bpdu.root.prio[0] = buf[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		bpdu.root.prio[1] = buf[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		bpdu.root.addr[0] = buf[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		bpdu.root.addr[1] = buf[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		bpdu.root.addr[2] = buf[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		bpdu.root.addr[3] = buf[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		bpdu.root.addr[4] = buf[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		bpdu.root.addr[5] = buf[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		bpdu.root_path_cost =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			(buf[10] << 24) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			(buf[11] << 16) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			(buf[12] << 8) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 			buf[13];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		bpdu.bridge_id.prio[0] = buf[14];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		bpdu.bridge_id.prio[1] = buf[15];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		bpdu.bridge_id.addr[0] = buf[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		bpdu.bridge_id.addr[1] = buf[17];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		bpdu.bridge_id.addr[2] = buf[18];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		bpdu.bridge_id.addr[3] = buf[19];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		bpdu.bridge_id.addr[4] = buf[20];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		bpdu.bridge_id.addr[5] = buf[21];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		bpdu.port_id = (buf[22] << 8) | buf[23];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		bpdu.message_age = br_get_ticks(buf+24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		bpdu.max_age = br_get_ticks(buf+26);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		bpdu.hello_time = br_get_ticks(buf+28);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		bpdu.forward_delay = br_get_ticks(buf+30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		if (bpdu.message_age > bpdu.max_age) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 			if (net_ratelimit())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 				br_notice(p->br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 					  "port %u config from %pM"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 					  " (message_age %ul > max_age %ul)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 					  p->port_no,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 					  eth_hdr(skb)->h_source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 					  bpdu.message_age, bpdu.max_age);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		br_received_config_bpdu(p, &bpdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	} else if (buf[0] == BPDU_TYPE_TCN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		br_received_tcn_bpdu(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	spin_unlock(&br->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }