From: Antoine Tenart <atenart@kernel.org>
To: Dumitru Ceara <dceara@redhat.com>,
Eric Dumazet <edumazet@google.com>,
Ilya Maximets <i.maximets@ovn.org>
Cc: i.maximets@ovn.org, davem@davemloft.net, kuba@kernel.org,
pabeni@redhat.com, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 4/4] net: skbuff: fix l4_hash comment
Date: Wed, 17 May 2023 14:05:19 +0200 [thread overview]
Message-ID: <168432511934.5394.6542526478980736820@kwain> (raw)
In-Reply-To: <485035ec-90f2-77fe-a3c5-21a0a40b111e@ovn.org>
Quoting Ilya Maximets (2023-05-16 23:25:19)
> On 5/16/23 09:36, Antoine Tenart wrote:
> >
> > What about "indicates hash was set by layer 4 stack and provides a
> > uniform distribution over flows"? Or/and we should we also add a
> > disclaimer like "no guarantee on how the hash was computed"?
>
> I'm still not sure this is correct. Is a NIC driver part of layer 4
> stack?
Offloading logic with L4 fields for csum, RSS, etc; we can argue it does
something at L4. What about this: "Provides a uniform distribution over
L4 flows"? I does look better than the previous proposal IMHO.
> And there are lots of other inconsistencies around skb hash. The following
> is probably the most colorful that I found:
>
> skb_set_hash(skb, tcp_rsk(req)->txhash, PKT_HASH_TYPE_L4);
> * Hash types refer to the protocol layer addresses which are used to
> * construct a packet's hash. The hashes are used to differentiate or identify
> * flows of the protocol layer for the hash type. Hash types are either
> * layer-2 (L2), layer-3 (L3), or layer-4 (L4).
> *
> * Properties of hashes:
> *
> * 1) Two packets in different flows have different hash values
> * 2) Two packets in the same flow should have the same hash value
> enum pkt_hash_types {
> PKT_HASH_TYPE_L4, /* Input: src_IP, dst_IP, src_port, dst_port */
> };
>
> Here we see that PKT_HASH_TYPE_L4 supposed to use particular fields
> as an input.
If we strictly follow the above, do all NIC provide a L4 hash using only
the above fields (src_IP, dst_IP, src_port, dst_port)? Having a quick
look I'm pretty sure no, both 4 and 5-tuple can be used. What is
important is at what level the distribution is.
So yes strictly speaking the above PKT_HASH_TYPE_L4 use can be a little
surprising, but to me it's a shortcut or a missing update. For perfect
correctness we could use
__skb_set_hash(skb, tcp_rsk(req)->txhash, false, true) FWIW.
Even l4_hash w/o taking the rnd case into account does not guarantee a
stable hash for the lifetime of a flow; what happens if packets from the
same flow are received on two NICs using different keys and/or algs?
Being computed from L4 fields does not mean it is stable. If the stable
property is needed, the hash has to be computed locally. And then comes
the other topic of caching it for reuse and potential sharing across
different consumers, sure.
Now, I'll let some time to give a chance for others to chime in.
Thanks,
Antoine
next prev parent reply other threads:[~2023-05-17 12:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-11 9:34 [PATCH net-next 0/4] net: tcp: make txhash use consistent for IPv4 Antoine Tenart
2023-05-11 9:34 ` [PATCH net-next 1/4] net: tcp: make the txhash available in TIME_WAIT sockets for IPv4 too Antoine Tenart
2023-05-11 9:34 ` [PATCH net-next 2/4] net: ipv4: use consistent txhash in TIME_WAIT and SYN_RECV Antoine Tenart
2023-05-11 9:34 ` [PATCH net-next 3/4] Documentation: net: net.core.txrehash is not specific to listening sockets Antoine Tenart
2023-05-11 9:34 ` [PATCH net-next 4/4] net: skbuff: fix l4_hash comment Antoine Tenart
2023-05-11 12:10 ` Dumitru Ceara
2023-05-11 12:33 ` Eric Dumazet
2023-05-11 13:00 ` Dumitru Ceara
2023-05-11 17:54 ` Ilya Maximets
2023-05-11 20:50 ` Dumitru Ceara
2023-05-15 8:12 ` Antoine Tenart
2023-05-15 18:23 ` Ilya Maximets
2023-05-16 7:36 ` Antoine Tenart
2023-05-16 21:25 ` Ilya Maximets
2023-05-17 12:05 ` Antoine Tenart [this message]
2023-05-17 23:00 ` Ilya Maximets
2023-05-23 15:25 ` Antoine Tenart
2023-05-11 10:24 ` [PATCH net-next 0/4] net: tcp: make txhash use consistent for IPv4 Eric Dumazet
2023-05-11 11:55 ` Antoine Tenart
2023-05-11 11:59 ` Ilya Maximets
-- strict thread matches above, loose matches on Subject: below --
2023-04-27 13:45 Antoine Tenart
2023-04-27 13:45 ` [PATCH net-next 4/4] net: skbuff: fix l4_hash comment Antoine Tenart
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=168432511934.5394.6542526478980736820@kwain \
--to=atenart@kernel.org \
--cc=davem@davemloft.net \
--cc=dceara@redhat.com \
--cc=edumazet@google.com \
--cc=i.maximets@ovn.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