Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: tianyi@cloudflare.com
Cc: netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,
	edumazet@kernel.org, davem@davemloft.net, horms@kernel.org,
	dkeogh@amazon.com, hawk@kernel.org, daniel@iogearbox.net,
	dwmw2@infradead.org, dtatulea@nvidia.com, noren@nvidia.com,
	alasdair@mcwilliam.dev, willemdebruijn.kernel@gmail.com,
	maciej.fijalkowski@intel.com, sdf@fomichev.me,
	magnus.karlsson@intel.com, dsahern@kernel.org, idosch@nvidia.com,
	ast@kernel.org, john.fastabend@gmail.com,
	donald.hunter@gmail.com, andrew+netdev@lunn.ch, corbet@lwn.net,
	skhan@linuxfoundation.org, shuah@kernel.org,
	rdunlap@infradead.org, leitao@debian.org, ast@fiberby.net,
	danieller@nvidia.com, kuniyu@google.com, bpf@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kernel-team@cloudflare.com, nh-open-source@amazon.com,
	stephen@networkplumber.org, gustavoars@kernel.org,
	one-d-wide@protonmail.com, ameryhung@gmail.com,
	andrii@kernel.org, aroulin@nvidia.com,
	anilkaushikwireless@gmail.com, demosthenes.ra@gmail.com,
	eddyz87@gmail.com, emil@etsalapatis.com, hangbin.liu@linux.dev,
	ihor.solodrai@linux.dev, jiayuan.chen@linux.dev,
	jolsa@kernel.org, joe@dama.to, memxor@gmail.com,
	lirongqing@baidu.com, louis.scalbert@6wind.com,
	mkl@pengutronix.de, martin.lau@linux.dev, mkarsten@uwaterloo.ca,
	mattbobrowski@google.com, michael.bommarito@gmail.com,
	razor@blackwall.org, runyu.xiao@seu.edu.cn, song@kernel.org,
	linux@leemhuis.info, wang.zhan@smartx.com,
	yonghong.song@linux.dev, n0ps1edzz@gmail.com,
	tianyi.gao@linux.dev
Subject: Re: [PATCH net-next v2 06/11] bpf, tcx: Set tx_extra_headroom from a decl tag on egress programs
Date: Mon, 23 Nov 2026 03:59:21 +0000	[thread overview]
Message-ID: <179540636180.3135.12677199986882977729@kernel.org> (raw)
In-Reply-To: <20261119013830.36935-7-tianyi@cloudflare.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The new documentation in Documentation/networking/netdevices.rst
  names only one load failure for the "tx_extra_headroom:" decl tag:…
- [Low] This patch adds tcx egress decl tags as a source of
  tx_extra_headroom.

--

bpf, tcx: Set tx_extra_headroom from a decl tag on egress programs

This patch lets a tcx egress program declare how many bytes of headers
it pushes, using a "tx_extra_headroom:" BTF decl tag on its main
function. The verifier parses the tag at load time into struct
bpf_prog_aux. The tags of all programs at tcx egress are summed into
dev->tx_extra_headroom whenever an egress program is attached, detached
or replaced.

> diff --git a/Documentation/networking/netdevices.rst b/Documentation/networking/netdevices.rst
> index 53ca8439f73bd..128a93303a6d3 100644
> --- a/Documentation/networking/netdevices.rst
> +++ b/Documentation/networking/netdevices.rst
> @@ -459,12 +459,27 @@ values:
>  
>  * ``XDP_PACKET_HEADROOM`` (256 bytes) minus ``needed_headroom``, when the
>    peer of a veth or netkit device has an XDP program
> +* the headroom that the programs at tcx egress of the device declare
>  
>  When the peer has an XDP program, locally generated UDP, raw and
>  AF_PACKET packets and AF_XDP packets in copy mode have enough headroom
>  for it. ``tx_extra_headroom`` is not recalculated when a bridge or
>  openvswitch changes ``needed_headroom`` later.
>  
> +A program at tcx egress declares its headroom with a BTF decl tag on its
> +main function. The value is a decimal number of bytes:
> +
> +.. code-block:: c
> +
> +  SEC("tcx/egress")
> +  __attribute__((btf_decl_tag("tx_extra_headroom:64")))
> +  int prog(struct __sk_buff *skb)
> +

[Severity: Low]
Should this paragraph say which packets actually get the declared
headroom?

The XDP paragraph above lists UDP, raw, AF_PACKET and AF_XDP copy mode.
The tcx paragraph does not limit the earlier statement at the top of the
section, which says tx_extra_headroom is extra headroom for locally
generated packets and that the stack adds it when it allocates such a
packet for the device.

The commit message makes a similar claim:

  A locally generated packet gets only LL_RESERVED_SPACE() of
  headroom, so bpf_skb_adjust_room() reallocates every such packet.

The only readers of dev->tx_extra_headroom are
netdev_get_alloc_headroom(), netdev_get_alloc_headroom_hlen() and
netdev_get_alloc_needed_headroom(). These are called from:

  __ip_append_data()
  raw_send_hdrinc()
  __ip6_append_data()
  rawv6_send_hdrinc()
  the AF_PACKET TX paths
  AF_XDP copy mode

TCP sizes its headroom with MAX_TCP_HEADER and never reads the value.

Say an encapsulating egress program carries "tx_extra_headroom:400".
TCP packets still get no extra reservation. bpf_skb_adjust_room() will
still reallocate them whenever MAX_TCP_HEADER leaves too little room.

