PERFORCE change 48544 for review
Robert Watson
rwatson at FreeBSD.org
Tue Mar 9 19:45:46 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=48544
Change 48544 by rwatson at 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 <sys/cdefs.h>
-__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 <machine/pcb.h>
#include <machine/pcb_ext.h>
#include <machine/vm86.h>
-#ifdef CPU_ELAN
-#include <machine/elan_mmcr.h>
-#endif
#ifdef CPU_ELAN
#include <machine/elan_mmcr.h>
@@ -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 <sys/cdefs.h>
-__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 <netipsec/key.h>
#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;
}
More information about the p4-projects
mailing list