git: 814fc45f3154 - stable/15 - tcp: Enable symmetric hashing by setting hash on outgoing conns
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 29 Oct 2026 07:41:25 UTC
The branch stable/15 has been updated by kbowling:
URL: https://cgit.FreeBSD.org/src/commit/?id=814fc45f3154d3a2442681fdec41e26d43beb7b6
commit 814fc45f3154d3a2442681fdec41e26d43beb7b6
Author: Andrew Gallatin <gallatin@FreeBSD.org>
AuthorDate: 2025-11-22 14:29:35 +0000
Commit: Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-10-29 07:37:57 +0000
tcp: Enable symmetric hashing by setting hash on outgoing conns
Now that we can trust NICs to supply an identical hash result
to software, we can setup the inpcb hash on outgoing connections.
This gives us symmetric hashing, meaning packets should enter
and leave on the same NIC queue.
Differential Revision: https://reviews.freebsd.org/D53104
Reviewed by: adrian, cc, kbowling, tuexen, zlei
Sponsored by: Netflix
(cherry picked from commit dd0e6bb996dc46e1d91f3d9aef87979716479465)
---
sys/netinet/tcp_usrreq.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 6b2388b9363c..9423a54a8a31 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -75,6 +75,7 @@
#include <netinet/in.h>
#include <netinet/in_kdtrace.h>
#include <netinet/in_pcb.h>
+#include <netinet/in_rss.h>
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
#include <netinet/ip.h>
@@ -82,6 +83,7 @@
#ifdef INET6
#include <netinet/ip6.h>
#include <netinet6/in6_pcb.h>
+#include <netinet6/in6_rss.h>
#include <netinet6/ip6_var.h>
#include <netinet6/scope6_var.h>
#endif
@@ -1488,6 +1490,10 @@ tcp_connect(struct tcpcb *tp, struct sockaddr_in *sin, struct thread *td)
if (error != 0)
return (error);
+ /* set the hash on the connection */
+ rss_proto_software_hash_v4(inp->inp_faddr, inp->inp_laddr,
+ inp->inp_fport, inp->inp_lport, IPPROTO_TCP,
+ &inp->inp_flowid, &inp->inp_flowtype);
/*
* Compute window scaling to request:
* Scale to fit into sweet spot. See tcp_syncache.c.
@@ -1533,6 +1539,10 @@ tcp6_connect(struct tcpcb *tp, struct sockaddr_in6 *sin6, struct thread *td)
if (error != 0)
return (error);
+ /* set the hash on the connection */
+ rss_proto_software_hash_v6(&inp->in6p_faddr,
+ &inp->in6p_laddr, inp->inp_fport, inp->inp_lport, IPPROTO_TCP,
+ &inp->inp_flowid, &inp->inp_flowtype);
/* Compute window scaling to request. */
while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
(TCP_MAXWIN << tp->request_r_scale) < sb_max)