mirror_ubuntu-kernels/drivers/net/ethernet
Jonas Gorski 2aa71b4b29 net: marvell: prestera: fix handling IPv4 routes with nhid
Fix handling IPv4 routes referencing a nexthop via its id by replacing
calls to fib_info_nh() with fib_info_nhc().

Trying to add an IPv4 route referencing a nextop via nhid:

    $ ip link set up swp5
    $ ip a a 10.0.0.1/24 dev swp5
    $ ip nexthop add dev swp5 id 20 via 10.0.0.2
    $ ip route add 10.0.1.0/24 nhid 20

triggers warnings when trying to handle the route:

[  528.805763] ------------[ cut here ]------------
[  528.810437] WARNING: CPU: 3 PID: 53 at include/net/nexthop.h:468 __prestera_fi_is_direct+0x2c/0x68 [prestera]
[  528.820434] Modules linked in: prestera_pci act_gact act_police sch_ingress cls_u32 cls_flower prestera arm64_delta_tn48m_dn_led(O) arm64_delta_tn48m_dn_cpld(O) [last unloaded: prestera_pci]
[  528.837485] CPU: 3 PID: 53 Comm: kworker/u8:3 Tainted: G           O       6.4.5 #1
[  528.845178] Hardware name: delta,tn48m-dn (DT)
[  528.849641] Workqueue: prestera_ordered __prestera_router_fib_event_work [prestera]
[  528.857352] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  528.864347] pc : __prestera_fi_is_direct+0x2c/0x68 [prestera]
[  528.870135] lr : prestera_k_arb_fib_evt+0xb20/0xd50 [prestera]
[  528.876007] sp : ffff80000b20bc90
[  528.879336] x29: ffff80000b20bc90 x28: 0000000000000000 x27: ffff0001374d3a48
[  528.886510] x26: ffff000105604000 x25: ffff000134af8a28 x24: ffff0001374d3800
[  528.893683] x23: ffff000101c89148 x22: ffff000101c89000 x21: ffff000101c89200
[  528.900855] x20: ffff00013641fda0 x19: ffff800009d01088 x18: 0000000000000059
[  528.908027] x17: 0000000000000277 x16: 0000000000000000 x15: 0000000000000000
[  528.915198] x14: 0000000000000003 x13: 00000000000fe400 x12: 0000000000000000
[  528.922371] x11: 0000000000000002 x10: 0000000000000aa0 x9 : ffff8000013d2020
[  528.929543] x8 : 0000000000000018 x7 : 000000007b1703f8 x6 : 000000001ca72f86
[  528.936715] x5 : 0000000033399ea7 x4 : 0000000000000000 x3 : ffff0001374d3acc
[  528.943886] x2 : 0000000000000000 x1 : ffff00010200de00 x0 : ffff000134ae3f80
[  528.951058] Call trace:
[  528.953516]  __prestera_fi_is_direct+0x2c/0x68 [prestera]
[  528.958952]  __prestera_router_fib_event_work+0x100/0x158 [prestera]
[  528.965348]  process_one_work+0x208/0x488
[  528.969387]  worker_thread+0x4c/0x430
[  528.973068]  kthread+0x120/0x138
[  528.976313]  ret_from_fork+0x10/0x20
[  528.979909] ---[ end trace 0000000000000000 ]---
[  528.984998] ------------[ cut here ]------------
[  528.989645] WARNING: CPU: 3 PID: 53 at include/net/nexthop.h:468 __prestera_fi_is_direct+0x2c/0x68 [prestera]
[  528.999628] Modules linked in: prestera_pci act_gact act_police sch_ingress cls_u32 cls_flower prestera arm64_delta_tn48m_dn_led(O) arm64_delta_tn48m_dn_cpld(O) [last unloaded: prestera_pci]
[  529.016676] CPU: 3 PID: 53 Comm: kworker/u8:3 Tainted: G        W  O       6.4.5 #1
[  529.024368] Hardware name: delta,tn48m-dn (DT)
[  529.028830] Workqueue: prestera_ordered __prestera_router_fib_event_work [prestera]
[  529.036539] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  529.043533] pc : __prestera_fi_is_direct+0x2c/0x68 [prestera]
[  529.049318] lr : __prestera_k_arb_fc_apply+0x280/0x2f8 [prestera]
[  529.055452] sp : ffff80000b20bc60
[  529.058781] x29: ffff80000b20bc60 x28: 0000000000000000 x27: ffff0001374d3a48
[  529.065953] x26: ffff000105604000 x25: ffff000134af8a28 x24: ffff0001374d3800
[  529.073126] x23: ffff000101c89148 x22: ffff000101c89148 x21: ffff00013641fda0
[  529.080299] x20: ffff000101c89000 x19: ffff000101c89020 x18: 0000000000000059
[  529.087471] x17: 0000000000000277 x16: 0000000000000000 x15: 0000000000000000
[  529.094642] x14: 0000000000000003 x13: 00000000000fe400 x12: 0000000000000000
[  529.101814] x11: 0000000000000002 x10: 0000000000000aa0 x9 : ffff8000013cee80
[  529.108985] x8 : 0000000000000018 x7 : 000000007b1703f8 x6 : 0000000000000018
[  529.116157] x5 : 00000000d3497eb6 x4 : ffff000105604081 x3 : 000000008e979557
[  529.123329] x2 : 0000000000000000 x1 : ffff00010200de00 x0 : ffff000134ae3f80
[  529.130501] Call trace:
[  529.132958]  __prestera_fi_is_direct+0x2c/0x68 [prestera]
[  529.138394]  prestera_k_arb_fib_evt+0x6b8/0xd50 [prestera]
[  529.143918]  __prestera_router_fib_event_work+0x100/0x158 [prestera]
[  529.150313]  process_one_work+0x208/0x488
[  529.154348]  worker_thread+0x4c/0x430
[  529.158030]  kthread+0x120/0x138
[  529.161274]  ret_from_fork+0x10/0x20
[  529.164867] ---[ end trace 0000000000000000 ]---

