From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796297017; b=h1Ry20F1iihA+QoxQsGDAOJVBvn/vOBDHsfex6DilhLOfsQQq/UnCgsZJEY8P5wIbooh 87nywr7UkvELJ9mTjA0xGPbJZ5lWOaafeIwiSExi37g8SFu5dlWg58oVqLvH+btSCAJ8t DAoICGvJp6QhIOuKku0NSThiiCsEHMjojqXeWEMBkLNJ3ZfAND6eom9D13+FYpzfAgvYI rBuPgcISH7YjmaLbPa250eDVGid1irUW5Nxax9IdyE0pIIAQ1uooaRKecrT7DkGGE0p/Q ui4HtFY+xQPOTmT6p+vB3SYo1A/t/7uqzGhsFuGf0SETlrhvqHc1qhyC48RdC1NcJDQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796297017; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=YNPeD7B4MCw2NKPmEP4SnNzQ4W7P6rOMRfQYMU0YyIk=; b=TIxUXUtyYOEKNp4xLgC8NcL+J5C3I3B24OGyFq4QdoTZ17KxNeyW3clz3w1V5Q2zageK MZnF2cn0axT9INmoAC12DZKcNuMr2Sdol0UV3gAfDhETSOXzifOuHD6Y51Q9VSyrty4JS ZFrXmHma57X0BpKVvgyxS1UvLYxa8+G0WfiQvHfLDcmZ2S72ZYn/cD1RnWKpU7h4COa0Y RLO0xx0XalFxh5tavfgfq6v1KSq1pPsTIA22qPpUMpKXR+NvQK7djpKgfWwxg573kTYgt iBM3M6YvXVy3oRDzpmurCeTK0QyEJGIQ7bizpfdD4tHSl8NVuRHAhGw28ZTqCDFyJug== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=L6bFmCkm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14123606A322 for ; Thu, 3 Dec 2026 11:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=L6bFmCkm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 712501F000C1; Thu, 3 Dec 2026 11:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796297016; bh=YNPeD7B4MCw2NKPmEP4SnNzQ4W7P6rOMRfQYMU0YyIk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=L6bFmCkmZzwGkI51fo10ALOJMiFFXmYScdLrtnql6TRZcVSyhaZQGPzEFmU/VRrYh OHqWSHbhyEl/u+sOpK9N/WxgXc8mPiP/BEWkjIOJmK1GFUYm/T6bbqqvIjeECVOlXX Oz/JZlDfn3hX5hQlv3aBnvNlUR1USqh/foKsTa1+wynZFHl9/GQABSNNVe5pnFP8tj kI1xGUkLDzbWjkHUvIVuZaJ+79MXEFCSQzxoJfPSCGS9rURZVIdGfygjg2WJDpUQ4M x865MLK7tzvGVh6XFOSh/ReH0/cF6EQnxKyJfa+6glwAIc/yomOhoTriyQLqsdfDYM v7OMJzsV7Hs2Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] selftests: net: can: add vcan concurrent tx/stats test Reply-To: sashiko-reviews@lists.linux.dev To: "T S Rameshkumar" Cc: linux-can@vger.kernel.org, "Marc Kleine-Budde" , "Oliver Hartkopp" , "Vincent Mailhol" , "Oleksij Rempel" In-Reply-To: <20261203111103.379929-2-rameshsv06@gmail.com> References: <20261203111103.379929-1-rameshsv06@gmail.com> <20261203111103.379929-2-rameshsv06@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 11:23:36 +0000 X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] selftests: net: can: premature EXIT trap and missing netns isolation - [Medium] selftests: net: can: missing barrier and unchecked reads in stats_reader() - [Low] selftests: net: can: missing CAN_RAW skip handling in test and wrapper -- commit b3f673b3db7d63b8eb092b5a5498ad7f078fc788 Author: T S Rameshkumar selftests: net: can: add vcan concurrent tx/stats test This commit adds a kselftest that spawns concurrent PF_CAN transmitters on a vcan interface while reading /proc/net/dev in parallel and checks the resulting rx/tx packet and byte counter deltas. > diff --git a/tools/testing/selftests/net/can/test_vcan_stats.c b/tools/te= sting/selftests/net/can/test_vcan_stats.c > new file mode 100644 > index 0000000000000..1a4f715adead8 > --- /dev/null > +++ b/tools/testing/selftests/net/can/test_vcan_stats.c [ ... ] > +static void *tx_worker(void *arg) > +{ > + int id =3D (int)(long)arg; > + struct sockaddr_can addr =3D {}; > + struct can_frame frame =3D {}; > + struct ifreq ifr =3D {}; > + int s; > + > + s =3D socket(PF_CAN, SOCK_RAW, CAN_RAW); > + if (s < 0) > + return (void *)(long)-errno; [Severity: Low] Should this test skip rather than fail when CONFIG_CAN_RAW is disabled? CONFIG_CAN_VCAN does not depend on or select CONFIG_CAN_RAW, so creating the vcan interface does not guarantee CAN_RAW socket support. When socket() fails with EPROTONOSUPPORT or EAFNOSUPPORT, tx_worker() returns a negative errno and ASSERT_EQ((long)res, 0) fails the test instead of probing CAN_RAW upfront and calling SKIP() with a reason string. In test_vcan_stats.sh, check_err() also treats any non-zero exit status (including ksft_skip) as a failure, so the wrapper would need to propagate a skip exit status from test_vcan_stats. [ ... ] > +static void *stats_reader(void *arg) > +{ > + struct net_dev_stats st; > + > + while (!atomic_load(&stop_reader)) > + read_if_stats(canif, &st); > + > + return NULL; > +} > + > +TEST(vcan_concurrent_tx_stats) > +{ > + struct net_dev_stats before, after; > + pthread_t tx[NUM_THREADS], reader; > + unsigned long long exp_pkts, exp_bytes; > + int ret; > + > + ret =3D read_if_stats(canif, &before); > + ASSERT_EQ(ret, 0) > + TH_LOG("failed to read initial stats for %s", canif); > + > + atomic_store(&stop_reader, 0); > + ret =3D pthread_create(&reader, NULL, stats_reader, NULL); > + ASSERT_EQ(ret, 0); > + > + for (long i =3D 0; i < NUM_THREADS; i++) { > + ret =3D pthread_create(&tx[i], NULL, tx_worker, (void *)i); > + ASSERT_EQ(ret, 0); > + } [Severity: Medium] Can all tx_worker() threads finish before stats_reader() ever runs? Sending 1000 in-memory frames on vcan takes only a few milliseconds, and no startup barrier (such as pthread_barrier_t) aligns the threads. All transmitters can finish and set stop_reader before stats_reader() runs once, giving a silent false pass. stats_reader() also ignores the return value of read_if_stats() and never inspects or counts the snapshots it reads, so /proc/net/dev read errors, zero concurrent reads, or non-monotonic counter values go undetected. > diff --git a/tools/testing/selftests/net/can/test_vcan_stats.sh b/tools/t= esting/selftests/net/can/test_vcan_stats.sh > new file mode 100755 > index 0000000000000..1153699cb176b > --- /dev/null > +++ b/tools/testing/selftests/net/can/test_vcan_stats.sh [ ... ] > +setup() > +{ > + ip link add name $CANIF type vcan || exit $ksft_skip > + ip link set dev $CANIF up > +} > + > +cleanup() > +{ > + ip link set dev $CANIF down > + ip link delete $CANIF > +} [ ... ] > +trap cleanup EXIT > +setup [Severity: Medium] Can cleanup() delete a pre-existing host vcan0 interface if setup() fails? trap cleanup EXIT is armed before setup() runs in the root network namespace. If $CANIF already exists on the host, ip link add fails with EEXIST and exits with $ksft_skip, triggering cleanup() to bring down and delete an interface this test did not create. Running in the root namespace also lets concurrent host traffic skew the exact /proc/net/dev deltas checked by test_vcan_stats. Isolating the device with setup_ns and cleanup_all_ns from the already-sourced net/lib.sh avoids both issues. In setup(), exiting on ip link add failure also omits a skip reason message (while still firing cleanup() errors when vcan is unavailable), and ip link set dev $CANIF up does not check its return status. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203111103.3799= 29-1-rameshsv06@gmail.com?part=3D2