From owner-p4-projects@FreeBSD.ORG Tue Mar 9 19:45:45 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 90F2E16A4D0; Tue, 9 Mar 2004 19:45:45 -0800 (PST) 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 6B3E316A4CE for ; Tue, 9 Mar 2004 19:45:45 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 59CC643D1D for ; Tue, 9 Mar 2004 19:45:45 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i2A3jjGe011130 for ; Tue, 9 Mar 2004 19:45:45 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i2A3jiVX011127 for perforce@freebsd.org; Tue, 9 Mar 2004 19:45:44 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 9 Mar 2004 19:45:44 -0800 (PST) Message-Id: <200403100345.i2A3jiVX011127@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 48544 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: Wed, 10 Mar 2004 03:45:46 -0000 http://perforce.freebsd.org/chv.cgi?CH=48544 Change 48544 by rwatson@rwatson_paprika on 2004/03/09 19:45:29 fork() file descriptor locking fixes from Giant removal. Constify etherbroadcastaddr, fddibroadcastaddr. Remove unused zeroin_addr. Loopback of ip_encap.c locking from merge. Affected files ... .. //depot/projects/netperf_socket/sys/i386/i386/vm_machdep.c#3 integrate .. //depot/projects/netperf_socket/sys/kern/kern_fork.c#7 integrate .. //depot/projects/netperf_socket/sys/net/if_ethersubr.c#6 integrate .. //depot/projects/netperf_socket/sys/net/if_fddisubr.c#2 integrate .. //depot/projects/netperf_socket/sys/netinet/in_pcb.c#3 integrate .. //depot/projects/netperf_socket/sys/netinet/in_var.h#2 integrate .. //depot/projects/netperf_socket/sys/netinet/ip_encap.c#2 integrate Differences ... ==== //depot/projects/netperf_socket/sys/i386/i386/vm_machdep.c#3 (text+ko) ==== @@ -41,9 +41,8 @@ */ #include -__FBSDID("$FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.228 2004/03/09 02:49:24 jb Exp $"); +__FBSDID("$FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.229 2004/03/09 20:53:01 jb Exp $"); -#include "opt_cpu.h" #include "opt_isa.h" #include "opt_kstack_pages.h" #include "opt_npx.h" @@ -78,9 +77,6 @@ #include #include #include -#ifdef CPU_ELAN -#include -#endif #ifdef CPU_ELAN #include @@ -563,12 +559,6 @@ } outb(0xf0, 0x00); /* Reset. */ #else -#ifdef CPU_ELAN - if (elan_mmcr != NULL) - /* SYS_RST */ - elan_mmcr->RESCFG = 1; -#endif - /* * Attempt to do a CPU reset via the keyboard controller, * do not turn of the GateA20, as any machine that fails ==== //depot/projects/netperf_socket/sys/kern/kern_fork.c#7 (text+ko) ==== @@ -39,7 +39,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_fork.c,v 1.220 2004/03/08 00:32:34 peter Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_fork.c,v 1.221 2004/03/10 00:27:36 jmg Exp $"); #include "opt_ktrace.h" #include "opt_mac.h" @@ -232,7 +232,9 @@ */ if (flags & RFCFDG) { struct filedesc *fdtmp; + FILEDESC_LOCK(td->td_proc->p_fd); fdtmp = fdinit(td->td_proc->p_fd); + FILEDESC_UNLOCK(td->td_proc->p_fd); fdfree(td); p1->p_fd = fdtmp; } @@ -428,7 +430,9 @@ * Copy filedesc. */ if (flags & RFCFDG) { + FILEDESC_LOCK(td->td_proc->p_fd); fd = fdinit(td->td_proc->p_fd); + FILEDESC_UNLOCK(td->td_proc->p_fd); fdtol = NULL; } else if (flags & RFFDG) { FILEDESC_LOCK(p1->p_fd); ==== //depot/projects/netperf_socket/sys/net/if_ethersubr.c#6 (text+ko) ==== @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 - * $FreeBSD: src/sys/net/if_ethersubr.c,v 1.160 2004/03/02 14:37:23 mlaier Exp $ + * $FreeBSD: src/sys/net/if_ethersubr.c,v 1.161 2004/03/09 23:55:59 rwatson Exp $ */ #include "opt_atalk.h" @@ -111,7 +111,7 @@ bdgtakeifaces_t *bdgtakeifaces_ptr; struct bdg_softc *ifp2sc; -static u_char etherbroadcastaddr[ETHER_ADDR_LEN] = +static const u_char etherbroadcastaddr[ETHER_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; static int ether_resolvemulti(struct ifnet *, struct sockaddr **, ==== //depot/projects/netperf_socket/sys/net/if_fddisubr.c#2 (text+ko) ==== @@ -33,7 +33,7 @@ * SUCH DAMAGE. * * from: if_ethersubr.c,v 1.5 1994/12/13 22:31:45 wollman Exp - * $FreeBSD: src/sys/net/if_fddisubr.c,v 1.87 2003/11/14 21:02:22 andre Exp $ + * $FreeBSD: src/sys/net/if_fddisubr.c,v 1.88 2004/03/09 23:55:59 rwatson Exp $ */ #include "opt_atalk.h" @@ -89,7 +89,7 @@ extern u_char aarp_org_code[ 3 ]; #endif /* NETATALK */ -static u_char fddibroadcastaddr[FDDI_ADDR_LEN] = +static const u_char fddibroadcastaddr[FDDI_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; static int fddi_resolvemulti(struct ifnet *, struct sockaddr **, ==== //depot/projects/netperf_socket/sys/netinet/in_pcb.c#3 (text+ko) ==== @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95 - * $FreeBSD: src/sys/netinet/in_pcb.c,v 1.136 2004/01/13 09:51:47 ume Exp $ + * $FreeBSD: src/sys/netinet/in_pcb.c,v 1.137 2004/03/10 01:01:04 rwatson Exp $ */ #include "opt_ipsec.h" @@ -83,8 +83,6 @@ #include #endif /* FAST_IPSEC */ -struct in_addr zeroin_addr; - /* * These configure the range of local port addresses assigned to * "unspecified" outgoing connections/packets/whatever. ==== //depot/projects/netperf_socket/sys/netinet/in_var.h#2 (text+ko) ==== @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)in_var.h 8.2 (Berkeley) 1/9/95 - * $FreeBSD: src/sys/netinet/in_var.h,v 1.48 2003/11/14 21:02:21 andre Exp $ + * $FreeBSD: src/sys/netinet/in_var.h,v 1.49 2004/03/10 01:01:04 rwatson Exp $ */ #ifndef _NETINET_IN_VAR_H_ @@ -83,7 +83,6 @@ #ifdef _KERNEL -extern struct in_addr zeroin_addr; extern u_char inetctlerrmap[]; /* ==== //depot/projects/netperf_socket/sys/netinet/ip_encap.c#2 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/netinet/ip_encap.c,v 1.18 2003/06/01 09:20:38 phk Exp $ */ +/* $FreeBSD: src/sys/netinet/ip_encap.c,v 1.19 2004/03/10 02:48:50 rwatson Exp $ */ /* $KAME: ip_encap.c,v 1.41 2001/03/15 08:35:08 itojun Exp $ */ /* @@ -98,31 +98,20 @@ const struct sockaddr *); static void encap_fillarg(struct mbuf *, const struct encaptab *); -#ifndef LIST_HEAD_INITIALIZER -/* rely upon BSS initialization */ -LIST_HEAD(, encaptab) encaptab; -#else +/* + * All global variables in ip_encap.c are locked using encapmtx. + */ +static struct mtx encapmtx; +MTX_SYSINIT(encapmtx, &encapmtx, "encapmtx", MTX_DEF); LIST_HEAD(, encaptab) encaptab = LIST_HEAD_INITIALIZER(&encaptab); -#endif +/* + * We currently keey encap_init() for source code compatibility reasons -- + * it's referenced by KAME pieces in netinet6. + */ void encap_init() { - static int initialized = 0; - - if (initialized) - return; - initialized++; -#if 0 - /* - * we cannot use LIST_INIT() here, since drivers may want to call - * encap_attach(), on driver attach. encap_init() will be called - * on AF_INET{,6} initialization, which happens after driver - * initialization - using LIST_INIT() here can nuke encap_attach() - * from drivers. - */ - LIST_INIT(&encaptab); -#endif } #ifdef INET @@ -152,6 +141,7 @@ match = NULL; matchprio = 0; + mtx_lock(&encapmtx); LIST_FOREACH(ep, &encaptab, chain) { if (ep->af != AF_INET) continue; @@ -193,6 +183,7 @@ match = ep; } } + mtx_unlock(&encapmtx); if (match) { /* found a match, "match" has the best one */ @@ -237,6 +228,7 @@ match = NULL; matchprio = 0; + mtx_lock(&encapmtx); LIST_FOREACH(ep, &encaptab, chain) { if (ep->af != AF_INET6) continue; @@ -261,6 +253,7 @@ match = ep; } } + mtx_unlock(&encapmtx); if (match) { /* found a match */ @@ -285,6 +278,7 @@ struct encaptab *ep; { + mtx_assert(&encapmtx, MA_OWNED); LIST_INSERT_HEAD(&encaptab, ep, chain); } @@ -303,21 +297,17 @@ void *arg; { struct encaptab *ep; - int s; - s = splnet(); /* sanity check on args */ - if (sp->sa_len > sizeof(ep->src) || dp->sa_len > sizeof(ep->dst)) { - goto fail; - } - if (sp->sa_len != dp->sa_len) { - goto fail; - } - if (af != sp->sa_family || af != dp->sa_family) { - goto fail; - } + if (sp->sa_len > sizeof(ep->src) || dp->sa_len > sizeof(ep->dst)) + return (NULL); + if (sp->sa_len != dp->sa_len) + return (NULL); + if (af != sp->sa_family || af != dp->sa_family) + return (NULL); /* check if anyone have already attached with exactly same config */ + mtx_lock(&encapmtx); LIST_FOREACH(ep, &encaptab, chain) { if (ep->af != af) continue; @@ -332,12 +322,14 @@ bcmp(&ep->dstmask, dm, dp->sa_len) != 0) continue; - goto fail; + mtx_unlock(&encapmtx); + return (NULL); } ep = malloc(sizeof(*ep), M_NETADDR, M_NOWAIT); /*XXX*/ if (ep == NULL) { - goto fail; + mtx_unlock(&encapmtx); + return (NULL); } bzero(ep, sizeof(*ep)); @@ -351,13 +343,8 @@ ep->arg = arg; encap_add(ep); - - splx(s); - return ep; - -fail: - splx(s); - return NULL; + mtx_unlock(&encapmtx); + return (ep); } const struct encaptab * @@ -369,16 +356,14 @@ void *arg; { struct encaptab *ep; - int s; - s = splnet(); /* sanity check on args */ if (!func) - goto fail; + return (NULL); ep = malloc(sizeof(*ep), M_NETADDR, M_NOWAIT); /*XXX*/ if (ep == NULL) - goto fail; + return (NULL); bzero(ep, sizeof(*ep)); ep->af = af; @@ -387,14 +372,10 @@ ep->psw = psw; ep->arg = arg; + mtx_lock(&encapmtx); encap_add(ep); - - splx(s); - return ep; - -fail: - splx(s); - return NULL; + mtx_unlock(&encapmtx); + return (ep); } int @@ -404,13 +385,16 @@ const struct encaptab *ep = cookie; struct encaptab *p; + mtx_lock(&encapmtx); LIST_FOREACH(p, &encaptab, chain) { if (p == ep) { LIST_REMOVE(p, chain); + mtx_unlock(&encapmtx); free(p, M_NETADDR); /*XXX*/ return 0; } } + mtx_unlock(&encapmtx); return EINVAL; }