Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Feb 2026 20:26:17 +0000
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 5547a7bb39ac - main - divert: Use a better source identifier for netisr_queue_src() calls
Message-ID:  <69a0ac69.2360d.f48d28@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=5547a7bb39accd8f151b53e90b41d13b55f84c95

commit 5547a7bb39accd8f151b53e90b41d13b55f84c95
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-02-26 20:25:35 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-02-26 20:25:35 +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
---
 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 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


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69a0ac69.2360d.f48d28>