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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) // Copyright (c) 2020, Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/rtnetlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <net/ip_tunnels.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "br_private.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "br_private_tunnel.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) static bool __vlan_tun_put(struct sk_buff *skb, const struct net_bridge_vlan *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	__be32 tid = tunnel_id_to_key32(v->tinfo.tunnel_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	struct nlattr *nest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	if (!v->tinfo.tunnel_dst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	nest = nla_nest_start(skb, BRIDGE_VLANDB_ENTRY_TUNNEL_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	if (!nest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	if (nla_put_u32(skb, BRIDGE_VLANDB_TINFO_ID, be32_to_cpu(tid))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		nla_nest_cancel(skb, nest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	nla_nest_end(skb, nest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) static bool __vlan_tun_can_enter_range(const struct net_bridge_vlan *v_curr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 				       const struct net_bridge_vlan *range_end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	return (!v_curr->tinfo.tunnel_dst && !range_end->tinfo.tunnel_dst) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	       vlan_tunid_inrange(v_curr, range_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) /* check if the options' state of v_curr allow it to enter the range */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) bool br_vlan_opts_eq_range(const struct net_bridge_vlan *v_curr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 			   const struct net_bridge_vlan *range_end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	return v_curr->state == range_end->state &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	       __vlan_tun_can_enter_range(v_curr, range_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) bool br_vlan_opts_fill(struct sk_buff *skb, const struct net_bridge_vlan *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	return !nla_put_u8(skb, BRIDGE_VLANDB_ENTRY_STATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 			   br_vlan_get_state(v)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	       __vlan_tun_put(skb, v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) size_t br_vlan_opts_nl_size(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	return nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_ENTRY_STATE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	       + nla_total_size(0) /* BRIDGE_VLANDB_ENTRY_TUNNEL_INFO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	       + nla_total_size(sizeof(u32)); /* BRIDGE_VLANDB_TINFO_ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) static int br_vlan_modify_state(struct net_bridge_vlan_group *vg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 				struct net_bridge_vlan *v,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 				u8 state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 				bool *changed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 				struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	struct net_bridge *br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	ASSERT_RTNL();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (state > BR_STATE_BLOCKING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		NL_SET_ERR_MSG_MOD(extack, "Invalid vlan state");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	if (br_vlan_is_brentry(v))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		br = v->br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		br = v->port->br;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (br->stp_enabled == BR_KERNEL_STP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		NL_SET_ERR_MSG_MOD(extack, "Can't modify vlan state when using kernel STP");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	if (v->state == state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	if (v->vid == br_get_pvid(vg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		br_vlan_set_pvid_state(vg, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	br_vlan_set_state(v, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	*changed = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static const struct nla_policy br_vlandb_tinfo_pol[BRIDGE_VLANDB_TINFO_MAX + 1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	[BRIDGE_VLANDB_TINFO_ID]	= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	[BRIDGE_VLANDB_TINFO_CMD]	= { .type = NLA_U32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static int br_vlan_modify_tunnel(const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 				 struct net_bridge_vlan *v,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 				 struct nlattr **tb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 				 bool *changed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 				 struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	struct nlattr *tun_tb[BRIDGE_VLANDB_TINFO_MAX + 1], *attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct bridge_vlan_info *vinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	u32 tun_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	int cmd, err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	if (!p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		NL_SET_ERR_MSG_MOD(extack, "Can't modify tunnel mapping of non-port vlans");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	if (!(p->flags & BR_VLAN_TUNNEL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		NL_SET_ERR_MSG_MOD(extack, "Port doesn't have tunnel flag set");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	attr = tb[BRIDGE_VLANDB_ENTRY_TUNNEL_INFO];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	err = nla_parse_nested(tun_tb, BRIDGE_VLANDB_TINFO_MAX, attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			       br_vlandb_tinfo_pol, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	if (!tun_tb[BRIDGE_VLANDB_TINFO_CMD]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		NL_SET_ERR_MSG_MOD(extack, "Missing tunnel command attribute");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		return -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	cmd = nla_get_u32(tun_tb[BRIDGE_VLANDB_TINFO_CMD]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	case RTM_SETLINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		if (!tun_tb[BRIDGE_VLANDB_TINFO_ID]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			NL_SET_ERR_MSG_MOD(extack, "Missing tunnel id attribute");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			return -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		/* when working on vlan ranges this is the starting tunnel id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		tun_id = nla_get_u32(tun_tb[BRIDGE_VLANDB_TINFO_ID]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		/* vlan info attr is guaranteed by br_vlan_rtm_process_one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		vinfo = nla_data(tb[BRIDGE_VLANDB_ENTRY_INFO]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		/* tunnel ids are mapped to each vlan in increasing order,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		 * the starting vlan is in BRIDGE_VLANDB_ENTRY_INFO and v is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		 * current vlan, so we compute: tun_id + v - vinfo->vid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		tun_id += v->vid - vinfo->vid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	case RTM_DELLINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		NL_SET_ERR_MSG_MOD(extack, "Unsupported tunnel command");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	return br_vlan_tunnel_info(p, cmd, v->vid, tun_id, changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static int br_vlan_process_one_opts(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 				    const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 				    struct net_bridge_vlan_group *vg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 				    struct net_bridge_vlan *v,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 				    struct nlattr **tb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 				    bool *changed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 				    struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	*changed = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	if (tb[BRIDGE_VLANDB_ENTRY_STATE]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		u8 state = nla_get_u8(tb[BRIDGE_VLANDB_ENTRY_STATE]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		err = br_vlan_modify_state(vg, v, state, changed, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	if (tb[BRIDGE_VLANDB_ENTRY_TUNNEL_INFO]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		err = br_vlan_modify_tunnel(p, v, tb, changed, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) int br_vlan_process_options(const struct net_bridge *br,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 			    const struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			    struct net_bridge_vlan *range_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 			    struct net_bridge_vlan *range_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			    struct nlattr **tb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			    struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	struct net_bridge_vlan *v, *curr_start = NULL, *curr_end = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	struct net_bridge_vlan_group *vg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	int vid, err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	u16 pvid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	if (p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		vg = nbp_vlan_group(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		vg = br_vlan_group(br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	if (!range_start || !br_vlan_should_use(range_start)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		NL_SET_ERR_MSG_MOD(extack, "Vlan range start doesn't exist, can't process options");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		return -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	if (!range_end || !br_vlan_should_use(range_end)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		NL_SET_ERR_MSG_MOD(extack, "Vlan range end doesn't exist, can't process options");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		return -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	pvid = br_get_pvid(vg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	for (vid = range_start->vid; vid <= range_end->vid; vid++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		bool changed = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		v = br_vlan_find(vg, vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		if (!v || !br_vlan_should_use(v)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			NL_SET_ERR_MSG_MOD(extack, "Vlan in range doesn't exist, can't process options");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			err = -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		err = br_vlan_process_one_opts(br, p, vg, v, tb, &changed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 					       extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		if (changed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			/* vlan options changed, check for range */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 			if (!curr_start) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 				curr_start = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 				curr_end = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			if (v->vid == pvid ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 			    !br_vlan_can_enter_range(v, curr_end)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 				br_vlan_notify(br, p, curr_start->vid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 					       curr_end->vid, RTM_NEWVLAN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 				curr_start = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 			curr_end = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 			/* nothing changed and nothing to notify yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			if (!curr_start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 			br_vlan_notify(br, p, curr_start->vid, curr_end->vid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 				       RTM_NEWVLAN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 			curr_start = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 			curr_end = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	if (curr_start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		br_vlan_notify(br, p, curr_start->vid, curr_end->vid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			       RTM_NEWVLAN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }