-/* $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 $ */
/*
sigcoderet
};
+#ifdef DIAGNOSTIC
+int pdevinit_done = 0;
+#endif
/*
* System startup; initialize the world, create process 0, mount root
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();
-/* $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 $ */
/*
#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 *);
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;
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);
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);
}
/*
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);
dst += IFNAMSIZ;
}
- rw_exit_read(&if_cloners_lock);
return (error);
}
-/* $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 $ */
/*
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 *);