TCP was left out on purpose in "net: add tx_extra_headroom and
netdev_get_alloc_headroom()". Could the tcx documentation, and the
commit message, state that scope?

> +The tag of the attached program covers the whole tail call chain. Tags on
> +tail call targets, freplace programs and programs at tcx ingress are
> +ignored. Loading a program whose tag is above 512 or does not parse fails
> +with ``-EINVAL``.

[Severity: Low]
Is this list of load failures complete? The loader also rejects a main
function with two "tx_extra_headroom:" decl tags, but the error is
-EEXIST, not -EINVAL.

btf_find_decl_tag_value() returns ERR_PTR(-EEXIST) for a duplicate:

kernel/bpf/btf.c:btf_find_decl_tag_value() {
    ...
	/* Prevent duplicate entries for same type */
	id = btf_find_next_decl_tag(btf, pt, comp_idx, tag_key, id);
	if (id >= 0)
		return ERR_PTR(-EEXIST);
    ...
}

bpf_find_tx_extra_headroom() returns that error unchanged:

	if (IS_ERR(value)) {
		if (PTR_ERR(value) == -ENOENT)
			return 0;
		verbose(env,
			"multiple tx_extra_headroom tags for main subprog\n");
		return PTR_ERR(value);
	}

The error goes back through add_subprogs(), so BPF_PROG_LOAD fails with
-EEXIST. The tag_twice selftest in verifier_tx_extra_headroom.c, later in
the series, expects this rejection. The documentation is still unchanged
at the end of the series.

Could the documentation also list the duplicate tag case and its error
code?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119013830.36935-1-tianyi%40cloudflare.com

  reply	other threads:[~2026-11-23  3:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  1:38 [PATCH net-next v2 00/11] net: extra TX headroom for local egress Tianyi Gao
2026-11-19  1:38 ` [PATCH net-next v2 01/11] net: add tx_extra_headroom and netdev_get_alloc_headroom() Tianyi Gao
2026-11-23  3:59   ` netdev-bot+sashiko
2026-11-19  1:38 ` [PATCH net-next v2 02/11] net: reserve extra TX headroom for local egress Tianyi Gao
2026-11-23  3:59   ` netdev-bot+sashiko
2026-11-19  1:38 ` [PATCH net-next v2 03/11] net: set tx_extra_headroom of the peer on XDP attach Tianyi Gao
2026-11-23  3:59   ` netdev-bot+sashiko
2026-11-19  1:38 ` [PATCH net-next v2 04/11] selftests: net: add flag to send a frame in xdp_helper Tianyi Gao
2026-11-23  3:59   ` netdev-bot+sashiko
2026-11-19  1:38 ` [PATCH net-next v2 05/11] selftests: net: add tx_extra_headroom test Tianyi Gao
2026-11-23  3:59   ` netdev-bot+sashiko
2026-11-19  1:38 ` [PATCH net-next v2 06/11] bpf, tcx: Set tx_extra_headroom from a decl tag on egress programs Tianyi Gao
2026-11-23  3:59   ` netdev-bot+sashiko [this message]
2026-11-19  1:38 ` [PATCH net-next v2 07/11] selftests: net: tx_extra_headroom: test a push at TC egress Tianyi Gao
2026-11-19  1:38 ` [PATCH net-next v2 08/11] selftests/bpf: Test the tx_extra_headroom decl tag Tianyi Gao
2026-11-19  1:38 ` [PATCH net-next v2 09/11] veth: add VETH_INFO_TX_EXTRA_HEADROOM Tianyi Gao
2026-11-19  1:38 ` [PATCH net-next v2 10/11] netlink: specs: rt-link: add veth attributes Tianyi Gao
2026-11-23  3:59   ` netdev-bot+sashiko
2026-11-19  1:38 ` [PATCH net-next v2 11/11] selftests: net: tx_extra_headroom: test the veth attribute Tianyi Gao
2026-11-19  8:31   ` Paolo Abeni
2026-11-23  3:59   ` netdev-bot+sashiko

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=179540636180.3135.12677199986882977729@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alasdair@mcwilliam.dev \
    --cc=ameryhung@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrii@kernel.org \
    --cc=anilkaushikwireless@gmail.com \
    --cc=aroulin@nvidia.com \
    --cc=ast@fiberby.net \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=daniel@iogearbox.net \
    --cc=danieller@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=demosthenes.ra@gmail.com \
    --cc=dkeogh@amazon.com \
    --cc=donald.hunter@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=dtatulea@nvidia.com \
    --cc=dwmw2@infradead.org \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=emil@etsalapatis.com \
    --cc=gustavoars@kernel.org \
    --cc=hangbin.liu@linux.dev \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jiayuan.chen@linux.dev \
    --cc=joe@dama.to \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=leitao@debian.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@leemhuis.info \
    --cc=lirongqing@baidu.com \
    --cc=louis.scalbert@6wind.com \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=martin.lau@linux.dev \
    --cc=mattbobrowski@google.com \
    --cc=memxor@gmail.com \
    --cc=michael.bommarito@gmail.com \
    --cc=mkarsten@uwaterloo.ca \
    --cc=mkl@pengutronix.de \
    --cc=n0ps1edzz@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nh-open-source@amazon.com \
    --cc=noren@nvidia.com \
    --cc=one-d-wide@protonmail.com \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=rdunlap@infradead.org \
    --cc=runyu.xiao@seu.edu.cn \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=song@kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=tianyi.gao@linux.dev \
    --cc=tianyi@cloudflare.com \
    --cc=wang.zhan@smartx.com \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=yonghong.song@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