selftest: forwarding: router: Add a test case for IPv4 link-local source IP

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>
Link: https://patch.msgid.link/3c2e0b17d99530f57bef5ddff9af284fa0c9b667.1755174341.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Ido Schimmel
2025-08-15 10:44:48 -07:00
committed by Jakub Kicinski
parent f604d3aaf6
commit 5e0b2177bd
@@ -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