Article View: linux.kernel.netdev
Article #25689Re: [PATCH net-next v2] selftests: net: add tests for the QRTR socket family
From: Hangbin Liu
Date: Wed, 02 Dec 2026 09:17
Date: Wed, 02 Dec 2026 09:17
77 lines
11836 bytes
11836 bytes
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
Technical Details
Message-ID:
<aw_iRO0E7odGeg2I@fedora>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375668-linux-kernel-netdev=dewy.ruReferences:
<20261201104515.45339-1-muralikrishna2444b@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375668-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v2] selftests: net: add tests for the QRTR socket family Date: Wed, 2 Dec 2026 17:17:56 +0800 Organization: Usenet Network Message-ID: <aw_iRO0E7odGeg2I@fedora> References: <20261201104515.45339-1-muralikrishna2444b@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1933345"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:imjlrRdc5IZctTrIw5UK2nWxZbI= sha256:vcyLVj3YOujixP7MiDQnepQvJ1rRztUiFg4Mi1LHabs= sha1:C8c/QhfTYFSk7kQFumhH+oDSP/I= sha256:JK/9AIa1k3Dy6hch6prUg2bXWsNvdsAnawfykbxewbU= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 4FC7F1175CA; Wed, 2 Dec 2026 12:18:34 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CbEsySukEWBF; Wed, 2 Dec 2026 12:18:30 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375668-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 560C91175C8; Wed, 2 Dec 2026 12:18:21 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 0936224E17; Wed, 2 Dec 2026 09:18:19 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796203098; b=VkjMpNGVJQ1xTMwsAnoqew80cihITJ3RV9pR0nwS5duOyEqwq6fw72pHWa/1HPgqjZdn HQiuQgVLJSZyOsKM6UDJQAfq+fz6QtXN1KH+ttMVPpeKc4DtRlkM2Xq+1UfDCArjKFRs/ tn6bEpR64geiVp41tXu1U58sdT8WQP2Pz7c2bSA2IWIFQAWbngopre/MBJCSNcFcXWyan x13f7MvgpB7Vj95k3+TsrcbIBkAUUpV/Qg9XW2K09bC1sqLsacvGDEEf1ob9iJRIT8HV7 z41Ucb9Jda/FmNPGt1uh0T6Ezp3agUTyBb8guTiTqR7pulibUJ0a69CPO1pQ6q88Z4A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796203098; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=1dpd+h3v67MuI0pCP5rrVwr/tdG08KcecGCn0XaXchE=; b=w4pN7QNQmzdCZ/E08LrOIKxix3rxwdpPyavMwxnNZHmlZmkD7lbEZB6tpNMlE2c6shj7 fc9MOqNu9g13G4P8puu9l2c/kUptckXI3tPnlOgbaBkiUe6QvWCk08HgzfCNQbOUxO064 YuOnTx+0G3camt3lxO44ocmMwAY1jIG7Tq5FbD0oPDtu6ywRJyZ2wHfVgqRrpRpUBomTA NIRG4X0dC4iy0OsuMhT7AGCsQU5wnZyS0P3JiT0vGHeTliVp+D03yb2/G/h+vk9ftDbpc qusBIBupxelrameekUblYwm2T8fuE8+NVtAPNE4Snw+aBZ5AyDKvX8uw4aWpc09RF0A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=IjbAw3Q3; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC27F606A32F; Wed, 2 Dec 2026 09:18:18 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=IjbAw3Q3 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.88 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796203097; b=TUKYkNN/wHsV0sBdB8Qktm6EuNTkPDmQXRj63UuqFKN5gz/1QOVAe3Vz2XMOiRmnpIv3 77RHrdAV+D4s7dbq1ghy0pWL8F9JGennLCLso335rXlLdOerR0ooWB+Shk7Q2mfLCmp74 Al5Wwkl6+yuAGfz4WrjrznGLDdGFGgCVC1fJOnkeLK3KRZb28cXBd7iB6uzHPZdzHrCdM 1oVYrNme/Nkb1k8XGYh84UewXsgg4TVXbsUhdQB1t3eQM7oOCPCB00MLFmLzPL7sUSzEh ZlOn7S5N3KZx8wZq/6Nw4qnnQLDyijeoCy1/mZucvsuUuah9N+iRNDaPW6oIENPiODg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796203097; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=1dpd+h3v67MuI0pCP5rrVwr/tdG08KcecGCn0XaXchE=; b=gwLAe0vne1/R2IxdZduN0cMmnHJaYqgjPHeLI0mRIKrYNQC//PSYNs58PrRCbTzEjFTR a0umnvIwZRXIvYJxKCJGAgYQ9iz+EzRuGU7WTpxK2U1HUIKnbGD1cqd4smLk9US5M53Ro T7EUCs24EWhtQwcwNty7se7GGRSi9QHVUs8ETyHDMcu5tfPpvSmiLchh9vdM6DY4brUco g4OUUsU8JWjFJqxee9hjZJ0GOH1wCR6isiTpKqjwqx3HGgHv+tDDbLXPfL50EMPIewEt8 Zv2WHfoeO5l8MZskIe8uzUT8Xb4CeueZTuq5zU7SuoqcYO0U1h3/EXeGw04NaxqVKiA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=IjbAw3Q3; arc=none smtp.remote-ip=95.215.58.88 X-Received: from mta1.migadu.com (out-88.mta1.migadu.com [95.215.58.88]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 160B8606A322 for <netdev@vger.kernel.org>; Wed, 2 Dec 2026 09:18:16 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 160B8606A322 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=IzSZWm7Wsu8iTNABVGK8ZuhxwFuIAf44eIOdZsGemik=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796203094; v=1; x=1796807894; b=IjbAw3Q3EqW/8c3boLKUb37CIqoBpSlmfYKSvi38snO/g5+e5T5u6fXWZffWgdzidtosXbOD Mtb4Azg6EwDnvWf7aGNoat0GynOcmOuGKuYh3NUP5ARNcEGZ8wB5RTPYO/TBk3y4w2CFa7y2lTu 1ipgyBgZ8LgDtLnysIPN6aUI= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta10.migadu.com with ESMTPS id c4356e40bd8d6ec5; Wed, 02 Dec 2026 09:18:11 +0000 X-Mizu-Trace-ID: c4356e40bd8d6ec5 X-Migadu-Flow: FLOW_OUT X-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 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261201104515.45339-1-muralikrishna2444b@gmail.com>