Skip to content

Commit 5777d18

Browse files
oscar-maeskuba-moo
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9e30ecf commit 5777d18

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

tools/testing/selftests/net/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ TEST_PROGS += skf_net_off.sh
115115
TEST_GEN_FILES += skf_net_off
116116
TEST_GEN_FILES += tfo
117117
TEST_PROGS += tfo_passive.sh
118+
TEST_PROGS += broadcast_pmtu.sh
118119

119120
# YNL files, must be before "include ..lib.mk"
120121
YNL_GEN_FILES := busy_poller netlink-dumps
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# Ensures broadcast route MTU is respected
5+
6+
CLIENT_NS=$(mktemp -u client-XXXXXXXX)
7+
CLIENT_IP4="192.168.0.1/24"
8+
CLIENT_BROADCAST_ADDRESS="192.168.0.255"
9+
10+
SERVER_NS=$(mktemp -u server-XXXXXXXX)
11+
SERVER_IP4="192.168.0.2/24"
12+
13+
setup() {
14+
ip netns add "${CLIENT_NS}"
15+
ip netns add "${SERVER_NS}"
16+
17+
ip -net "${SERVER_NS}" link add link1 type veth peer name link0 netns "${CLIENT_NS}"
18+
19+
ip -net "${CLIENT_NS}" link set link0 up
20+
ip -net "${CLIENT_NS}" link set link0 mtu 9000
21+
ip -net "${CLIENT_NS}" addr add "${CLIENT_IP4}" dev link0
22+
23+
ip -net "${SERVER_NS}" link set link1 up
24+
ip -net "${SERVER_NS}" link set link1 mtu 1500
25+
ip -net "${SERVER_NS}" addr add "${SERVER_IP4}" dev link1
26+
27+
read -r -a CLIENT_BROADCAST_ENTRY <<< "$(ip -net "${CLIENT_NS}" route show table local type broadcast)"
28+
ip -net "${CLIENT_NS}" route del "${CLIENT_BROADCAST_ENTRY[@]}"
29+
ip -net "${CLIENT_NS}" route add "${CLIENT_BROADCAST_ENTRY[@]}" mtu 1500
30+
31+
ip net exec "${SERVER_NS}" sysctl -wq net.ipv4.icmp_echo_ignore_broadcasts=0
32+
}
33+
34+
cleanup() {
35+
ip -net "${SERVER_NS}" link del link1
36+
ip netns del "${CLIENT_NS}"
37+
ip netns del "${SERVER_NS}"
38+
}
39+
40+
trap cleanup EXIT
41+
42+
setup &&
43+
echo "Testing for broadcast route MTU" &&
44+
ip net exec "${CLIENT_NS}" ping -f -M want -q -c 1 -s 8000 -w 1 -b "${CLIENT_BROADCAST_ADDRESS}" > /dev/null 2>&1
45+
46+
exit $?
47+

0 commit comments

Comments
 (0)