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

From: Jakub Kicinski
Date: Sat Jan 16 2021 - 21:59:44 EST


On Thu, 14 Jan 2021 20:41:31 -0800 menglong8.dong@xxxxxxxxx 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.