Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: make vlan_get_tag() return -ENODATA instead of -EINVAL

__vlan_hwaccel_get_tag() is used in veth XDP hints implementation,
its return value (-EINVAL if skb is not VLAN tagged) is passed to bpf code,
but XDP hints specification requires drivers to return -ENODATA, if a hint
cannot be provided for a particular packet.

Solve this inconsistency by changing error return value of
__vlan_hwaccel_get_tag() from -EINVAL to -ENODATA, do the same thing to
__vlan_get_tag(), because this function is supposed to follow the same
convention. This, in turn, makes -ENODATA the only non-zero value
vlan_get_tag() can return. We can do this with no side effects, because
none of the users of the 3 above-mentioned functions rely on the exact
value.

Suggested-by: Jesper Dangaard Brouer <jbrouer@redhat.com>
Acked-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
Link: https://lore.kernel.org/r/20231205210847.28460-14-larysa.zaremba@intel.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Larysa Zaremba and committed by
Alexei Starovoitov
537fec07 fca78379

+2 -2
+2 -2
include/linux/if_vlan.h
··· 540 540 struct vlan_ethhdr *veth = skb_vlan_eth_hdr(skb); 541 541 542 542 if (!eth_type_vlan(veth->h_vlan_proto)) 543 - return -EINVAL; 543 + return -ENODATA; 544 544 545 545 *vlan_tci = ntohs(veth->h_vlan_TCI); 546 546 return 0; ··· 561 561 return 0; 562 562 } else { 563 563 *vlan_tci = 0; 564 - return -EINVAL; 564 + return -ENODATA; 565 565 } 566 566 } 567 567