From: Ido Schimmel <idosch@nvidia.com>
To: Jon Kohler <jon@nutanix.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Cong Wang <xiyou.wangcong@gmail.com>,
Nicolas Dichtel <nicolas.dichtel@6wind.com>,
Jason Wang <jasowang@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] flow_dissector: save computed hash in __skb_get_hash_symmetric_net()
Date: Wed, 26 Nov 2025 09:45:18 +0200 [thread overview]
Message-ID: <aSawDrVIMM4eHlAw@shredder> (raw)
In-Reply-To: <20251125181930.1192165-1-jon@nutanix.com>
On Tue, Nov 25, 2025 at 11:19:27AM -0700, Jon Kohler wrote:
> tun.c changed from skb_get_hash() to __skb_get_hash_symmetric() on
> commit feec084a7cf4 ("tun: use symmetric hash"), which exposes an
> overhead for OVS datapath, where ovs_dp_process_packet() has to
> calculate the hash again because __skb_get_hash_symmetric() does not
> retain the hash that it calculates.
This seems to be intentional according to commit eb70db875671 ("packet:
Use symmetric hash for PACKET_FANOUT_HASH."): "This hash does not get
installed into and override the normal skb hash, so this change has no
effect whatsoever on the rest of the stack."
>
> Save the computed hash in __skb_get_hash_symmetric_net() so that the
> calcuation work does not go to waste.
>
> Fixes: feec084a7cf4 ("tun: use symmetric hash")
> Signed-off-by: Jon Kohler <jon@nutanix.com>
> ---
> include/linux/skbuff.h | 4 ++--
> net/core/flow_dissector.c | 7 +++++--
> 2 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index ff90281ddf90..f58afa49a50e 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -1568,9 +1568,9 @@ __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4)
> __skb_set_hash(skb, hash, true, is_l4);
> }
>
> -u32 __skb_get_hash_symmetric_net(const struct net *net, const struct sk_buff *skb);
> +u32 __skb_get_hash_symmetric_net(const struct net *net, struct sk_buff *skb);
>
> -static inline u32 __skb_get_hash_symmetric(const struct sk_buff *skb)
> +static inline u32 __skb_get_hash_symmetric(struct sk_buff *skb)
> {
> return __skb_get_hash_symmetric_net(NULL, skb);
> }
> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
> index 1b61bb25ba0e..4a74dcc4799c 100644
> --- a/net/core/flow_dissector.c
> +++ b/net/core/flow_dissector.c
> @@ -1864,9 +1864,10 @@ EXPORT_SYMBOL(make_flow_keys_digest);
>
> static struct flow_dissector flow_keys_dissector_symmetric __read_mostly;
>
> -u32 __skb_get_hash_symmetric_net(const struct net *net, const struct sk_buff *skb)
> +u32 __skb_get_hash_symmetric_net(const struct net *net, struct sk_buff *skb)
> {
> struct flow_keys keys;
> + u32 flow_hash;
>
> __flow_hash_secret_init();
>
> @@ -1874,7 +1875,9 @@ u32 __skb_get_hash_symmetric_net(const struct net *net, const struct sk_buff *sk
> __skb_flow_dissect(net, skb, &flow_keys_dissector_symmetric,
> &keys, NULL, 0, 0, 0, 0);
>
> - return __flow_hash_from_keys(&keys, &hashrnd);
> + flow_hash = __flow_hash_from_keys(&keys, &hashrnd);
> + __skb_set_sw_hash(skb, flow_hash, flow_keys_have_l4(&keys));
> + return flow_hash;
> }
> EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric_net);
>
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-11-26 7:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-25 18:19 [PATCH net-next] flow_dissector: save computed hash in __skb_get_hash_symmetric_net() Jon Kohler
2025-11-26 7:45 ` Ido Schimmel [this message]
2025-11-26 16:21 ` Jon Kohler
2025-11-27 8:24 ` Ido Schimmel
2025-12-02 16:53 ` Jon Kohler
2025-12-03 8:35 ` Ido Schimmel
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=aSawDrVIMM4eHlAw@shredder \
--to=idosch@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jasowang@redhat.com \
--cc=jon@nutanix.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=pabeni@redhat.com \
--cc=xiyou.wangcong@gmail.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;
as well as URLs for NNTP newsgroup(s).