OpenCloudOS-Kernel/drivers/net
Vladimir Oltean f964f8399d net: mscc: ocelot: fix VCAP filters not matching on MAC with "protocol 802.1Q"
Alternative short title: don't instruct the hardware to match on
EtherType with "protocol 802.1Q" flower filters. It doesn't work for the
reasons detailed below.

With a command such as the following:

tc filter add dev $swp1 ingress chain $(IS1 2) pref 3 \
	protocol 802.1Q flower skip_sw vlan_id 200 src_mac $h1_mac \
	action vlan modify id 300 \
	action goto chain $(IS2 0 0)

the created filter is set by ocelot_flower_parse_key() to be of type
OCELOT_VCAP_KEY_ETYPE, and etype is set to {value=0x8100, mask=0xffff}.
This gets propagated all the way to is1_entry_set() which commits it to
hardware (the VCAP_IS1_HK_ETYPE field of the key). Compare this to the
case where src_mac isn't specified - the key type is OCELOT_VCAP_KEY_ANY,
and is1_entry_set() doesn't populate VCAP_IS1_HK_ETYPE.

The problem is that for VLAN-tagged frames, the hardware interprets the
ETYPE field as holding the encapsulated VLAN protocol. So the above
filter will only match those packets which have an encapsulated protocol
of 0x8100, rather than all packets with VLAN ID 200 and the given src_mac.

The reason why this is allowed to occur is because, although we have a
block of code in ocelot_flower_parse_key() which sets "match_protocol"
to false when VLAN keys are present, that code executes too late.
There is another block of code, which executes for Ethernet addresses,
and has a "goto finished_key_parsing" and skips the VLAN header parsing.
By skipping it, "match_protocol" remains with the value it was
initialized with, i.e. "true", and "proto" is set to f->common.protocol,
or 0x8100.

The concept of ignoring some keys rather than erroring out when they are
present but can't be offloaded is dubious in itself, but is present
since the initial commit fe3490e610 ("net: mscc: ocelot: Hardware
ofload for tc flower filter"), and it's outside of the scope of this
patch to change that.

The problem was introduced when the driver started to interpret the
flower filter's protocol, and populate the VCAP filter's ETYPE field
based on it.

To fix this, it is sufficient to move the code that parses the VLAN keys
earlier than the "goto finished_key_parsing" instruction. This will
ensure that if we have a flower filter with both VLAN and Ethernet
address keys, it won't match on ETYPE 0x8100, because the VLAN key
parsing sets "match_protocol = false".

Fixes: 86b956de11 ("net: mscc: ocelot: support matching on EtherType")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230205192409.1796428-1-vladimir.oltean@nxp.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-02-07 12:20:21 +01:00
..
appletalk
arcnet
bonding bonding: fix error checking in bond_debug_reregister() 2023-02-03 19:22:20 -08:00
caif
can can: mcp251xfd: mcp251xfd_ring_set_ringparam(): assign missing tx_obj_num_coalesce_irq 2023-02-02 10:33:27 +01:00
dsa net: dsa: mt7530: don't change PVC_EG_TAG when CPU port becomes VLAN-aware 2023-02-07 11:42:04 +01:00
ethernet net: mscc: ocelot: fix VCAP filters not matching on MAC with "protocol 802.1Q" 2023-02-07 12:20:21 +01:00
fddi net: defxx: Fix missing err handling in dfx_init() 2022-12-09 10:44:27 +00:00
fjes ACPI: make remove callback of ACPI driver void 2022-11-23 19:11:22 +01:00
hamradio Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-12-13 09:49:29 +01:00
hippi
hyperv hv_netvsc: Fix missed pagebuf entries in netvsc_dma_map/unmap() 2023-02-02 09:15:30 +01:00
ieee802154 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-12-08 18:19:59 -08:00
ipa net: ipa: disable ipa interrupt during suspend 2023-01-17 19:04:13 -08:00
ipvlan Driver Core changes for 6.2-rc1 2022-12-16 03:54:54 -08:00
mctp mctp: serial: Fix starting value for frame check sequence 2022-12-19 12:38:45 +00:00
mdio net: mdio-mux-meson-g12a: force internal PHY off on mux switch 2023-01-25 22:46:51 -08:00
netdevsim xfrm: allow state packet offload mode 2022-12-05 10:32:44 +01:00
pcs net: pcs: altera-tse: remove unnecessary register definitions 2022-11-29 20:29:55 -08:00
phy net: phy: meson-gxl: use MMD access dummy stubs for GXL, internal PHY 2023-02-03 19:55:36 -08:00
plip net: plip: don't call kfree_skb/dev_kfree_skb() under spin_lock_irq() 2022-12-07 20:10:47 -08:00
ppp Networking changes for 6.2. 2022-12-13 15:47:48 -08:00
pse-pd
slip
team Revert "net: team: use IFF_NO_ADDRCONF flag to prevent ipv6 addrconf" 2023-01-18 20:32:44 -08:00
usb net: USB: Fix wrong-direction WARNING in plusb.c 2023-02-06 09:59:35 +00:00
vmxnet3 vmxnet3: correctly report csum_level for encapsulated packet 2022-12-21 17:55:30 -08:00
vxlan vxlan: Fix memory leaks in error path 2023-01-02 13:37:33 +00:00
wan net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs 2023-01-13 21:34:31 -08:00
wireguard wireguard: timers: cast enum limits members to int in prints 2022-12-13 19:30:45 -08:00
wireless wifi: mt76: dma: fix a regression in adding rx buffers 2023-01-16 17:27:17 +02:00
wwan net: wwan: t7xx: Fix Runtime PM initialization 2023-01-28 13:20:21 +00:00
xen-netback xen: branch for v6.2-rc4 2023-01-12 17:02:20 -06:00
Kconfig
LICENSE.SRC
Makefile
Space.c
amt.c
bareudp.c
dummy.c
eql.c
geneve.c
gtp.c
ifb.c
loopback.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-29 13:04:52 -08:00
macsec.c net: macsec: fix net device access prior to holding a lock 2022-12-13 18:58:08 -08:00
macvlan.c
macvtap.c
mdio.c
mhi_net.c
mii.c
net_failover.c
netconsole.c netconsole: avoid CON_ENABLED misuse to track registration 2022-12-02 11:25:02 +01:00
nlmon.c
ntb_netdev.c ntb_netdev: Use dev_kfree_skb_any() in interrupt context 2022-12-12 12:56:37 -08:00
rionet.c
sb1000.c
sungem_phy.c
tap.c driver/net/tun: Added features for USO. 2022-12-12 09:29:56 +00:00
thunderbolt.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-12-08 18:19:59 -08:00
tun.c driver/net/tun: Added features for USO. 2022-12-12 09:29:56 +00:00
veth.c veth: Fix race with AF_XDP exposing old or uninitialized descriptors 2022-12-22 15:06:10 +01:00
virtio_net.c virtio-net: Keep stop() to follow mirror sequence of open() 2023-02-02 10:10:53 -08:00
vrf.c net: vrf: determine the dst using the original ifindex for multicast 2022-12-21 17:47:37 -08:00
vsockmon.c
xen-netfront.c xen: branch for v6.2-rc4 2023-01-12 17:02:20 -06:00