BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bobby Eshleman" <bobbyeshleman@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v2 5/6] selftests: drv-net: add primary_rx_redirect support to NetDrvContEnv
Date: Wed, 06 May 2026 00:29:06 +0000	[thread overview]
Message-ID: <20260506002907.4BA08C2BCB4@smtp.kernel.org> (raw)
In-Reply-To: <20260504-tcp-dm-netkit-v2-5-56d52ac72fd4@meta.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Hardcoding `byteorder='little'` when packing BPF map values breaks the test on big-endian architectures.
--

commit 5fba7c06c7ed450ad321c1238af07a759467e25a
Author: Bobby Eshleman <bobbyeshleman@meta.com>

selftests: drv-net: add primary_rx_redirect support to NetDrvContEnv

When sending from a namespace that has access to a netkit device with a
leased queue, the nk primary in the host namespace needs to redirect its
RX to the physical device. This patch adds that redirection bpf program
and teaches the harness to install it.

> diff --git a/tools/testing/selftests/drivers/net/lib/py/env.py b/tools/testing/selftests/drivers/net/lib/py/env.py
> index 24ce122abd9c..d569d01ef791 100644
> --- a/tools/testing/selftests/drivers/net/lib/py/env.py
> +++ b/tools/testing/selftests/drivers/net/lib/py/env.py
[ ... ]
> @@ -505,3 +520,31 @@ class NetDrvContEnv(NetDrvEpEnv):
[ ... ]
> +    def _attach_primary_rx_redirect_bpf(self):
> +        """Attach BPF redirect program on the primary netkit ingress."""
[ ... ]
> +        bss_map_id = self._find_bss_map_id(redirect_prog_id)
> +        phys_ifindex_bytes = self.ifindex.to_bytes(4, byteorder='little')

Does hardcoding byteorder='little' here break the test on big-endian
architectures?

Since .bss maps store integers in native byte order, and BPF programs execute
using the host's native endianness, passing a 4-byte little-endian sequence
on a big-endian system (like s390x) will cause the kernel to interpret the
ifindex backwards.

For example, an ifindex of 1 (01 00 00 00) becomes 16777216 (0x01000000).
This would cause bpf_redirect_neigh() to fail because the byte-swapped ifindex
does not exist on the system, silently dropping all packets.

While a similar pre-existing pattern exists in _attach_bpf(), this duplicates
it into the newly added _attach_primary_rx_redirect_bpf() function.

Could this dynamically use byteorder=sys.byteorder instead so the serialization
matches the host architecture's endianness?

> +        value_hex = ' '.join(f'{b:02x}' for b in phys_ifindex_bytes)
> +        bpftool(f"map update id {bss_map_id} key hex 00 00 00 00 value hex {value_hex}")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260504-tcp-dm-netkit-v2-0-56d52ac72fd4@meta.com?part=5

  reply	other threads:[~2026-05-06  0:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-05  0:27 [PATCH net-next v2 0/6] net: devmem: support devmem with netkit devices Bobby Eshleman
2026-05-05  0:27 ` [PATCH net-next v2 1/6] net: add netmem_tx modes that indicate dma capability Bobby Eshleman
2026-05-05 17:41   ` Harshitha Ramamurthy
2026-05-07  2:30   ` Jakub Kicinski
2026-05-05  0:27 ` [PATCH net-next v2 2/6] net: devmem: support TX over NETMEM_TX_NO_DMA devices Bobby Eshleman
2026-05-06  0:29   ` sashiko-bot
2026-05-06  1:18     ` Bobby Eshleman
2026-05-06 15:00       ` Bobby Eshleman
2026-05-07  2:34   ` Jakub Kicinski
2026-05-07 15:38     ` Bobby Eshleman
2026-05-05  0:27 ` [PATCH net-next v2 3/6] selftests: drv-net: ncdevmem: add -n flag to skip NIC configuration Bobby Eshleman
2026-05-05  0:27 ` [PATCH net-next v2 4/6] selftests: drv-net: refactor devmem command builders into lib module Bobby Eshleman
2026-05-06  0:29   ` sashiko-bot
2026-05-05  0:27 ` [PATCH net-next v2 5/6] selftests: drv-net: add primary_rx_redirect support to NetDrvContEnv Bobby Eshleman
2026-05-06  0:29   ` sashiko-bot [this message]
2026-05-05  0:27 ` [PATCH net-next v2 6/6] selftests: drv-net: add netkit devmem tests Bobby Eshleman
2026-05-06  0:29   ` sashiko-bot

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=20260506002907.4BA08C2BCB4@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bobbyeshleman@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko@lists.linux.dev \
    /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