Skip to content

Commit 5e0b217

Browse files
idoschkuba-moo
authored andcommitted
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 <[email protected]> Signed-off-by: Petr Machata <[email protected]> Link: https://patch.msgid.link/3c2e0b17d99530f57bef5ddff9af284fa0c9b667.1755174341.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f604d3a commit 5e0b217

File tree

1 file changed

+29
-0
lines changed
  • tools/testing/selftests/net/forwarding

1 file changed

+29
-0
lines changed

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)