Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Oscar Maes and committed by
Jakub Kicinski
5777d187 9e30ecf2

+48
+1
tools/testing/selftests/net/Makefile
··· 115 115 TEST_GEN_FILES += skf_net_off 116 116 TEST_GEN_FILES += tfo 117 117 TEST_PROGS += tfo_passive.sh 118 + TEST_PROGS += broadcast_pmtu.sh 118 119 119 120 # YNL files, must be before "include ..lib.mk" 120 121 YNL_GEN_FILES := busy_poller netlink-dumps
+47
tools/testing/selftests/net/broadcast_pmtu.sh
··· 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 +