netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] mlxsw: spectrum: Forward packets with an IPv4 link-local source IP
@ 2025-08-14 13:06 Petr Machata
  2025-08-14 13:06 ` [PATCH net v2 1/2] " Petr Machata
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Petr Machata @ 2025-08-14 13:06 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, netdev
  Cc: Simon Horman, Ido Schimmel, Petr Machata, Jiri Pirko, mlxsw

By default, Spectrum devices do not forward IPv4 packets with a link-local
source IP (i.e., 169.254.0.0/16). This behavior does not align with the
kernel which does forward them. Fix the issue and add a selftest.

v2:
- Patch #2: disable rp_filter to prevent packets from getting dropped
  on ingress.

Ido Schimmel (2):
  mlxsw: spectrum: Forward packets with an IPv4 link-local source IP
  selftest: forwarding: router: Add a test case for IPv4 link-local
    source IP

 .../net/ethernet/mellanox/mlxsw/spectrum.c    |  2 ++
 drivers/net/ethernet/mellanox/mlxsw/trap.h    |  1 +
 .../selftests/net/forwarding/router.sh        | 29 +++++++++++++++++++
 3 files changed, 32 insertions(+)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net v2 1/2] mlxsw: spectrum: Forward packets with an IPv4 link-local source IP
  2025-08-14 13:06 [PATCH net v2 0/2] mlxsw: spectrum: Forward packets with an IPv4 link-local source IP Petr Machata
@ 2025-08-14 13:06 ` Petr Machata
  2025-08-14 13:06 ` [PATCH net v2 2/2] selftest: forwarding: router: Add a test case for " Petr Machata
  2025-08-15 18:09 ` [PATCH net v2 0/2] mlxsw: spectrum: Forward packets with an " patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Petr Machata @ 2025-08-14 13:06 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, netdev
  Cc: Simon Horman, Ido Schimmel, Petr Machata, Jiri Pirko, mlxsw,
	Zoey Mertes

From: Ido Schimmel <idosch@nvidia.com>

By default, the device does not forward IPv4 packets with a link-local
source IP (i.e., 169.254.0.0/16). This behavior does not align with the
kernel which does forward them.

Fix by instructing the device to forward such packets instead of
dropping them.

Fixes: ca360db4b825 ("mlxsw: spectrum: Disable DIP_LINK_LOCAL check in hardware pipeline")
Reported-by: Zoey Mertes <zoey@cloudflare.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 ++
 drivers/net/ethernet/mellanox/mlxsw/trap.h     | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 618957d65663..9a2d64a0a858 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -2375,6 +2375,8 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = {
 			     ROUTER_EXP, false),
 	MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_DIP_LINK_LOCAL, FORWARD,
 			     ROUTER_EXP, false),
+	MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_SIP_LINK_LOCAL, FORWARD,
+			     ROUTER_EXP, false),
 	/* Multicast Router Traps */
 	MLXSW_SP_RXL_MARK(ACL1, TRAP_TO_CPU, MULTICAST, false),
 	MLXSW_SP_RXL_L3_MARK(ACL2, TRAP_TO_CPU, MULTICAST, false),
