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 tests for PPP

Add ping and iperf3 tests for ppp_async.c and pppoe.c.

Signed-off-by: Qingfang Deng <qingfang.deng@linux.dev>
Link: https://patch.msgid.link/20260403034908.30017-1-qingfang.deng@linux.dev
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Qingfang Deng and committed by
Paolo Abeni
dfecb0c5 c149d90e

+181
+1
MAINTAINERS
··· 21083 21083 L: linux-ppp@vger.kernel.org 21084 21084 S: Orphan 21085 21085 F: drivers/net/ppp/ppp_* 21086 + F: tools/testing/selftests/net/ppp/ 21086 21087 21087 21088 PPS SUPPORT 21088 21089 M: Rodolfo Giometti <giometti@enneenne.com>
+1
tools/testing/selftests/Makefile
··· 78 78 TARGETS += net/openvswitch 79 79 TARGETS += net/ovpn 80 80 TARGETS += net/packetdrill 81 + TARGETS += net/ppp 81 82 TARGETS += net/rds 82 83 TARGETS += net/tcp_ao 83 84 TARGETS += nolibc
+15
tools/testing/selftests/net/ppp/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + top_srcdir = ../../../../.. 4 + 5 + TEST_PROGS := \ 6 + ppp_async.sh \ 7 + pppoe.sh \ 8 + # end of TEST_PROGS 9 + 10 + TEST_FILES := \ 11 + ppp_common.sh \ 12 + pppoe-server-options \ 13 + # end of TEST_FILES 14 + 15 + include ../../lib.mk
+9
tools/testing/selftests/net/ppp/config
··· 1 + CONFIG_IPV6=y 2 + CONFIG_PACKET=y 3 + CONFIG_PPP=m 4 + CONFIG_PPP_ASYNC=m 5 + CONFIG_PPP_BSDCOMP=m 6 + CONFIG_PPP_DEFLATE=m 7 + CONFIG_PPPOE=m 8 + CONFIG_PPPOE_HASH_BITS_4=y 9 + CONFIG_VETH=y
+43
tools/testing/selftests/net/ppp/ppp_async.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + source ppp_common.sh 5 + 6 + # Temporary files for PTY symlinks 7 + TTY_DIR=$(mktemp -d /tmp/ppp.XXXXXX) 8 + TTY_SERVER="$TTY_DIR"/server 9 + TTY_CLIENT="$TTY_DIR"/client 10 + 11 + # shellcheck disable=SC2329 12 + cleanup() { 13 + cleanup_all_ns 14 + [ -n "$SOCAT_PID" ] && kill_process "$SOCAT_PID" 15 + rm -fr "$TTY_DIR" 16 + } 17 + 18 + trap cleanup EXIT 19 + 20 + ppp_common_init 21 + modprobe -q ppp_async 22 + 23 + # Create the virtual serial device 24 + socat -d PTY,link="$TTY_SERVER",rawer PTY,link="$TTY_CLIENT",rawer & 25 + SOCAT_PID=$! 26 + 27 + # Wait for symlinks to be created 28 + slowwait 5 [ -L "$TTY_SERVER" ] 29 + 30 + # Start the PPP Server 31 + ip netns exec "$NS_SERVER" pppd "$TTY_SERVER" 115200 \ 32 + "$IP_SERVER":"$IP_CLIENT" \ 33 + local noauth nodefaultroute debug 34 + 35 + # Start the PPP Client 36 + ip netns exec "$NS_CLIENT" pppd "$TTY_CLIENT" 115200 \ 37 + local noauth updetach nodefaultroute debug 38 + 39 + ppp_test_connectivity 40 + 41 + log_test "PPP async" 42 + 43 + exit "$EXIT_STATUS"
+45
tools/testing/selftests/net/ppp/ppp_common.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + # shellcheck disable=SC2153 4 + 5 + source ../lib.sh 6 + 7 + IP_SERVER="192.168.200.1" 8 + IP_CLIENT="192.168.200.2" 9 + 10 + ppp_common_init() { 11 + # Package requirements 12 + require_command socat 13 + require_command pppd 14 + require_command iperf3 15 + 16 + # Check for root privileges 17 + if [ "$(id -u)" -ne 0 ];then 18 + echo "SKIP: Need root privileges" 19 + exit "$ksft_skip" 20 + fi 21 + 22 + # Namespaces 23 + setup_ns NS_SERVER NS_CLIENT 24 + } 25 + 26 + ppp_check_addr() { 27 + dev=$1 28 + addr=$2 29 + ns=$3 30 + ip -netns "$ns" -4 addr show dev "$dev" 2>/dev/null | grep -q "$addr" 31 + return $? 32 + } 33 + 34 + ppp_test_connectivity() { 35 + slowwait 10 ppp_check_addr "ppp0" "$IP_CLIENT" "$NS_CLIENT" 36 + 37 + ip netns exec "$NS_CLIENT" ping -c 3 "$IP_SERVER" 38 + check_err $? 39 + 40 + ip netns exec "$NS_SERVER" iperf3 -s -1 -D 41 + wait_local_port_listen "$NS_SERVER" 5201 tcp 42 + 43 + ip netns exec "$NS_CLIENT" iperf3 -c "$IP_SERVER" -Z -t 2 44 + check_err $? 45 + }
+2
tools/testing/selftests/net/ppp/pppoe-server-options
··· 1 + noauth 2 + noipdefault
+65
tools/testing/selftests/net/ppp/pppoe.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + source ppp_common.sh 5 + 6 + VETH_SERVER="veth-server" 7 + VETH_CLIENT="veth-client" 8 + PPPOE_LOG=$(mktemp /tmp/pppoe.XXXXXX) 9 + 10 + # shellcheck disable=SC2329 11 + cleanup() { 12 + cleanup_all_ns 13 + [ -n "$SOCAT_PID" ] && kill_process "$SOCAT_PID" 14 + rm -f "$PPPOE_LOG" 15 + } 16 + 17 + trap cleanup EXIT 18 + 19 + require_command pppoe-server 20 + ppp_common_init 21 + modprobe -q pppoe 22 + 23 + # Try to locate pppoe.so plugin 24 + PPPOE_PLUGIN=$(find /usr/{lib,lib64,lib32}/pppd/ -name pppoe.so -type f -print -quit) 25 + if [ -z "$PPPOE_PLUGIN" ]; then 26 + log_test_skip "PPPoE: pppoe.so plugin not found" 27 + exit "$EXIT_STATUS" 28 + fi 29 + 30 + # Create the veth pair 31 + ip link add "$VETH_SERVER" type veth peer name "$VETH_CLIENT" 32 + ip link set "$VETH_SERVER" netns "$NS_SERVER" 33 + ip link set "$VETH_CLIENT" netns "$NS_CLIENT" 34 + ip -netns "$NS_SERVER" link set "$VETH_SERVER" up 35 + ip -netns "$NS_CLIENT" link set "$VETH_CLIENT" up 36 + 37 + # Start socat as syslog listener 38 + socat -v -u UNIX-RECV:/dev/log OPEN:/dev/null > "$PPPOE_LOG" 2>&1 & 39 + SOCAT_PID=$! 40 + 41 + # Start the PPP Server. Note that versions before 4.0 ignore -g option and 42 + # instead use a hardcoded plugin path, so they may fail to find the plugin. 43 + ip netns exec "$NS_SERVER" pppoe-server -I "$VETH_SERVER" \ 44 + -L "$IP_SERVER" -R "$IP_CLIENT" -N 1 -q "$(command -v pppd)" \ 45 + -k -O "$(pwd)/pppoe-server-options" -g "$PPPOE_PLUGIN" 46 + 47 + # Start the PPP Client 48 + ip netns exec "$NS_CLIENT" pppd \ 49 + local debug updetach noipdefault noauth nodefaultroute \ 50 + plugin "$PPPOE_PLUGIN" nic-"$VETH_CLIENT" 51 + 52 + ppp_test_connectivity 53 + 54 + log_test "PPPoE" 55 + 56 + # Dump syslog messages if the test failed 57 + if [ "$RET" -ne 0 ]; then 58 + while read -r _sign _date _time len _from _to 59 + do len=${len##*=} 60 + read -n "$len" -r LINE 61 + echo "$LINE" 62 + done < "$PPPOE_LOG" 63 + fi 64 + 65 + exit "$EXIT_STATUS"