From owner-p4-projects@FreeBSD.ORG Tue Aug 26 14:41:29 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6355816A4C1; Tue, 26 Aug 2003 14:41:29 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E958016A4BF for ; Tue, 26 Aug 2003 14:41:28 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6EA9C43FE5 for ; Tue, 26 Aug 2003 14:41:28 -0700 (PDT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h7QLfS0U016082 for ; Tue, 26 Aug 2003 14:41:28 -0700 (PDT) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h7QLfRLd016079 for perforce@freebsd.org; Tue, 26 Aug 2003 14:41:27 -0700 (PDT) Date: Tue, 26 Aug 2003 14:41:27 -0700 (PDT) Message-Id: <200308262141.h7QLfRLd016079@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 36982 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Aug 2003 21:41:29 -0000 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(); }