mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julius Bairaktaris <julius@bairaktaris.de>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Qingfang Deng <qingfang.deng@linux.dev>,
	Guillaume Nault <gnault@redhat.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Haoli Zhang <26031212468@stu.xidian.edu.cn>,
	linux-ppp@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH net-next 3/3] selftests: net: ppp: send on PPPoE from every CPU at once
Date: Sun, 29 Nov 2026 15:43:19 +0100	[thread overview]
Message-ID: <20261129144319.1489366-4-julius@bairaktaris.de> (raw)
In-Reply-To: <20261129144319.1489366-1-julius@bairaktaris.de>

Run one iperf3 stream per CPU, each pinned with taskset, over the PPPoE
session. Count the IPv4 and IPv6 session frames leaving the client's
veth with flower filters and check that they match the frames and bytes
ppp0 counted. A frame sent while the counters are read can be counted by
only one of them, so they are read until two reads 100 ms apart agree.
This covers concurrent use of the PPP transmit path and its per-CPU
statistics.

Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
 tools/testing/selftests/net/ppp/config   |  4 ++
 tools/testing/selftests/net/ppp/pppoe.sh | 83 ++++++++++++++++++++++++
 2 files changed, 87 insertions(+)

diff --git a/tools/testing/selftests/net/ppp/config b/tools/testing/selftests/net/ppp/config
index 843545df8f03..e7ba52a36026 100644
--- a/tools/testing/selftests/net/ppp/config
+++ b/tools/testing/selftests/net/ppp/config
@@ -1,5 +1,9 @@
 CONFIG_IPV6=y
 CONFIG_L2TP=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_CLS_FLOWER=m
+CONFIG_NET_SCH_INGRESS=m
 CONFIG_PACKET=y
 CONFIG_PPP=m
 CONFIG_PPP_ASYNC=m
diff --git a/tools/testing/selftests/net/ppp/pppoe.sh b/tools/testing/selftests/net/ppp/pppoe.sh
index f67b51df7490..93c8dbb58818 100755
--- a/tools/testing/selftests/net/ppp/pppoe.sh
+++ b/tools/testing/selftests/net/ppp/pppoe.sh
@@ -17,6 +17,8 @@ cleanup() {
 trap cleanup EXIT
 
 require_command pppoe-server
+require_command taskset
+require_command jq
 ppp_common_init
 modprobe -q pppoe
 
@@ -34,6 +36,82 @@ 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
 
+# Print the client's ppp0 transmit counters, then those of the IPv4 and
+# IPv6 PPPoE session frames leaving its veth. PPP control frames go to
+# the channel directly and are counted by neither.
+client_tx_stats() {
+	local stat
+
+	for stat in tx_packets tx_bytes; do
+		ip netns exec "$NS_CLIENT" \
+			cat "/sys/class/net/ppp0/statistics/$stat"
+	done
+	tc -n "$NS_CLIENT" -s -j filter show dev "$VETH_CLIENT" egress |
+		jq '[.[].options.actions[0].stats // empty] |
+		    (map(.packets) | add), (map(.bytes) | add)'
+}
+
+# A frame sent while the counters are read can be counted by only one of
+# them. Read them until two reads 100 ms apart agree.
+client_tx_stats_settled() {
+	local prev cur i
+
+	prev=$(client_tx_stats)
+	for ((i = 0; i < 50; i++)); do
+		sleep 0.1
+		cur=$(client_tx_stats)
+		[ "$cur" = "$prev" ] && break
+		prev=$cur
+	done
+	echo "$cur"
+}
+
+# Send TCP streams from every CPU at once, then check that each frame
+# counted by the PPP device left the Ethernet device exactly once.
+ppp_test_parallel() {
+	local ncpus cpu i pids=() before after d=() proto
+
+	# PPP protocol numbers of IPv4 and IPv6
+	tc -n "$NS_CLIENT" qdisc add dev "$VETH_CLIENT" clsact
+	for proto in 0x0021 0x0057; do
+		tc -n "$NS_CLIENT" filter add dev "$VETH_CLIENT" egress \
+			protocol ppp_ses flower ppp_proto "$proto" action pass
+	done
+
+	ncpus=$(nproc)
+	[ "$ncpus" -gt 8 ] && ncpus=8
+	for ((cpu = 0; cpu < ncpus; cpu++)); do
+		ip netns exec "$NS_SERVER" iperf3 -s -1 -D -p $((5301 + cpu))
+		wait_local_port_listen "$NS_SERVER" $((5301 + cpu)) tcp
+	done
+
+	mapfile -t before < <(client_tx_stats_settled)
+	for ((cpu = 0; cpu < ncpus; cpu++)); do
+		ip netns exec "$NS_CLIENT" taskset -c "$cpu" \
+			iperf3 -c "$IP_SERVER" -p $((5301 + cpu)) -Z -t 3 \
+			> /dev/null &
+		pids+=($!)
+	done
+	for i in "${pids[@]}"; do
+		wait "$i"
+		check_err $? "iperf3 client failed"
+	done
+	mapfile -t after < <(client_tx_stats_settled)
+
+	# 0-1: ppp0 packets and bytes; 2-3: the same on the veth
+	for i in 0 1 2 3; do
+		d[i]=$((after[i] - before[i]))
+	done
+	echo "ppp0: ${d[0]} packets, ${d[1]} bytes; veth: ${d[2]}, ${d[3]}"
+
+	[ "${d[0]}" -gt 0 ] && [ "${d[0]}" -eq "${d[2]}" ]
+	check_err $? "PPP and Ethernet packet counts differ"
+
+	# Ethernet (14), PPPoE (6) and PPP protocol (2) header per frame
+	[ "${d[3]}" -eq $((d[1] + 22 * d[0])) ]
+	check_err $? "PPP and Ethernet byte counts differ"
+}
+
 # Start socat as syslog listener
 socat -v -u UNIX-RECV:/dev/log OPEN:/dev/null > "$PPPOE_LOG" 2>&1 &
 SOCAT_PID=$!
@@ -53,6 +131,11 @@ ppp_test_connectivity
 
 log_test "PPPoE"
 
+RET=0
+ppp_test_parallel
+
+log_test "PPPoE parallel transmit"
+
 # Dump syslog messages if the test failed
 if [ "$RET" -ne 0 ]; then
 	while read -r _sign _date _time len _from _to
-- 
2.53.0


      parent reply	other threads:[~2026-11-29 14:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 14:43 [PATCH net-next 0/3] ppp: transmit data frames without the unit and channel locks Julius Bairaktaris
2026-11-29 14:43 ` [PATCH net-next 1/3] " Julius Bairaktaris
2026-11-29 14:43 ` [PATCH net-next 2/3] pppoe: transmit without the PPP channel lock Julius Bairaktaris
2026-11-29 14:43 ` Julius Bairaktaris [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261129144319.1489366-4-julius@bairaktaris.de \
    --to=julius@bairaktaris.de \
    --cc=26031212468@stu.xidian.edu.cn \
    --cc=andrew+netdev@lunn.ch \
    --cc=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=gnault@redhat.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-ppp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=qingfang.deng@linux.dev \
    --cc=shuah@kernel.org \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®