Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Jan 2006 17:19:57 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 89728 for review
Message-ID:  <200601151719.k0FHJvP3099445@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=89728

Change 89728 by rwatson@rwatson_peppercorn on 2006/01/15 17:19:04

	Allocate ipq fragment reassembly queue headers using UMA rather than
	the mbuf allocator.

Affected files ...

.. //depot/projects/netsmp/src/sys/netinet/ip_input.c#7 edit

Differences ...

==== //depot/projects/netsmp/src/sys/netinet/ip_input.c#7 (text+ko) ====

@@ -107,17 +107,6 @@
 	&ip_keepfaith,	0,
 	"Enable packet capture for FAITH IPv4->IPv6 translater daemon");
 
-static int    nipq = 0;         /* total # of reass queues */
-static int    maxnipq;
-SYSCTL_INT(_net_inet_ip, OID_AUTO, maxfragpackets, CTLFLAG_RW,
-	&maxnipq, 0,
-	"Maximum number of IPv4 fragment reassembly queue entries");
-
-static int    maxfragsperpacket;
-SYSCTL_INT(_net_inet_ip, OID_AUTO, maxfragsperpacket, CTLFLAG_RW,
-	&maxfragsperpacket, 0,
-	"Maximum number of IPv4 fragments allowed per packet");
-
 static int	ip_sendsourcequench = 0;
 SYSCTL_INT(_net_inet_ip, OID_AUTO, sendsourcequench, CTLFLAG_RW,
 	&ip_sendsourcequench, 0,
@@ -166,22 +155,41 @@
 SYSCTL_STRUCT(_net_inet_ip, IPCTL_STATS, stats, CTLFLAG_RW,
     &ipstat, ipstat, "IP statistics (struct ipstat, netinet/ip_var.h)");
 
-/* Packet reassembly stuff */
+/*
+ * IP datagram reassembly.
+ */
 #define IPREASS_NHASH_LOG2      6
 #define IPREASS_NHASH           (1 << IPREASS_NHASH_LOG2)
 #define IPREASS_HMASK           (IPREASS_NHASH - 1)
 #define IPREASS_HASH(x,y) \
 	(((((x) & 0xF) | ((((x) >> 8) & 0xF) << 4)) ^ (y)) & IPREASS_HMASK)
 
+/*
+ * For historical reasons, the max ipq size is maintained outside of the UMA
+ * zone.  At some point, it would be good to start using the UMA zone max.
+ */
+static uma_zone_t ipq_zone;
 static TAILQ_HEAD(ipqhead, ipq) ipq[IPREASS_NHASH];
-struct mtx ipqlock;
-struct callout ipport_tick_callout;
 
+static struct mtx ipqlock;
 #define	IPQ_LOCK()	mtx_lock(&ipqlock)
 #define	IPQ_UNLOCK()	mtx_unlock(&ipqlock)
 #define	IPQ_LOCK_INIT()	mtx_init(&ipqlock, "ipqlock", NULL, MTX_DEF)
 #define	IPQ_LOCK_ASSERT()	mtx_assert(&ipqlock, MA_OWNED)
 
+static int    nipq = 0;         /* total # of reass queues */
+static int    maxnipq;
+SYSCTL_INT(_net_inet_ip, OID_AUTO, maxfragpackets, CTLFLAG_RW,
+	&maxnipq, 0,
+	"Maximum number of IPv4 fragment reassembly queue entries");
+
+static int    maxfragsperpacket;
+SYSCTL_INT(_net_inet_ip, OID_AUTO, maxfragsperpacket, CTLFLAG_RW,
+	&maxfragsperpacket, 0,
+	"Maximum number of IPv4 fragments allowed per packet");
+
+struct callout ipport_tick_callout;
+
 #ifdef IPCTL_DEFMTU
 SYSCTL_INT(_net_inet_ip, IPCTL_DEFMTU, mtu, CTLFLAG_RW,
     &ip_mtu, 0, "Default MTU");
@@ -249,6 +257,8 @@
 	    TAILQ_INIT(&ipq[i]);
 	maxnipq = nmbclusters / 32;
 	maxfragsperpacket = 16;
+	ipq_zone = uma_zcreate("ipq", sizeof(struct ipq), NULL, NULL, NULL,
+	    NULL, UMA_ALIGN_PTR, 0);
 
 	/* Start ipport_tick. */
 	callout_init(&ipport_tick_callout, CALLOUT_MPSAFE);
@@ -865,12 +875,12 @@
 	 * If first fragment to arrive, create a reassembly queue.
 	 */
 	if (fp == NULL) {
-		if ((t = m_get(M_DONTWAIT, MT_FTABLE)) == NULL)
+		fp = uma_zalloc(ipq_zone, M_NOWAIT);
+		if (fp == NULL)
 			goto dropfrag;
-		fp = mtod(t, struct ipq *);
 #ifdef MAC
 		if (mac_init_ipq(fp, M_NOWAIT) != 0) {
-			m_free(t);
+			uma_zfree(ipq_zone, fp);
 			goto dropfrag;
 		}
 		mac_create_ipq(m, fp);
@@ -1038,7 +1048,7 @@
 	ip->ip_dst = fp->ipq_dst;
 	TAILQ_REMOVE(head, fp, ipq_list);
 	nipq--;
-	(void) m_free(dtom(fp));
+	uma_zfree(ipq_zone, fp);
 	m->m_len += (ip->ip_hl << 2);
 	m->m_data -= (ip->ip_hl << 2);
 	/* some debugging cruft by sklower, below, will go away soon */
@@ -1079,7 +1089,7 @@
 		m_freem(q);
 	}
 	TAILQ_REMOVE(fhp, fp, ipq_list);
-	(void) m_free(dtom(fp));
+	uma_zfree(ipq_zone, fp);
 	nipq--;
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200601151719.k0FHJvP3099445>