Commit a98c0c47 authored by Menglong Dong's avatar Menglong Dong Committed by Jakub Kicinski

net: bridge: check vlan with eth_type_vlan() method

Replace some checks for ETH_P_8021Q and ETH_P_8021AD with
eth_type_vlan().
Signed-off-by: default avatarMenglong Dong <dong.menglong@zte.com.cn>
Acked-by: default avatarNikolay Aleksandrov <nikolay@nvidia.com>
Link: https://lore.kernel.org/r/20210117080950.122761-1-dong.menglong@zte.com.cnSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 220723dc
...@@ -39,8 +39,7 @@ int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb ...@@ -39,8 +39,7 @@ int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb
br_drop_fake_rtable(skb); br_drop_fake_rtable(skb);
if (skb->ip_summed == CHECKSUM_PARTIAL && if (skb->ip_summed == CHECKSUM_PARTIAL &&
(skb->protocol == htons(ETH_P_8021Q) || eth_type_vlan(skb->protocol)) {
skb->protocol == htons(ETH_P_8021AD))) {
int depth; int depth;
if (!__vlan_get_protocol(skb, skb->protocol, &depth)) if (!__vlan_get_protocol(skb, skb->protocol, &depth))
......
...@@ -1096,15 +1096,9 @@ static int br_validate(struct nlattr *tb[], struct nlattr *data[], ...@@ -1096,15 +1096,9 @@ static int br_validate(struct nlattr *tb[], struct nlattr *data[],
return 0; return 0;
#ifdef CONFIG_BRIDGE_VLAN_FILTERING #ifdef CONFIG_BRIDGE_VLAN_FILTERING
if (data[IFLA_BR_VLAN_PROTOCOL]) { if (data[IFLA_BR_VLAN_PROTOCOL] &&
switch (nla_get_be16(data[IFLA_BR_VLAN_PROTOCOL])) { !eth_type_vlan(nla_get_be16(data[IFLA_BR_VLAN_PROTOCOL])))
case htons(ETH_P_8021Q): return -EPROTONOSUPPORT;
case htons(ETH_P_8021AD):
break;
default:
return -EPROTONOSUPPORT;
}
}
if (data[IFLA_BR_VLAN_DEFAULT_PVID]) { if (data[IFLA_BR_VLAN_DEFAULT_PVID]) {
__u16 defpvid = nla_get_u16(data[IFLA_BR_VLAN_DEFAULT_PVID]); __u16 defpvid = nla_get_u16(data[IFLA_BR_VLAN_DEFAULT_PVID]);
......
...@@ -917,7 +917,7 @@ int __br_vlan_set_proto(struct net_bridge *br, __be16 proto) ...@@ -917,7 +917,7 @@ int __br_vlan_set_proto(struct net_bridge *br, __be16 proto)
int br_vlan_set_proto(struct net_bridge *br, unsigned long val) int br_vlan_set_proto(struct net_bridge *br, unsigned long val)
{ {
if (val != ETH_P_8021Q && val != ETH_P_8021AD) if (!eth_type_vlan(htons(val)))
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
return __br_vlan_set_proto(br, htons(val)); return __br_vlan_set_proto(br, htons(val));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment