[Bridge] [PATCH v3 net-next] net: bridge: check vlan with eth_type_vlan() method

Jakub Kicinski kuba at kernel.org
Sun Jan 17 02:58:42 UTC 2021


On Thu, 14 Jan 2021 20:41:31 -0800 menglong8.dong at gmail.com wrote:
> -	if (data[IFLA_BR_VLAN_PROTOCOL]) {
> -		switch (nla_get_be16(data[IFLA_BR_VLAN_PROTOCOL])) {
> -		case htons(ETH_P_8021Q):
> -		case htons(ETH_P_8021AD):
> -			break;
> -		default:
> -			return -EPROTONOSUPPORT;
> -		}
> +	if (data[IFLA_BR_VLAN_PROTOCOL] &&
> +	    !eth_type_vlan(nla_get_be16(data[IFLA_BR_VLAN_PROTOCOL]))) {
> +		return -EPROTONOSUPPORT;
>  	}

The curly brackets are no longer necessary here, since it's a single
line expression.


More information about the Bridge mailing list