git: a426ae1e411e - stable/15 - divert: Use a better source identifier for netisr_queue_src() calls
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 31 Mar 2026 15:59:07 UTC
The branch stable/15 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=a426ae1e411ee315682964dc1a423eb023f7341d
commit a426ae1e411ee315682964dc1a423eb023f7341d
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-02-26 20:25:35 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-03-31 15:57:29 +0000
divert: Use a better source identifier for netisr_queue_src() calls
These opaque IDs are used by netisr to distribute work among threads.
The mapping function is simply SourceID % numthreads, so using socket
addresses as source IDs isn't going to distribute packets well due to
alignment.
Use the divert socket's generation number instead, as that suits this
purpose much better.
Reviewed by: zlei, glebius
MFC after: 1 week
Sponsored by: OPNsense
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D55537
(cherry picked from commit 5547a7bb39accd8f151b53e90b41d13b55f84c95)
---
sys/netinet/ip_divert.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index f98a599e7554..75371c7dacb3 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -503,8 +503,10 @@ static int
div_output_inbound(int family, struct socket *so, struct mbuf *m,
struct sockaddr_in *sin)
{
+ struct divcb *dcb;
struct ifaddr *ifa;
+ dcb = so->so_pcb;
if (m->m_pkthdr.rcvif == NULL) {
/*
* No luck with the name, check by IP address.
@@ -541,14 +543,14 @@ div_output_inbound(int family, struct socket *so, struct mbuf *m,
m->m_flags |= M_MCAST;
else if (in_ifnet_broadcast(ip->ip_dst, m->m_pkthdr.rcvif))
m->m_flags |= M_BCAST;
- netisr_queue_src(NETISR_IP, (uintptr_t)so, m);
+ netisr_queue_src(NETISR_IP, (uintptr_t)dcb->dcb_gencnt, m);
DIVSTAT_INC(inbound);
break;
}
#endif
#ifdef INET6
case AF_INET6:
- netisr_queue_src(NETISR_IPV6, (uintptr_t)so, m);
+ netisr_queue_src(NETISR_IPV6, (uintptr_t)dcb->dcb_gencnt, m);
DIVSTAT_INC(inbound);
break;
#endif