From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Eric Dumazet <edumazet@kernel.org>, bpf <bpf@vger.kernel.org>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, <netdev@vger.kernel.org>,
<edumazet@google.com>
Subject: Re: [PATCH net-next] net: inline eth_type_trans() fast path
Date: Fri, 2 Oct 2026 18:54:35 +0200 [thread overview]
Message-ID: <5639a56a-249f-4424-b883-140a865d327f@intel.com> (raw)
In-Reply-To: <CAL4Wiipep_WhfWBGov3vbOCLNKd0oQzFkX413AMU6V5DNN5Pmw@mail.gmail.com>
From: Edumazet@kernel.org <edumazet@kernel.org>
Date: Thu, 1 Oct 2026 19:10:46 +0200
> On Thu, Oct 1, 2026 at 5:58 PM Alexander Lobakin
> <aleksander.lobakin@intel.com> wrote:
>>
>> From: Edumazet@kernel.org <edumazet@kernel.org>
>> Date: Wed, 30 Sep 2026 19:29:57 +0200
>>
>>> eth_type_trans() is called once per received packet by most
>>> Ethernet drivers, and by core helpers (napi_gro_frags(),
>>> xdp_build_skb_from_*(), veth, tun, tunnels, loopback...).
>>>
>>> With CONFIG_MITIGATION_RETHUNK / SRSO, the call and return
>>> are not free anymore.
>>>
>>> Add eth_type_trans_inline(), handling the common case inline:
>>> unicast frame sent to dev->dev_addr, with a real ethertype,
>>> on a device which is not a DSA conduit. All other frames
>>> (multicast, broadcast, otherhost, 802.2, runts, DSA)
>>> are handled by the out-of-line eth_type_trans().
>>>
>>> eth_type_trans() is now a macro calling eth_type_trans_inline(),
>>> so that all existing callers get the fast path. The out-of-line
>>> version remains exported, and can be called with
>>> (eth_type_trans)(skb, dev). bpf_prog_test_run_skb() uses this
>>
>> Shouldn't it get renamed to e.g. eth_type_trans_slow() to avoid this
>> confusion?
>
> This was my initial idea, but this would make the patch a bit more
> invasive and touch bpf selftests, something like:
>
> Let me know if I should send a V2 and CC bpf maintainers, thanks!
>
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index 513354e928cb58f837fdc93a77f2e896de1ef916..8f4e9dd18001a4c32455fefd74fe38db270756d1
> 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -1165,7 +1165,8 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog,
> const union bpf_attr *kattr,
> goto out;
> }
> }
> - skb->protocol = eth_type_trans(skb, dev);
> + /* Always call the out-of-line version, for fentry/fexit selftests. */
> + skb->protocol = eth_type_trans_slow(skb, dev);
> skb_reset_network_header(skb);
>
> switch (skb->protocol) {
> diff --git a/tools/testing/selftests/bpf/progs/core_kern.c
> b/tools/testing/selftests/bpf/progs/core_kern.c
> index 004f2acef2eb0b0d80184423a3e8ba399feee1f3..fca26af98a7b92898a4adfde19f63b342f29db74
> 100644
> --- a/tools/testing/selftests/bpf/progs/core_kern.c
> +++ b/tools/testing/selftests/bpf/progs/core_kern.c
> @@ -47,14 +47,14 @@ int BPF_PROG(tp_xdp_devmap_xmit_multi, const
> struct net_device
> return randmap(from_dev->ifindex, from_dev);
> }
>
> -SEC("fentry/eth_type_trans")
> +SEC("fentry/eth_type_trans_slow")
> int BPF_PROG(fentry_eth_type_trans, struct sk_buff *skb,
> struct net_device *dev, unsigned short protocol)
> {
> return randmap(dev->ifindex + skb->len, dev);
> }
>
> -SEC("fexit/eth_type_trans")
> +SEC("fexit/eth_type_trans_slow")
> int BPF_PROG(fexit_eth_type_trans, struct sk_buff *skb,
> struct net_device *dev, unsigned short protocol)
> {
> diff --git a/tools/testing/selftests/bpf/progs/kfree_skb.c
> b/tools/testing/selftests/bpf/progs/kfree_skb.c
> index 7236da72ce8055f9a0165d3b4334a04d17d110b8..678c15c151944b44e276cf1280c77cb436ff7b10
> 100644
> --- a/tools/testing/selftests/bpf/progs/kfree_skb.c
> +++ b/tools/testing/selftests/bpf/progs/kfree_skb.c
> @@ -114,7 +114,7 @@ struct {
> bool fexit_test_ok;
> } result = {};
>
> -SEC("fentry/eth_type_trans")
> +SEC("fentry/eth_type_trans_slow")
> int BPF_PROG(fentry_eth_type_trans, struct sk_buff *skb, struct
> net_device *dev,
> unsigned short protocol)
> {
> @@ -132,7 +132,7 @@ int BPF_PROG(fentry_eth_type_trans, struct sk_buff
> *skb, struct net_device *dev,
> return 0;
> }
>
> -SEC("fexit/eth_type_trans")
> +SEC("fexit/eth_type_trans_slow")
> int BPF_PROG(fexit_eth_type_trans, struct sk_buff *skb, struct net_device *dev,
> unsigned short protocol)
> {
This shouldn't break anything, but CCing bpf just in case.
Thanks,
Olek
next prev parent reply other threads:[~2026-10-02 16:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 17:29 [PATCH net-next] net: inline eth_type_trans() fast path Eric Dumazet
2026-10-01 15:57 ` Alexander Lobakin
2026-10-01 17:10 ` Eric Dumazet
2026-10-02 15:26 ` Stanislav Fomichev
2026-10-02 16:54 ` Alexander Lobakin [this message]
2026-10-02 18:52 ` Eric Dumazet
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=5639a56a-249f-4424-b883-140a865d327f@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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