From nobody Sat Apr 4 00:20:35 2026 Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F63A1DDA18 for ; Fri, 3 Apr 2026 03:49:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775188177; cv=none; b=DZNldhK8pCzOPp2i7kexe+L9utVzJ8YYMJ3EvmnW02IZGe88EnGYqdOU7G0IAtVwXaOIio1XuXr0yvj6Z33y3ELsBKfm9qsTYs3Jc63drQrPLMBnQmrW6EwyFXzL4Fqamu38yt/UP0auCBVQNhuvvHypyTJW0vPm0HTxO1JsPZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775188177; c=relaxed/simple; bh=YFkuOCnrJpzDB0Z5a3xx3tq1/XaMpLmaUp4WPCCuAOE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=K0smhc0Y06OQNr8Oe0rAnVqa1VnlqtYaQisRG7tLCs5yDlyfua4xjxtZOCd9sLd7wpBOzRb0RMc9ozYdhMPyN+HX4/dwa1yUORkcVuyUI/+hoqEh6UB6wOfNiL5CLO7xFL5znUYNMbxm0r00ORVLE9+yPePCtbim2PiSER7Y7Hw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=K2Q6BhAr; arc=none smtp.client-ip=95.215.58.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="K2Q6BhAr" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1775188162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=sVqEFwMZ86bS0uTEmuMewmHsbzVj9vG2EZxLHT6aEYw=; b=K2Q6BhArTwDCDJwXi0UpTLj4IFN21DwvtE5BEeNrWo9Hs53mp019xmw8xYi28IpCzMYZJx vQLzWb+zQ7f+pAa90n33Kb44J44sEDGG79EuPEhKJK0E3PzdQ1B0NuXYYSij+hnzI9Xcz0 m+f3gk+NbpEtjAm2TUw0X+hTdyZjWyE= From: Qingfang Deng To: linux-ppp@vger.kernel.org, Shuah Khan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Sebastian Andrzej Siewior , Felix Maurer , Qingfang Deng , Petr Machata , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org Cc: Paul Mackerras , Dianne Skoll , Jaco Kroon , James Carlson , Andrew Lunn Subject: [PATCH net-next v8] selftests: net: add tests for PPP Date: Fri, 3 Apr 2026 11:48:47 +0800 Message-ID: <20260403034908.30017-1-qingfang.deng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Add ping and iperf3 tests for ppp_async.c and pppoe.c. Signed-off-by: Qingfang Deng --- v8: - locate pppoe.so and pass it to pppoe-server - start socat as a syslog listener and dump the log messages if the test f= ails https://lore.kernel.org/netdev/20260330035604.133073-1-dqfext@gmail.com/ MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/net/ppp/Makefile | 15 +++++ tools/testing/selftests/net/ppp/config | 9 +++ tools/testing/selftests/net/ppp/ppp_async.sh | 43 ++++++++++++ tools/testing/selftests/net/ppp/ppp_common.sh | 45 +++++++++++++ .../selftests/net/ppp/pppoe-server-options | 2 + tools/testing/selftests/net/ppp/pppoe.sh | 65 +++++++++++++++++++ 8 files changed, 181 insertions(+) create mode 100644 tools/testing/selftests/net/ppp/Makefile create mode 100644 tools/testing/selftests/net/ppp/config create mode 100755 tools/testing/selftests/net/ppp/ppp_async.sh create mode 100644 tools/testing/selftests/net/ppp/ppp_common.sh create mode 100644 tools/testing/selftests/net/ppp/pppoe-server-options create mode 100755 tools/testing/selftests/net/ppp/pppoe.sh diff --git a/MAINTAINERS b/MAINTAINERS index c583c5478ef6..c92bfed47ead 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21089,6 +21089,7 @@ PPP PROTOCOL DRIVERS AND COMPRESSORS L: linux-ppp@vger.kernel.org S: Orphan F: drivers/net/ppp/ppp_* +F: tools/testing/selftests/net/ppp/ =20 PPS SUPPORT M: Rodolfo Giometti diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Mak= efile index 450f13ba4cca..65f84e8a0cf0 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -78,6 +78,7 @@ TARGETS +=3D net/netfilter TARGETS +=3D net/openvswitch TARGETS +=3D net/ovpn TARGETS +=3D net/packetdrill +TARGETS +=3D net/ppp TARGETS +=3D net/rds TARGETS +=3D net/tcp_ao TARGETS +=3D nolibc diff --git a/tools/testing/selftests/net/ppp/Makefile b/tools/testing/selft= ests/net/ppp/Makefile new file mode 100644 index 000000000000..b39b0abadde6 --- /dev/null +++ b/tools/testing/selftests/net/ppp/Makefile @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0 + +top_srcdir =3D ../../../../.. + +TEST_PROGS :=3D \ + ppp_async.sh \ + pppoe.sh \ +# end of TEST_PROGS + +TEST_FILES :=3D \ + ppp_common.sh \ + pppoe-server-options \ +# end of TEST_FILES + +include ../../lib.mk diff --git a/tools/testing/selftests/net/ppp/config b/tools/testing/selftes= ts/net/ppp/config new file mode 100644 index 000000000000..b45d25c5b970 --- /dev/null +++ b/tools/testing/selftests/net/ppp/config @@ -0,0 +1,9 @@ +CONFIG_IPV6=3Dy +CONFIG_PACKET=3Dy +CONFIG_PPP=3Dm +CONFIG_PPP_ASYNC=3Dm +CONFIG_PPP_BSDCOMP=3Dm +CONFIG_PPP_DEFLATE=3Dm +CONFIG_PPPOE=3Dm +CONFIG_PPPOE_HASH_BITS_4=3Dy +CONFIG_VETH=3Dy diff --git a/tools/testing/selftests/net/ppp/ppp_async.sh b/tools/testing/s= elftests/net/ppp/ppp_async.sh new file mode 100755 index 000000000000..10f54c8dd0bc --- /dev/null +++ b/tools/testing/selftests/net/ppp/ppp_async.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source ppp_common.sh + +# Temporary files for PTY symlinks +TTY_DIR=3D$(mktemp -d /tmp/ppp.XXXXXX) +TTY_SERVER=3D"$TTY_DIR"/server +TTY_CLIENT=3D"$TTY_DIR"/client + +# shellcheck disable=3DSC2329 +cleanup() { + cleanup_all_ns + [ -n "$SOCAT_PID" ] && kill_process "$SOCAT_PID" + rm -fr "$TTY_DIR" +} + +trap cleanup EXIT + +ppp_common_init +modprobe -q ppp_async + +# Create the virtual serial device +socat -d PTY,link=3D"$TTY_SERVER",rawer PTY,link=3D"$TTY_CLIENT",rawer & +SOCAT_PID=3D$! + +# Wait for symlinks to be created +slowwait 5 [ -L "$TTY_SERVER" ] + +# Start the PPP Server +ip netns exec "$NS_SERVER" pppd "$TTY_SERVER" 115200 \ + "$IP_SERVER":"$IP_CLIENT" \ + local noauth nodefaultroute debug + +# Start the PPP Client +ip netns exec "$NS_CLIENT" pppd "$TTY_CLIENT" 115200 \ + local noauth updetach nodefaultroute debug + +ppp_test_connectivity + +log_test "PPP async" + +exit "$EXIT_STATUS" diff --git a/tools/testing/selftests/net/ppp/ppp_common.sh b/tools/testing/= selftests/net/ppp/ppp_common.sh new file mode 100644 index 000000000000..40bbec317039 --- /dev/null +++ b/tools/testing/selftests/net/ppp/ppp_common.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# shellcheck disable=3DSC2153 + +source ../lib.sh + +IP_SERVER=3D"192.168.200.1" +IP_CLIENT=3D"192.168.200.2" + +ppp_common_init() { + # Package requirements + require_command socat + require_command pppd + require_command iperf3 + + # Check for root privileges + if [ "$(id -u)" -ne 0 ];then + echo "SKIP: Need root privileges" + exit "$ksft_skip" + fi + + # Namespaces + setup_ns NS_SERVER NS_CLIENT +} + +ppp_check_addr() { + dev=3D$1 + addr=3D$2 + ns=3D$3 + ip -netns "$ns" -4 addr show dev "$dev" 2>/dev/null | grep -q "$addr" + return $? +} + +ppp_test_connectivity() { + slowwait 10 ppp_check_addr "ppp0" "$IP_CLIENT" "$NS_CLIENT" + + ip netns exec "$NS_CLIENT" ping -c 3 "$IP_SERVER" + check_err $? + + ip netns exec "$NS_SERVER" iperf3 -s -1 -D + wait_local_port_listen "$NS_SERVER" 5201 tcp + + ip netns exec "$NS_CLIENT" iperf3 -c "$IP_SERVER" -Z -t 2 + check_err $? +} diff --git a/tools/testing/selftests/net/ppp/pppoe-server-options b/tools/t= esting/selftests/net/ppp/pppoe-server-options new file mode 100644 index 000000000000..66c8c9d319e9 --- /dev/null +++ b/tools/testing/selftests/net/ppp/pppoe-server-options @@ -0,0 +1,2 @@ +noauth +noipdefault diff --git a/tools/testing/selftests/net/ppp/pppoe.sh b/tools/testing/selft= ests/net/ppp/pppoe.sh new file mode 100755 index 000000000000..f67b51df7490 --- /dev/null +++ b/tools/testing/selftests/net/ppp/pppoe.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source ppp_common.sh + +VETH_SERVER=3D"veth-server" +VETH_CLIENT=3D"veth-client" +PPPOE_LOG=3D$(mktemp /tmp/pppoe.XXXXXX) + +# shellcheck disable=3DSC2329 +cleanup() { + cleanup_all_ns + [ -n "$SOCAT_PID" ] && kill_process "$SOCAT_PID" + rm -f "$PPPOE_LOG" +} + +trap cleanup EXIT + +require_command pppoe-server +ppp_common_init +modprobe -q pppoe + +# Try to locate pppoe.so plugin +PPPOE_PLUGIN=3D$(find /usr/{lib,lib64,lib32}/pppd/ -name pppoe.so -type f = -print -quit) +if [ -z "$PPPOE_PLUGIN" ]; then + log_test_skip "PPPoE: pppoe.so plugin not found" + exit "$EXIT_STATUS" +fi + +# Create the veth pair +ip link add "$VETH_SERVER" type veth peer name "$VETH_CLIENT" +ip link set "$VETH_SERVER" netns "$NS_SERVER" +ip link set "$VETH_CLIENT" netns "$NS_CLIENT" +ip -netns "$NS_SERVER" link set "$VETH_SERVER" up +ip -netns "$NS_CLIENT" link set "$VETH_CLIENT" up + +# Start socat as syslog listener +socat -v -u UNIX-RECV:/dev/log OPEN:/dev/null > "$PPPOE_LOG" 2>&1 & +SOCAT_PID=3D$! + +# Start the PPP Server. Note that versions before 4.0 ignore -g option and +# instead use a hardcoded plugin path, so they may fail to find the plugin. +ip netns exec "$NS_SERVER" pppoe-server -I "$VETH_SERVER" \ + -L "$IP_SERVER" -R "$IP_CLIENT" -N 1 -q "$(command -v pppd)" \ + -k -O "$(pwd)/pppoe-server-options" -g "$PPPOE_PLUGIN" + +# Start the PPP Client +ip netns exec "$NS_CLIENT" pppd \ + local debug updetach noipdefault noauth nodefaultroute \ + plugin "$PPPOE_PLUGIN" nic-"$VETH_CLIENT" + +ppp_test_connectivity + +log_test "PPPoE" + +# Dump syslog messages if the test failed +if [ "$RET" -ne 0 ]; then + while read -r _sign _date _time len _from _to + do len=3D${len##*=3D} + read -n "$len" -r LINE + echo "$LINE" + done < "$PPPOE_LOG" +fi + +exit "$EXIT_STATUS" --=20 2.43.0