and results in a non offloaded route:

    $ ip route
    10.0.0.0/24 dev swp5 proto kernel scope link src 10.0.0.1 rt_trap
    10.0.1.0/24 nhid 20 via 10.0.0.2 dev swp5 rt_trap

When creating a route referencing a nexthop via its ID, the nexthop will
be stored in a separate nh pointer instead of the array of nexthops in
the fib_info struct. This causes issues since fib_info_nh() only handles
the nexthops array, but not the separate nh pointer, and will loudly
WARN about it.

In contrast fib_info_nhc() handles both, but returns a fib_nh_common
pointer instead of a fib_nh pointer. Luckily we only ever access fields
from the fib_nh_common parts, so we can just replace all instances of
fib_info_nh() with fib_info_nhc() and access the fields via their
fib_nh_common names.

This allows handling IPv4 routes with an external nexthop, and they now
get offloaded as expected:

    $ ip route
    10.0.0.0/24 dev swp5 proto kernel scope link src 10.0.0.1 rt_trap
    10.0.1.0/24 nhid 20 via 10.0.0.2 dev swp5 offload rt_offload

Fixes: 396b80cb5c ("net: marvell: prestera: Add neighbour cache accounting")
Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Acked-by: Elad Nachman <enachman@marvell.com>
Link: https://lore.kernel.org/r/20230804101220.247515-1-jonas.gorski@bisdn.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-08-07 19:20:50 -07:00
..
3com 3c589_cs: Fix an error handling path in tc589_probe() 2023-05-22 19:17:58 -07:00
8390 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-05-18 14:39:34 -07:00
actions
adaptec
adi
aeroflex
agere
alacritech
allwinner
alteon
altera net: altera_tse: explicitly disable autoscan on the regmap-mdio bus 2023-06-07 13:30:12 -07:00
amazon net: ena: fix shift-out-of-bounds in exponential backoff 2023-07-12 15:57:57 -07:00
amd pds_core: use vmalloc_array and vcalloc 2023-06-27 09:30:23 -07:00
apm
apple
aquantia net: introduce and use skb_frag_fill_page_desc() 2023-05-13 19:47:56 +01:00
arc net: arc: Make arc_emac_remove() return void 2023-05-19 13:33:28 +01:00
asix
atheros ethernet: atheros: fix return value check in atl1e_tso_csum() 2023-07-24 15:43:02 -07:00
broadcom bnxt_en: Fix max_mtu setting for multi-buf XDP 2023-08-01 15:04:58 -07:00
brocade bna: Remove error checking for debugfs_create_dir() 2023-07-14 09:09:12 +01:00
cadence net: macb: update PCS driver to use neg_mode 2023-06-22 19:41:02 -07:00
calxeda
cavium Networking changes for 6.5. 2023-06-28 16:43:10 -07:00
chelsio sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES) 2023-06-24 15:50:13 -07:00
cirrus net: isa: include net/Space.h 2023-05-17 21:27:30 -07:00
cisco
cortina
davicom spi: Updates for v6.4 2023-04-27 11:02:26 -07:00
dec
dlink
emulex benet: fix return value check in be_lancer_xmit_workarounds() 2023-07-27 10:31:38 +02:00
engleder net/sched: taprio: replace tc_taprio_qopt_offload :: enable with a "cmd" enum 2023-05-31 10:00:30 +01:00
ezchip
faraday
freescale net: fec: tx processing does not call XDP APIs if budget is 0 2023-07-26 21:12:12 -07:00
fujitsu
fungible net: tls: make the offload check helper take skb not socket 2023-06-15 09:01:05 +01:00
google gve: unify driver name usage 2023-07-10 08:29:55 +01:00
hisilicon net: hns3: fix wrong bw weight of disabled tc issue 2023-07-24 09:36:23 +01:00
huawei
i825xx net: ethernet: i825xx: sun3_8256: Add SPDX license identifier 2023-05-16 15:38:07 +02:00
ibm ibmvnic: Do not reset dql stats on NON_FATAL err 2023-06-29 11:12:19 -07:00
intel ice: Fix RDMA VSI removal during queue rebuild 2023-07-31 14:28:21 -07:00
litex net: ethernet: litex: add support for 64 bit stats 2023-06-15 22:56:46 -07:00
marvell net: marvell: prestera: fix handling IPv4 routes with nhid 2023-08-07 19:20:50 -07:00
mediatek net: ethernet: mtk_eth_soc: always mtk_get_ib1_pkt_type 2023-07-19 21:15:04 -07:00
mellanox net/mlx5e: Set proper IPsec source port in L4 selector 2023-08-02 18:38:42 -07:00
micrel
microchip net: lan743x: select FIXED_PHY 2023-07-09 11:23:47 +01:00
microsoft v6.5 merge window RDMA pull request 2023-06-29 21:01:17 -07:00
moxa
mscc drivers:net: fix return value check in ocelot_fdma_receive_skb 2023-07-19 12:27:09 +01:00
myricom net: move gso declarations and functions to their own files 2023-06-10 00:11:41 -07:00
natsemi
neterion
netronome nfp: clean mc addresses in application firmware when closing port 2023-07-05 10:59:12 -07:00
ni
nvidia forcedeth: Fix an error handling path in nv_probe() 2023-05-22 19:17:28 -07:00
nxp
oki-semi net: pch_gbe: Allow build on MIPS_GENERIC kernel 2023-06-08 19:18:32 -07:00
packetengines
pasemi
pensando ionic: Add missing err handling for queue reconfig 2023-08-06 16:44:03 +01:00
qlogic qed: Fix scheduling in a tasklet while getting stats 2023-07-29 17:09:18 +01:00
qualcomm drivers: net: fix return value check in emac_tso_csum() 2023-07-19 12:27:09 +01:00
rdc
realtek Revert "r8169: disable ASPM during NAPI poll" 2023-07-19 21:09:11 -07:00
renesas Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-06-15 22:19:41 -07:00
rocker
samsung net: samsung: sxgbe: Make sxgbe_drv_remove() return void 2023-05-12 08:49:49 +01:00
seeq
sfc sfc: fix field-spanning memcpy in selftest 2023-07-31 14:27:53 -07:00
sgi
silan
sis
smsc
socionext net: netsec: Ignore 'phy-mode' on SynQuacer in DT mode 2023-08-01 14:59:45 -07:00
stmicro net: stmmac: tegra: Properly allocate clock bulk data 2023-07-29 16:59:51 +01:00
sun sunvnet: fix sparc64 build error after gso code split 2023-06-15 22:47:13 -07:00
sunplus
synopsys
tehuti
ti net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()/cpsw_ale_set_field() 2023-07-14 08:36:43 +01:00
toshiba
tundra
vertexcom
via
wangxun net: ethernet: Remove repeating expression 2023-07-14 09:11:10 +01:00
wiznet
xilinx net: ll_temac: fix error checking of irq_of_parse_and_map() 2023-08-01 14:38:17 -07:00
xircom
xscale
dnet.c
dnet.h
ec_bhf.c
ethoc.c
fealnx.c
jme.c
jme.h
Kconfig
korina.c net: korina: handle clk prepare error in korina_probe() 2023-08-01 14:58:34 -07:00
lantiq_etop.c
lantiq_xrx200.c
Makefile