summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/init_main.c8
-rw-r--r--sys/net/if.c34
-rw-r--r--sys/net/if_var.h3
-rw-r--r--sys/sys/device.h7
4 files changed, 24 insertions, 28 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index aa4c0a83ef7..91070090bb1 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init_main.c,v 1.280 2018/08/13 15:26:17 visa Exp $ */
+/* $OpenBSD: init_main.c,v 1.281 2018/09/10 16:18:34 sashan Exp $ */
/* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */
/*
@@ -174,6 +174,9 @@ struct emul emul_native = {
sigcoderet
};
+#ifdef DIAGNOSTIC
+int pdevinit_done = 0;
+#endif
/*
* System startup; initialize the world, create process 0, mount root
@@ -401,6 +404,9 @@ main(void *framep)
for (pdev = pdevinit; pdev->pdev_attach != NULL; pdev++)
if (pdev->pdev_count > 0)
(*pdev->pdev_attach)(pdev->pdev_count);
+#ifdef DIAGNOSTIC
+ pdevinit_done = 1;
+#endif
#ifdef CRYPTO
crypto_init();
diff --git a/sys/net/if.c b/sys/net/if.c
index f4978c1112d..0e0c767cc3b 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.562 2018/09/10 16:07:20 henning Exp $ */
+/* $OpenBSD: if.c,v 1.563 2018/09/10 16:18:34 sashan Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -129,6 +129,8 @@
#include <net/pfvar.h>
#endif
+#include <sys/device.h>
+
void if_attachsetup(struct ifnet *);
void if_attachdomain(struct ifnet *);
void if_attach_common(struct ifnet *);
@@ -220,8 +222,6 @@ void if_idxmap_remove(struct ifnet *);
TAILQ_HEAD(, ifg_group) ifg_head = TAILQ_HEAD_INITIALIZER(ifg_head);
-/* Serialize access to &if_cloners and if_cloners_count */
-struct rwlock if_cloners_lock = RWLOCK_INITIALIZER("ifclonerslk");
LIST_HEAD(, if_clone) if_cloners = LIST_HEAD_INITIALIZER(if_cloners);
int if_cloners_count;
@@ -1253,13 +1253,11 @@ if_clone_lookup(const char *name, int *unitp)
if (cp - name < IFNAMSIZ-1 && *cp == '0' && cp[1] != '\0')
return (NULL); /* unit number 0 padded */
- rw_enter_read(&if_cloners_lock);
LIST_FOREACH(ifc, &if_cloners, ifc_list) {
if (strlen(ifc->ifc_name) == cp - name &&
!strncmp(name, ifc->ifc_name, cp - name))
break;
}
- rw_exit_read(&if_cloners_lock);
if (ifc == NULL)
return (NULL);
@@ -1285,22 +1283,15 @@ if_clone_lookup(const char *name, int *unitp)
void
if_clone_attach(struct if_clone *ifc)
{
- rw_enter_write(&if_cloners_lock);
+ /*
+ * we are called at kernel boot by main(), when pseudo devices are
+ * being attached. The main() is the only guy which may alter the
+ * if_cloners. While system is running and main() is done with
+ * initialization, the if_cloners becomes immutable.
+ */
+ KASSERT(pdevinit_done == 0);
LIST_INSERT_HEAD(&if_cloners, ifc, ifc_list);
if_cloners_count++;
- rw_exit_write(&if_cloners_lock);
-}
-
-/*
- * Unregister a network interface cloner.
- */
-void
-if_clone_detach(struct if_clone *ifc)
-{
- rw_enter_write(&if_cloners_lock);
- LIST_REMOVE(ifc, ifc_list);
- if_cloners_count--;
- rw_exit_write(&if_cloners_lock);
}
/*
@@ -1315,17 +1306,13 @@ if_clone_list(struct if_clonereq *ifcr)
if ((dst = ifcr->ifcr_buffer) == NULL) {
/* Just asking how many there are. */
- rw_enter_read(&if_cloners_lock);
ifcr->ifcr_total = if_cloners_count;
- rw_exit_read(&if_cloners_lock);
return (0);
}
if (ifcr->ifcr_count < 0)
return (EINVAL);
- rw_enter_read(&if_cloners_lock);
-
ifcr->ifcr_total = if_cloners_count;
count = MIN(if_cloners_count, ifcr->ifcr_count);
@@ -1341,7 +1328,6 @@ if_clone_list(struct if_clonereq *ifcr)
dst += IFNAMSIZ;
}
- rw_exit_read(&if_cloners_lock);
return (error);
}
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index e9f69c964cb..564b59037fd 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_var.h,v 1.89 2018/01/10 23:50:39 dlg Exp $ */
+/* $OpenBSD: if_var.h,v 1.90 2018/09/10 16:18:34 sashan Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -328,7 +328,6 @@ void ifafree(struct ifaddr *);
int if_isconnected(const struct ifnet *, unsigned int);
void if_clone_attach(struct if_clone *);
-void if_clone_detach(struct if_clone *);
int if_clone_create(const char *, int);
int if_clone_destroy(const char *);
diff --git a/sys/sys/device.h b/sys/sys/device.h
index 00a1f6ad2a6..1faa0192a99 100644
--- a/sys/sys/device.h
+++ b/sys/sys/device.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: device.h,v 1.54 2015/12/11 16:07:02 mpi Exp $ */
+/* $OpenBSD: device.h,v 1.55 2018/09/10 16:18:34 sashan Exp $ */
/* $NetBSD: device.h,v 1.15 1996/04/09 20:55:24 cgd Exp $ */
/*
@@ -164,6 +164,11 @@ struct pdevinit {
};
#ifdef _KERNEL
+
+#ifdef DIAGNOSTIC
+extern int pdevinit_done;
+#endif
+
extern struct devicelist alldevs; /* list of all devices */
extern int autoconf_verbose;