Skip to content

Commit 0894731

Browse files
committed
Merge branch 'mlxsw-spectrum-forward-packets-with-an-ipv4-link-local-source-ip'
Petr Machata says: ==================== 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. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 065c31f + 5e0b217 commit 0894731

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,6 +2375,8 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = {
23752375
ROUTER_EXP, false),
23762376
MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_DIP_LINK_LOCAL, FORWARD,
23772377
ROUTER_EXP, false),
2378+
MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_SIP_LINK_LOCAL, FORWARD,
2379+
ROUTER_EXP, false),
23782380
/* Multicast Router Traps */
23792381
MLXSW_SP_RXL_MARK(ACL1, TRAP_TO_CPU, MULTICAST, false),
23802382
MLXSW_SP_RXL_L3_MARK(ACL2, TRAP_TO_CPU, MULTICAST, false),

drivers/net/ethernet/mellanox/mlxsw/trap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ enum {
9494
MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_SIP_BC = 0x16A,
9595
MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_DIP_LOCAL_NET = 0x16B,
9696
MLXSW_TRAP_ID_DISCARD_ING_ROUTER_DIP_LINK_LOCAL = 0x16C,
97+
MLXSW_TRAP_ID_DISCARD_ING_ROUTER_SIP_LINK_LOCAL = 0x16D,
9798
MLXSW_TRAP_ID_DISCARD_ROUTER_IRIF_EN = 0x178,
9899
MLXSW_TRAP_ID_DISCARD_ROUTER_ERIF_EN = 0x179,
99100
MLXSW_TRAP_ID_DISCARD_ROUTER_LPM4 = 0x17B,

tools/testing/selftests/net/forwarding/router.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# | 2001:db8:1::1/64 2001:db8:2::1/64 |
1919
# | |
2020
# +-----------------------------------------------------------------+
21+
#
22+
#shellcheck disable=SC2034 # SC doesn't see our uses of global variables
2123

2224
ALL_TESTS="
2325
ping_ipv4
@@ -27,6 +29,7 @@ ALL_TESTS="
2729
ipv4_sip_equal_dip
2830
ipv6_sip_equal_dip
2931
ipv4_dip_link_local
32+
ipv4_sip_link_local
3033
"
3134

3235
NUM_NETIFS=4
@@ -330,6 +333,32 @@ ipv4_dip_link_local()
330333
tc filter del dev $rp2 egress protocol ip pref 1 handle 101 flower
331334
}
332335

336+
ipv4_sip_link_local()
337+
{
338+
local sip=169.254.1.1
339+
340+
RET=0
341+
342+
# Disable rpfilter to prevent packets to be dropped because of it.
343+
sysctl_set net.ipv4.conf.all.rp_filter 0
344+
sysctl_set net.ipv4.conf."$rp1".rp_filter 0
345+
346+
tc filter add dev "$rp2" egress protocol ip pref 1 handle 101 \
347+
flower src_ip "$sip" action pass
348+
349+
$MZ "$h1" -t udp "sp=54321,dp=12345" -c 5 -d 1msec -b "$rp1mac" \
350+
-A "$sip" -B 198.51.100.2 -q
351+
352+
tc_check_packets "dev $rp2 egress" 101 5
353+
check_err $? "Packets were dropped"
354+
355+
log_test "IPv4 source IP is link-local"
356+
357+
tc filter del dev "$rp2" egress protocol ip pref 1 handle 101 flower
358+
sysctl_restore net.ipv4.conf."$rp1".rp_filter
359+
sysctl_restore net.ipv4.conf.all.rp_filter
360+
}
361+
333362
trap cleanup EXIT
334363

335364
setup_prepare

0 commit comments

Comments
 (0)