Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: maciej.fijalkowski@intel.com
Cc: netdev@vger.kernel.org, magnus.karlsson@intel.com,
	stfomichev@gmail.com, kuba@kernel.org, pabeni@redhat.com,
	tushar.vyavahare@intel.com, kerneljasonxing@gmail.com,
	bjorn@kernel.org
Subject: Re: [PATCH v5 net-next 08/13] selftests: xsk: send UDP over IPv4 or IPv6 between the interface MACs
Date: Mon, 23 Nov 2026 18:46:38 +0000	[thread overview]
Message-ID: <179545959852.3135.9080788623983347843@kernel.org> (raw)
In-Reply-To: <20261119164636.1071385-9-maciej.fijalkowski@intel.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

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] This commit turns the AF_XDP test frames into UDP over
  IPv4/IPv6.
- [Low] The feature patch also carries fixes for older selftest defects,
  with no Fixes: tag and no separate patch.
- [Low] parse_command_line() in xskxceiver.c reads --udp-port with
  `opt_udp_port = strtoul(optarg, NULL, 10);` into a u16 and checks no…

--

selftests: xsk: send UDP over IPv4 or IPv6 between the interface MACs

The xskxceiver test frames used to be ETH_P_LOOPBACK frames between
made-up MAC addresses. They are now UDP over IPv4 or IPv6 between the
real interface MACs, configured by new --src-ip, --dst-ip, --dst-mac and
--udp-port options. The XDP programs now redirect only UDP packets to the
test port and pass everything else to the stack. The patch also fixes the
.bss read in is_adjust_tail_supported() and adds length checks to
is_frag_valid() and pkt_dump().

> diff --git a/tools/testing/selftests/net/lib/xsk/test_xsk.c b/tools/testing/selftests/net/lib/xsk/test_xsk.c
> index fdf449822f026..d4485da0f9ac8 100644
> --- a/tools/testing/selftests/net/lib/xsk/test_xsk.c
> +++ b/tools/testing/selftests/net/lib/xsk/test_xsk.c

[ ... ]

> @@ -792,31 +933,12 @@ static bool is_metadata_correct(struct pkt *pkt, void *buffer, u64 addr)
>  	return true;
>  }
>  
> -static int is_adjust_tail_supported(struct xsk_xdp_progs *skel_rx, bool *supported)
> +static bool is_adjust_tail_supported(struct xsk_xdp_progs *skel_rx)
>  {
> -	struct bpf_map *data_map;
> -	int adjust_value = 0;
> -	int key = 0;
> -	int ret;
> -

[ ... ]

> -	ret = bpf_map_lookup_elem(bpf_map__fd(data_map), &key, &adjust_value);
> -	if (ret) {
> -		ksft_print_msg("Error: bpf_map_lookup_elem failed with error %d\n", ret);
> -		return ret;
> -	}
> -
>  	/* Set the 'adjust_value' variable to -EOPNOTSUPP in the XDP program if the adjust_tail
>  	 * helper is not supported. Skip the adjust_tail test case in this scenario.
>  	 */
> -	*supported = adjust_value != -EOPNOTSUPP;
> -
> -	return 0;
> +	return skel_rx->bss->adjust_value != -EOPNOTSUPP;
>  }

[Severity: Low]
This isn't a bug, but the old bpf_map_lookup_elem() call here was a real
stack overflow in the test process, and it has nothing to do with the
UDP conversion. The baseline .bss holds idx, drop_idx, adjust_value and
count. That is at least 16 bytes, all copied into the single int
adjust_value on the stack.

The same applies to the new short fragment check in is_frag_valid() and
the bounded word count in pkt_dump().

The commit message does describe each fix, and they are tied to this
patch. It removes idx and adds test_port to .bss. It also grows
PKT_HDR_SIZE to 44 or 64 bytes, which is why the short fragment check is
needed. The fixes themselves look complete.

Would it be worth moving these into a separate patch with a Fixes: tag,
so they can be picked up on their own?

[ ... ]

> diff --git a/tools/testing/selftests/net/lib/xsk/xsk_xdp_progs.bpf.c b/tools/testing/selftests/net/lib/xsk/xsk_xdp_progs.bpf.c
> index 84e5f47322895..2b55dbaf13b24 100644
> --- a/tools/testing/selftests/net/lib/xsk/xsk_xdp_progs.bpf.c
> +++ b/tools/testing/selftests/net/lib/xsk/xsk_xdp_progs.bpf.c

[ ... ]

> +static __always_inline bool is_test_packet(struct xdp_md *xdp)
> +{
> +	__u32 hdr_len;
> +
> +	return test_udp_hdr(xdp, &hdr_len);
> +}
>  
>  SEC("xdp.frags") int xsk_def_prog(struct xdp_md *xdp)
>  {
> +	if (!is_test_packet(xdp))
> +		return XDP_PASS;
>  	return bpf_redirect_map(&xsk, 0, XDP_DROP);
>  }

