Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Hangbin Liu <hangbin.liu@linux.dev>
To: Murali Krishna <muralikrishna2444b@gmail.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>,
	Shuah Khan <shuah@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2] selftests: net: add tests for the QRTR socket family
Date: Wed, 2 Dec 2026 17:17:56 +0800	[thread overview]
Message-ID: <aw_iRO0E7odGeg2I@fedora> (raw)
In-Reply-To: <20261201104515.45339-1-muralikrishna2444b@gmail.com>

Hi Murali,
On Tue, Dec 01, 2026 at 04:14:15PM +0530, Murali Krishna wrote:
> net/qrtr has no test coverage in tools/testing/selftests, although the
> behaviour it exposes to userspace is well defined and testable without
> Qualcomm hardware: the local node always exists, and CONFIG_QRTR_TUN
> lets a test act as a QRTR endpoint.
> 
> Add tools/testing/selftests/net/qrtr with two programs.
> 
> qrtr_sock covers the AF_QIPCRTR socket contract: the ephemeral port
> range and the CAP_NET_ADMIN boundary documented above
> qrtr_port_assign(), the bind() rule that an address must name the
> socket's own node, rebinding (which moves the port and releases the old
> one), EADDRINUSE on a taken port, auto-bind on send, and local datagram
> delivery including the source address reported to the receiver.
> 
> qrtr_endpoint covers frame validation in qrtr_endpoint_post() by writing
> crafted frames to /dev/qrtr-tun: length alignment, unknown protocol
> versions, headers truncated below the v1 and v2 minimums, a zero or
> over-long declared payload size, a size that disagrees with the frame
> length, control types whose payload is too small to hold a struct
> qrtr_ctrl_pkt, control types addressed to an ordinary port, and the
> legacy 16-bit control port number. Each rejection test malforms the
> frame in exactly one way, so a failure names the check that regressed.
> 
> A rejection on its own is weak evidence, though, because
> qrtr_endpoint_post() reports every failed validation check as -EINVAL
> through a single error path: a frame can be refused for a reason the
> test did not intend. control_type_to_normal_port therefore binds a
> socket to the destination port, so that qrtr_port_lookup() cannot be
> what fails, and data_to_normal_port shows a DATA frame to that same
> port being accepted.
> 
> Header fields are written with htole32()/htole16().
> qrtr_endpoint_post() takes the protocol version from the first byte of
> the frame and decodes the remaining fields with le32_to_cpu() and
> le16_to_cpu(), so frames built in host byte order would be rejected at
> the version check on a big-endian host.
> 
> Both programs skip cleanly when CONFIG_QRTR is not available, and
> qrtr_endpoint also skips when /dev/qrtr-tun cannot be opened, so the
> suite is harmless on non-Qualcomm configurations.
> 
> The tests were written with the help of an LLM coding assistant, from a
> prompt asking for selftests covering the AF_QIPCRTR socket contract and
> qrtr_endpoint_post() frame validation. Both C files and this changelog
> were drafted that way, then reviewed, corrected and run by hand.
> Writing them corrected two assumptions about the interface: that bind()
> treats sq_node == 0 as "any node", and that rebinding an already bound
> socket fails.

The commit description is too long, maybe shorter it?

> 
> Signed-off-by: Murali Krishna <muralikrishna2444b@gmail.com>
> ---

...

> diff --git a/tools/testing/selftests/net/qrtr/config b/tools/testing/selftests/net/qrtr/config
> new file mode 100644
> index 000000000..0bdb8a4c5
> --- /dev/null
> +++ b/tools/testing/selftests/net/qrtr/config
> @@ -0,0 +1,2 @@
> +CONFIG_QRTR=m
> +CONFIG_QRTR_TUN=m

We build qrtr-tun as a module. If the user hasn't loaded it, the test skips with:

	no /dev/qrtr-tun: modprobe qrtr-tun, or CONFIG_QRTR_TUN=n

Should we try loading it inside the test script?

Thanks
Hangbin

      reply	other threads:[~2026-12-02  9:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 10:44 [PATCH net-next v2] selftests: net: add tests for the QRTR socket family Murali Krishna
2026-12-02  9:17 ` Hangbin Liu [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=aw_iRO0E7odGeg2I@fedora \
    --to=hangbin.liu@linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=muralikrishna2444b@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /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