diff --git a/drivers/net/ethernet/mellanox/mlxsw/trap.h b/drivers/net/ethernet/mellanox/mlxsw/trap.h
index 80ee5c4825dc..9962dc157901 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/trap.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/trap.h
@@ -94,6 +94,7 @@ enum {
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_SIP_BC = 0x16A,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_DIP_LOCAL_NET = 0x16B,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_DIP_LINK_LOCAL = 0x16C,
+	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_SIP_LINK_LOCAL = 0x16D,
 	MLXSW_TRAP_ID_DISCARD_ROUTER_IRIF_EN = 0x178,
 	MLXSW_TRAP_ID_DISCARD_ROUTER_ERIF_EN = 0x179,
 	MLXSW_TRAP_ID_DISCARD_ROUTER_LPM4 = 0x17B,
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net v2 2/2] selftest: forwarding: router: Add a test case for IPv4 link-local source IP
  2025-08-14 13:06 [PATCH net v2 0/2] mlxsw: spectrum: Forward packets with an IPv4 link-local source IP Petr Machata
  2025-08-14 13:06 ` [PATCH net v2 1/2] " Petr Machata
@ 2025-08-14 13:06 ` Petr Machata
  2025-08-15 18:09 ` [PATCH net v2 0/2] mlxsw: spectrum: Forward packets with an " patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Petr Machata @ 2025-08-14 13:06 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, netdev
  Cc: Simon Horman, Ido Schimmel, Petr Machata, Jiri Pirko, mlxsw

From: Ido Schimmel <idosch@nvidia.com>

Add a test case which checks that packets with an IPv4 link-local source
IP are forwarded and not dropped.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 .../selftests/net/forwarding/router.sh        | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/tools/testing/selftests/net/forwarding/router.sh b/tools/testing/selftests/net/forwarding/router.sh
index b98ea9449b8b..dfb6646cb97b 100755
--- a/tools/testing/selftests/net/forwarding/router.sh
+++ b/tools/testing/selftests/net/forwarding/router.sh
@@ -18,6 +18,8 @@
 # | 2001:db8:1::1/64                             2001:db8:2::1/64   |
 # |                                                                 |
 # +-----------------------------------------------------------------+
+#
+#shellcheck disable=SC2034 # SC doesn't see our uses of global variables
 
 ALL_TESTS="
 	ping_ipv4
@@ -27,6 +29,7 @@ ALL_TESTS="
 	ipv4_sip_equal_dip
 	ipv6_sip_equal_dip
 	ipv4_dip_link_local
+	ipv4_sip_link_local
 "
 
 NUM_NETIFS=4
@@ -330,6 +333,32 @@ ipv4_dip_link_local()
 	tc filter del dev $rp2 egress protocol ip pref 1 handle 101 flower
 }
 
+ipv4_sip_link_local()
+{
+	local sip=169.254.1.1
+
+	RET=0
+
+	# Disable rpfilter to prevent packets to be dropped because of it.
+	sysctl_set net.ipv4.conf.all.rp_filter 0
+	sysctl_set net.ipv4.conf."$rp1".rp_filter 0
+
+	tc filter add dev "$rp2" egress protocol ip pref 1 handle 101 \
+		flower src_ip "$sip" action pass
+
+	$MZ "$h1" -t udp "sp=54321,dp=12345" -c 5 -d 1msec -b "$rp1mac" \
+		-A "$sip" -B 198.51.100.2 -q
+
+	tc_check_packets "dev $rp2 egress" 101 5
+	check_err $? "Packets were dropped"
+
+	log_test "IPv4 source IP is link-local"
+
+	tc filter del dev "$rp2" egress protocol ip pref 1 handle 101 flower
+	sysctl_restore net.ipv4.conf."$rp1".rp_filter
+	sysctl_restore net.ipv4.conf.all.rp_filter
+}
+
 trap cleanup EXIT
 
 setup_prepare
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2 0/2] mlxsw: spectrum: Forward packets with an IPv4 link-local source IP
  2025-08-14 13:06 [PATCH net v2 0/2] mlxsw: spectrum: Forward packets with an IPv4 link-local source IP Petr Machata
  2025-08-14 13:06 ` [PATCH net v2 1/2] " Petr Machata
  2025-08-14 13:06 ` [PATCH net v2 2/2] selftest: forwarding: router: Add a test case for " Petr Machata
@ 2025-08-15 18:09 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-15 18:09 UTC (permalink / raw)
  To: Petr Machata
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, netdev, horms,
	idosch, jiri, mlxsw

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 14 Aug 2025 15:06:39 +0200 you wrote:
> By default, Spectrum devices do not forward IPv4 packets with a link-local
> source IP (i.e., 169.254.0.0/16). This behavior does not align with the
> kernel which does forward them. Fix the issue and add a selftest.
> 
> v2:
> - Patch #2: disable rp_filter to prevent packets from getting dropped
>   on ingress.
> 
> [...]

Here is the summary with links:
  - [net,v2,1/2] mlxsw: spectrum: Forward packets with an IPv4 link-local source IP
    https://git.kernel.org/netdev/net/c/f604d3aaf64f
  - [net,v2,2/2] selftest: forwarding: router: Add a test case for IPv4 link-local source IP
    https://git.kernel.org/netdev/net/c/5e0b2177bdba

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-15 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 13:06 [PATCH net v2 0/2] mlxsw: spectrum: Forward packets with an IPv4 link-local source IP Petr Machata
2025-08-14 13:06 ` [PATCH net v2 1/2] " Petr Machata
2025-08-14 13:06 ` [PATCH net v2 2/2] selftest: forwarding: router: Add a test case for " Petr Machata
2025-08-15 18:09 ` [PATCH net v2 0/2] mlxsw: spectrum: Forward packets with an " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).