mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 15:39:42 -04:00
selftests: net: add test for variable PMTU in broadcast routes
Added a test for variable PMTU in broadcast routes. This test uses iputils' ping and attempts to send a ping between two peers, which should result in a regular echo reply. This test will fail when the receiving peer does not receive the echo request due to a lack of packet fragmentation. Signed-off-by: Oscar Maes <oscmaes92@gmail.com> Link: https://patch.msgid.link/20250710142714.12986-2-oscmaes92@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
9e30ecf23b
commit
5777d1871b
@@ -115,6 +115,7 @@ TEST_PROGS += skf_net_off.sh
|
||||
TEST_GEN_FILES += skf_net_off
|
||||
TEST_GEN_FILES += tfo
|
||||
TEST_PROGS += tfo_passive.sh
|
||||
TEST_PROGS += broadcast_pmtu.sh
|
||||
|
||||
# YNL files, must be before "include ..lib.mk"
|
||||
YNL_GEN_FILES := busy_poller netlink-dumps
|
||||
|
||||
47
tools/testing/selftests/net/broadcast_pmtu.sh
Executable file
47
tools/testing/selftests/net/broadcast_pmtu.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Ensures broadcast route MTU is respected
|
||||
|
||||
CLIENT_NS=$(mktemp -u client-XXXXXXXX)
|
||||
CLIENT_IP4="192.168.0.1/24"
|
||||
CLIENT_BROADCAST_ADDRESS="192.168.0.255"
|
||||
|
||||
SERVER_NS=$(mktemp -u server-XXXXXXXX)
|
||||
SERVER_IP4="192.168.0.2/24"
|
||||
|
||||
setup() {
|
||||
ip netns add "${CLIENT_NS}"
|
||||
ip netns add "${SERVER_NS}"
|
||||
|
||||
ip -net "${SERVER_NS}" link add link1 type veth peer name link0 netns "${CLIENT_NS}"
|
||||
|
||||
ip -net "${CLIENT_NS}" link set link0 up
|
||||
ip -net "${CLIENT_NS}" link set link0 mtu 9000
|
||||
ip -net "${CLIENT_NS}" addr add "${CLIENT_IP4}" dev link0
|
||||
|
||||
ip -net "${SERVER_NS}" link set link1 up
|
||||
ip -net "${SERVER_NS}" link set link1 mtu 1500
|
||||
ip -net "${SERVER_NS}" addr add "${SERVER_IP4}" dev link1
|
||||
|
||||
read -r -a CLIENT_BROADCAST_ENTRY <<< "$(ip -net "${CLIENT_NS}" route show table local type broadcast)"
|
||||
ip -net "${CLIENT_NS}" route del "${CLIENT_BROADCAST_ENTRY[@]}"
|
||||
ip -net "${CLIENT_NS}" route add "${CLIENT_BROADCAST_ENTRY[@]}" mtu 1500
|
||||
|
||||
ip net exec "${SERVER_NS}" sysctl -wq net.ipv4.icmp_echo_ignore_broadcasts=0
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
ip -net "${SERVER_NS}" link del link1
|
||||
ip netns del "${CLIENT_NS}"
|
||||
ip netns del "${SERVER_NS}"
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
setup &&
|
||||
echo "Testing for broadcast route MTU" &&
|
||||
ip net exec "${CLIENT_NS}" ping -f -M want -q -c 1 -s 8000 -w 1 -b "${CLIENT_BROADCAST_ADDRESS}" > /dev/null 2>&1
|
||||
|
||||
exit $?
|
||||
|
||||
Reference in New Issue
Block a user