mlxsw: spectrum: Forward packets with an IPv4 link-local source IP
Subsystems (5)
Petr Machata
maintainerv2 cover mlxsw: spectrum: Forward packets with an IPv4 link-local source IP
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(+)
Signature · 1 line
2.49.0
Petr Machata
maintainerPATCH v2 1/2 mlxsw: spectrum: Forward packets with an IPv4 link-local source IP
From: Ido Schimmel <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 ++ drivers/net/ethernet/mellanox/mlxsw/trap.h | 1 + 2 files changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +2 -0
@@ -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),
drivers/net/ethernet/mellanox/mlxsw/trap.h +1 -0
@@ -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,
Signature · 1 line
2.49.0
Petr Machata
maintainerPATCH v2 2/2 selftest: forwarding: router: Add a test case for IPv4 link-local source IP
In reply to Petr MachataFrom: Ido Schimmel <[email protected]>
Add a test case which checks that packets with an IPv4 link-local source IP are forwarded and not dropped.
--- .../selftests/net/forwarding/router.sh | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+)
tools/testing/selftests/net/forwarding/router.sh +29 -0
@@ -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
Signature · 1 line
2.49.0
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · 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: disablerp_filterto 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html