aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2026-02-26 20:25:35 +0000
committerMark Johnston <markj@FreeBSD.org>2026-02-26 20:25:35 +0000
commit5547a7bb39accd8f151b53e90b41d13b55f84c95 (patch)
tree4f2db57877471a20e5ddfc663de83fef690abcd3
parentd971bc5220f7adb8a2bdfadc8e3ca7ffcf9ca843 (diff)
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
-rw-r--r--sys/netinet/ip_divert.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index 9f1d862a0531..2b85bd4a50bb 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -502,8 +502,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.
@@ -540,14 +542,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