Date: Tue, 26 Aug 2003 14:41:27 -0700 (PDT) From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 36982 for review Message-ID: <200308262141.h7QLfRLd016079@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=36982 Change 36982 by sam@sam_ebb on 2003/08/26 14:40:35 ip fragment queue locking from rwatson Affected files ... .. //depot/projects/netperf/sys/netinet/ip_input.c#2 edit Differences ... ==== //depot/projects/netperf/sys/netinet/ip_input.c#2 (text+ko) ==== @@ -182,6 +182,12 @@ (((((x) & 0xF) | ((((x) >> 8) & 0xF) << 4)) ^ (y)) & IPREASS_HMASK) static TAILQ_HEAD(ipqhead, ipq) ipq[IPREASS_NHASH]; +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); #ifdef IPCTL_DEFMTU SYSCTL_INT(_net_inet_ip, IPCTL_DEFMTU, mtu, CTLFLAG_RW, @@ -257,6 +263,7 @@ pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) ip_protox[pr->pr_protocol] = pr - inetsw; + IPQ_LOCK_INIT(); for (i = 0; i < IPREASS_NHASH; i++) TAILQ_INIT(&ipq[i]); @@ -744,8 +751,9 @@ ipstat.ips_fragdropped++; goto bad; } - + sum = IPREASS_HASH(ip->ip_src.s_addr, ip->ip_id); + IPQ_LOCK(); /* * Look for queue of fragments * of this datagram. @@ -799,6 +807,7 @@ * that's a non-zero multiple of 8 bytes. */ if (ip->ip_len == 0 || (ip->ip_len & 0x7) != 0) { + IPQ_UNLOCK(); ipstat.ips_toosmall++; /* XXX */ goto bad; } @@ -816,6 +825,7 @@ m->m_pkthdr.header = ip; m = ip_reass(m, &ipq[sum], fp, &divert_info, &args.divert_rule); + IPQ_UNLOCK(); if (m == 0) return; ipstat.ips_reassembled++; @@ -974,6 +984,8 @@ int hlen = ip->ip_hl << 2; int i, next; + IPQ_LOCK_ASSERT(); + /* * Presence of header sizes in mbufs * would confuse code below. @@ -1203,6 +1215,8 @@ { register struct mbuf *q; + IPQ_LOCK_ASSERT(); + while (fp->ipq_frags) { q = fp->ipq_frags; fp->ipq_frags = q->m_nextpkt; @@ -1225,6 +1239,7 @@ int s = splnet(); int i; + IPQ_LOCK(); for (i = 0; i < IPREASS_NHASH; i++) { for(fp = TAILQ_FIRST(&ipq[i]); fp;) { struct ipq *fpp; @@ -1251,6 +1266,7 @@ } } } + IPQ_UNLOCK(); ipflow_slowtimo(); splx(s); } @@ -1263,6 +1279,7 @@ { int i; + IPQ_LOCK(); for (i = 0; i < IPREASS_NHASH; i++) { while(!TAILQ_EMPTY(&ipq[i])) { ipstat.ips_fragdropped += @@ -1270,6 +1287,7 @@ ip_freef(&ipq[i], TAILQ_FIRST(&ipq[i])); } } + IPQ_UNLOCK(); in_rtqdrain(); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200308262141.h7QLfRLd016079>