OpenCloudOS-Kernel/drivers/net/ethernet
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
..
3com net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
8390 ethernet: 8390: remove unnecessary check of mem 2022-09-29 11:05:23 +02:00
actions net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
adaptec net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
adi net: ethernet: adi: adin1110: Fix multicast offloading 2023-01-23 21:41:33 -08:00
aeroflex ethernet: aeroflex: fix potential skb leak in greth_init_rings() 2022-12-07 11:45:52 +01:00
agere net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
alacritech net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers). 2022-10-28 20:13:54 -07:00
allwinner net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
alteon net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
altera Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-29 13:04:52 -08:00
amazon net: ena: Update NUMA TPH hint register upon NUMA node update 2022-12-30 07:43:44 +00:00
amd amd-xgbe: Delay AN timeout during KR training 2023-01-12 21:50:37 -08:00
apm drivers: net: xgene: disable napi when register irq failed in xgene_enet_open() 2022-11-08 15:15:55 +01:00
apple net: apple: bmac: don't call dev_kfree_skb() under spin_lock_irqsave() 2022-12-12 09:53:10 +00:00
aquantia Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-29 13:04:52 -08:00
arc net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
asix net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers). 2022-10-28 20:13:54 -07:00
atheros Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-17 18:30:39 -08:00
broadcom net/tg3: resolve deadlock in tg3_reset_task() during EEH 2023-01-25 22:35:42 -08:00
brocade bna: Avoid clashing function prototypes 2022-11-21 08:17:59 +00:00
cadence net: macb: Perform zynqmp dynamic configuration only for SGMII interface 2023-02-03 19:34:55 -08:00
calxeda net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
cavium liquidio: use strscpy() to instead of strncpy() 2022-12-12 10:00:55 +00:00
chelsio Networking changes for 6.2. 2022-12-13 15:47:48 -08:00
cirrus net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
cisco enic: define constants for legacy interrupts offset 2022-10-18 19:34:28 -07:00
cortina net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers). 2022-10-28 20:13:54 -07:00
davicom net: dm9051: Fix missing dev_kfree_skb() in dm9051_loop_rx() 2022-11-23 12:43:14 +00:00
dec net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
dlink sundance: remove unused variable cnt 2022-11-17 13:18:30 +01:00
emulex net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers). 2022-10-28 20:13:54 -07:00
engleder tsnep: Fix TX queue stop/wake for multiple queues 2023-01-25 22:41:50 -08:00
ezchip
faraday net: ftmac100: allow increasing MTU to make most use of single-segment buffers 2022-10-31 20:02:57 -07:00
freescale net: fman: memac: free mdio device if lynx_pcs_create() fails 2023-01-31 21:05:09 -08:00
fujitsu net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
fungible net: devlink: clean-up empty devlink_ops::info_get() 2022-11-30 21:49:39 -08:00
google gve: Handle alternate miss completions 2022-11-21 10:52:14 +00:00
hisilicon net: hns3: fix wrong use of rss size during VF rss config 2023-01-11 20:20:59 -08:00
huawei Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-17 18:30:39 -08:00
i825xx
ibm ibmvnic: Update XPS assignments during affinity binding 2022-11-14 10:47:07 +00:00
intel igc: return an error if the mac type is unknown in igc_ptp_systim_to_hwtstamp() 2023-02-01 21:19:57 -08:00
litex net: ethernet: litex: Fix return type of liteeth_start_xmit 2022-09-19 18:23:39 -07:00
marvell octeontx2-af: Fix devlink unregister 2023-02-01 21:22:41 -08:00
mediatek mtk_sgmii: enable PCS polling to allow SFP work 2023-02-02 11:55:53 -08:00
mellanox net: mlx5: eliminate anonymous module_init & module_exit 2023-01-18 00:01:39 -08:00
micrel net: ksz884x: fix missing pci_disable_device() on error in pcidev_init() 2022-10-25 19:46:35 -07:00
microchip net: microchip: sparx5: fix PTP init/deinit not checking all ports 2023-02-06 09:26:04 +00:00
microsoft net: mana: Fix IRQ name - add PCI and queue number 2023-01-20 18:17:17 -08:00
moxa net: moxa: fix endianness-related issues from 'sparse' 2022-09-06 10:24:42 +02:00
mscc net: mscc: ocelot: fix VCAP filters not matching on MAC with "protocol 802.1Q" 2023-02-07 12:20:21 +01:00
myricom myri10ge: Fix an error handling path in myri10ge_probe() 2022-12-19 12:30:32 +00:00
natsemi net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
neterion ethernet: s2io: don't call dev_kfree_skb() under spin_lock_irqsave() 2022-12-12 09:38:24 +00:00
netronome nfp: flower: avoid taking mutex in atomic context 2023-02-01 19:56:11 -08:00
ni net: ethernet: nixge: fix NULL dereference 2022-11-28 11:09:51 +00:00
nvidia net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers). 2022-10-28 20:13:54 -07:00
nxp net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
oki-semi net: pch_gbe: fix pci device refcount leak while module exiting 2022-11-18 19:40:14 -08:00
packetengines net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
pasemi net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
pensando ionic: missed doorbell workaround 2023-02-03 19:58:53 -08:00
qlogic qede: execute xdp_do_flush() before napi_complete_done() 2023-01-27 22:27:59 -08:00
qualcomm net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers). 2022-10-28 20:13:54 -07:00
rdc r6040: Fix kmemleak in probe and remove 2022-12-15 12:48:34 +01:00
realtek Revert "r8169: disable detection of chip version 36" 2023-01-09 20:40:28 -08:00
renesas net: ravb: Fix possible hang if RIS2_QFF1 happen 2023-01-25 13:00:27 +00:00
rocker rocker: Explicitly mark learned FDB entries as offloaded 2022-11-02 20:45:23 -07:00
samsung net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
seeq
sfc sfc: correctly advertise tunneled IPv6 segmentation 2023-01-28 00:19:48 -08:00
sgi net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
silan
sis net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
smsc net: remove smc911x driver 2022-10-18 19:33:51 -07:00
socionext net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers). 2022-10-28 20:13:54 -07:00
stmicro net: stmmac: do not stop RX_CLK in Rx LPI state for qcs404 SoC 2023-01-30 07:21:25 +00:00
sun treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
sunplus eth: sp7021: drop free_netdev() from spl2sw_init_netdev() 2022-11-10 16:27:33 -08:00
synopsys net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
tehuti net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
ti net: ethernet: ti: am65-cpsw: fix CONFIG_PM #ifdef 2022-12-16 21:13:52 -08:00
toshiba net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
tundra ethernet: tundra: free irq when alloc ring failed in tsi108_open() 2022-11-10 15:39:08 +01:00
vertexcom net: vertexcom: mse102x: Silence no spi_device_id warnings 2022-09-26 12:46:16 -07:00
via net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers). 2022-10-28 20:13:54 -07:00
wangxun net: libwx: Fix dead code for duplicate check 2022-11-18 10:53:13 +00:00
wiznet net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
xilinx Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-12-13 09:49:29 +01:00
xircom net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
xscale ptp_ixp46x: convert .adjfreq to .adjfine 2022-11-11 10:58:39 +00:00
Kconfig eth: fealnx: delete the driver for Myson MTD-800 2022-10-27 13:32:08 +02:00
Makefile eth: fealnx: delete the driver for Myson MTD-800 2022-10-27 13:32:08 +02:00
dnet.c net: ethernet: dnet: don't call dev_kfree_skb() under spin_lock_irqsave() 2022-12-12 09:56:17 +00:00
dnet.h
ec_bhf.c
ethoc.c net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
jme.c net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
jme.h
korina.c net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
lantiq_etop.c net: lantiq_etop: don't free skb when returning NETDEV_TX_BUSY 2022-10-24 13:02:18 +01:00
lantiq_xrx200.c net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00