[Severity: Medium]
The test frames now carry real IPv4/IPv6 and UDP headers, so NIC RSS can
hash them. The old ETH_P_LOOPBACK frames gave it nothing to hash. Every
program here still redirects to a fixed xskmap index, whatever
xdp->rx_queue_index is:

    return bpf_redirect_map(&xsk, 0, XDP_DROP);

On a multi-queue physical NIC with no flow steering, what happens to a
test packet that RSS puts on a queue other than the bound one? It looks
like xsk_rcv_check() would drop it, and the case would then time out.

XDP_SHARED_UMEM makes this more likely. Each socket now sends from its
own source port, set in __test_spec_init():

    xsk->src_port = udp_port + j;

So an L4 hash could put the two flows on different queues.

Later in the series, "selftests: drv-net: run the AF_XDP tests over veth
or a NIC" handles this in drivers/net/xsk.py. _reserve_queue() takes the
bound queue out of RSS with ethtool -X equal. _steer_udp() then installs
an ethtool -N flow-type udp4/udp6 dst-port rule on both hosts. The rule
matches only the destination port, so it covers both shared UMEM source
ports. "selftests: xsk: drop the single-interface loopback mode" also
says the hardware test steers its traffic with ntuple and RSS
configuration. At this commit, no in-tree runner drives a physical NIC.

Could the usage text or the commit message say that the caller has to
steer the flow to the bound queue?

[ ... ]

> diff --git a/tools/testing/selftests/net/lib/xsk/xskxceiver.c b/tools/testing/selftests/net/lib/xsk/xskxceiver.c
> index ded94b84cd1da..ef03bf3bd37b1 100644
> --- a/tools/testing/selftests/net/lib/xsk/xskxceiver.c
> +++ b/tools/testing/selftests/net/lib/xsk/xskxceiver.c

[ ... ]

> @@ -294,6 +315,20 @@ static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj
>  		case OPT_LISTEN:
>  			opt_listen = true;
>  			break;

[ ... ]

> +		case OPT_UDP_PORT:
> +			opt_udp_port = strtoul(optarg, NULL, 10);
> +			break;

[Severity: Low]
Does --udp-port need a range check here? The strtoul() result goes
straight into the u16 opt_udp_port, so a value above 65535 is silently
truncated modulo 65536. Only a result of 0 is rejected, by the
!opt_udp_port check and by xsk_set_flow().

xsk_load_xdp_programs() then makes the truncated value the port that the
XDP programs match on:

    ifobj->xdp_progs->bss->test_port = udp_port;

UDP traffic to an unintended port could then be redirected to the XSK
instead of reaching the stack.

There is also a separate wrap: with --udp-port 65535, the source port of
socket 1 in __test_spec_init() becomes 0:

    xsk->src_port = udp_port + j;

That wrap looks harmless. xsk_xdp_shared_umem() computes
(__u16)(0 - 65535) == 1 and still picks socket 1, and UDP source port 0
is legal.

Later in the series, the in-tree launcher drivers/net/xsk.py checks the
value with _check_opt("--udp-port", cfg.udp_port, 1, 0xffff) before
passing it on. The series leaves option range checks to the launcher, so
this only affects running xskxceiver by hand.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119164636.1071385-1-maciej.fijalkowski%40intel.com

  reply	other threads:[~2026-11-23 18:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 16:46 [PATCH v5 net-next 00/13] selftests: net: adjust xskxceiver to drv-net Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 01/13] selftests: xsk: factor endpoint work out of pthread wrappers Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 02/13] selftests: xsk: size the TX UMEM in HW_SW_MAX_RING_SIZE Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 03/13] selftests: xsk: drop the single-interface loopback mode Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 04/13] selftests: xsk: collect interface capabilities in struct xsk_caps Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 05/13] selftests: xsk: split xskxceiver main() into setup, run and cleanup Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 06/13] selftests: xsk: run one test case per xskxceiver invocation Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 07/13] selftests: xsk: run the RX and TX endpoints in separate processes Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 08/13] selftests: xsk: send UDP over IPv4 or IPv6 between the interface MACs Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko [this message]
2026-11-23 19:08   ` Björn Töpel
2026-11-19 16:46 ` [PATCH v5 net-next 09/13] selftests: xsk: prepare xskxceiver for endpoints on two hosts Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 10/13] selftests: xsk: list the endpoint roles of the test cases Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 11/13] selftests: drv-net: decouple local link setup from netdevsim Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 12/13] selftests: drv-net: run the AF_XDP tests over veth or a NIC Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 13/13] selftests: xsk: document generic and hardware endpoint runs Maciej Fijalkowski

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=179545959852.3135.9080788623983347843@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=kerneljasonxing@gmail.com \
    --cc=kuba@kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stfomichev@gmail.com \
    --cc=tushar.vyavahare@intel.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