From: netdev-bot+sashiko@kernel.org
To: o.rempel@pengutronix.de
Cc: robin@protonic.nl, socketcan@hartkopp.net, mkl@pengutronix.de,
shuah@kernel.org, kernel@pengutronix.de,
linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, fmaurer@redhat.com,
mailhol@kernel.org, alexander.hoelzl@gmx.net,
quchaosheng000406@163.com, penguin-kernel@I-love.SAKURA.ne.jp,
kuba@kernel.org
Subject: Re: [PATCH can-next v5 7/9] selftests: can: add J1939 TP/ETP multi-frame tests against CAN_RAW
Date: Sun, 22 Nov 2026 01:03:57 +0000 [thread overview]
Message-ID: <179530943723.3131.3874073778043295050@kernel.org> (raw)
In-Reply-To: <20261120-j1939-selftests-v5-7-fdf4c242a37e@pengutronix.de>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The new RX tests in
tools/testing/selftests/net/can/test_j1939_multi.c assume that…
--
selftests: can: add J1939 TP/ETP multi-frame tests against CAN_RAW
This adds TP and ETP round-trip selftests in both directions. A CAN_RAW
socket acts as the transport peer and by default sits on its own vcan
behind the CAN gateway that j1939_lib.sh sets up. The tests check the
control and DT frames the kernel sends and the order of the TX-completion
ACK, and test_j1939_multi.sh is added to TEST_PROGS.
> diff --git a/tools/testing/selftests/net/can/test_j1939_multi.c b/tools/testing/selftests/net/can/test_j1939_multi.c
> new file mode 100644
> index 0000000000000..6edce7493892b
> --- /dev/null
> +++ b/tools/testing/selftests/net/can/test_j1939_multi.c
> @@ -0,0 +1,682 @@
[ ... ]
> +static bool send_dt_burst_ok(int raw, uint8_t prio, pgn_t dt_pgn, uint8_t da,
> + uint8_t sa, unsigned int next, unsigned int count,
> + const uint8_t *payload, size_t size,
> + unsigned int first_seq)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < count; i++) {
> + size_t abs_pkt = (next - 1) + i;
> + uint8_t seq = first_seq + i;
> +
> + if (!send_dt_ok(raw, prio, dt_pgn, da, sa, seq, payload,
> + abs_pkt * J1939_DT_DATA_LEN, size))
> + return false;
> + }
> + return true;
> +}
[ ... ]
> +static bool etp_rx_serve_cts_ok(int raw, const uint8_t *payload, size_t size)
> +{
[ ... ]
> + cm_dat_init(dat, ETP_CMD_DPO);
> + dat[ETP_DPO_PKTS_OFF] = cts_pkts;
> + put_le24(&dat[ETP_DPO_BASE_OFF], next - 1);
> + if (!peer_send_cm_ok(raw, ETP_CM, dat))
> + return false;
> +
> + if (!send_dt_burst_ok(raw, PRIO, ETP_DT, SA_LOCAL, SA_PEER,
> + next, cts_pkts, payload, size,
> + TP_FIRST_PKT))
> + return false;
[Severity: Medium]
Can the DPO and the up to 255 DT frames after it reach the J1939 stack
in a different order than they were sent?
Each raw send() goes through can_send()->netif_rx()->netif_rx_internal().
With RPS off, that queues the frame on the current CPU's backlog:
net/core/dev.c:netif_rx_internal() {
...
ret = enqueue_to_backlog(skb, smp_processor_id(), &qtail);
...
}
The gateway then queues its copy for CANIF while that CPU processes its
backlog. Frames stay in order only inside a single CPU's backlog.
On PREEMPT_RT, use_backlog_threads() always returns true. So netif_rx()
only wakes the per-CPU backlog_napi thread, and send() returns before
the frame has been handled. On non-RT kernels the same thing happens
with thread_backlog_napi, or when softirq work goes to ksoftirqd.
The test thread has no CPU affinity. Suppose it moves to another CPU
between two send() calls, for example after the backlog thread it just
woke preempts it. Then the new CPU can process a later frame before the
earlier frames still queued on the old CPU.
An ETP DT that arrives before the DPO has been handled hits the default
case in j1939_xtp_rx_dat_one() and cancels the session:
net/can/j1939/transport.c:j1939_xtp_rx_dat_one() {
...
case J1939_TP_CMD_CTS:
if (skcb->addr.type != J1939_ETP)
break;
fallthrough;
default:
...
goto out_session_cancel;
...
}
The send_tp_dt_burst_ok() call in tp_serve_cts_ok() has the same
pattern. A TP DT that arrives early fails this check:
if (packet == session->pkt.rx)
session->pkt.rx++;
Then pkt.rx never reaches pkt.last, no EOMA is sent, and the session
times out.
The commit message says:
j1939_lib.sh also turns RPS off on that vcan, so
the peer gets each frame only after the stack has handled its echo
That covers the order between the stack's echo and the peer. It doesn't
cover the order of the peer's own consecutive frames. Nothing in
j1939_lib.sh or in this directory uses taskset or sched_setaffinity, and
that is still true at the end of the series.
Could tp_rx_from_raw and etp_rx_from_raw then fail at random in the
default kselftest run, especially on RT kernels or loaded VMs?
Would pinning the test process to one CPU fix this? That could be
sched_setaffinity() in j1939_test_main() or taskset in j1939_lib.sh.
The per-CPU backlog FIFO would then keep the order.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-j1939-selftests-v5-0-fdf4c242a37e%40pengutronix.de
next prev parent reply other threads:[~2026-11-22 1:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 9:45 [PATCH can-next v5 0/9] selftests: can: add J1939 socket and transport tests Oleksij Rempel
2026-11-20 9:45 ` [PATCH can-next v5 1/9] selftests: can: install net/lib.sh with the CAN tests Oleksij Rempel
2026-11-20 9:45 ` [PATCH can-next v5 2/9] selftests: can: add J1939 test helper header and library Oleksij Rempel
2026-11-20 9:45 ` [PATCH can-next v5 3/9] selftests: can: add J1939 base functional tests Oleksij Rempel
2026-11-20 9:45 ` [PATCH can-next v5 4/9] selftests: can: add J1939 socket option and metadata tests Oleksij Rempel
2026-11-20 9:46 ` [PATCH can-next v5 5/9] selftests: can: add J1939 addressing and concurrency tests Oleksij Rempel
2026-11-20 9:46 ` [PATCH can-next v5 6/9] selftests: can: add J1939 wire-format tests against CAN_RAW Oleksij Rempel
2026-11-20 9:46 ` [PATCH can-next v5 7/9] selftests: can: add J1939 TP/ETP multi-frame " Oleksij Rempel
2026-11-22 1:03 ` netdev-bot+sashiko [this message]
2026-11-20 9:46 ` [PATCH can-next v5 8/9] selftests: can: cover J1939 transport abort and timeout paths Oleksij Rempel
2026-11-20 9:46 ` [PATCH can-next v5 9/9] selftests: can: check SO_J1939_PROMISC receive effect Oleksij Rempel
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=179530943723.3131.3874073778043295050@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alexander.hoelzl@gmx.net \
--cc=fmaurer@redhat.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=quchaosheng000406@163.com \
--cc=robin@protonic.nl \
--cc=shuah@kernel.org \
--cc=socketcan@hartkopp.net \
/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®