svn commit: r296409 - projects/vnet/sys/net
Bjoern A. Zeeb
bz at FreeBSD.org
Sat Mar 5 15:07:26 UTC 2016
Author: bz
Date: Sat Mar 5 15:07:25 2016
New Revision: 296409
URL: https://svnweb.freebsd.org/changeset/base/296409
Log:
Decompose the protocol hooks and the interface creation as they
occur (and have to happen) at totally different times.
Interfaces are created before protocols are attached and protocol
hooks are removed before protocols are torn down.
This prevents a panic on boot when enc(4) is compiled into the
kernel or the module is loaded from loader.
Reported by: kp
Sponsored by: The FreeBSD Foundation
Modified:
projects/vnet/sys/net/if_enc.c
Modified: projects/vnet/sys/net/if_enc.c
==============================================================================
--- projects/vnet/sys/net/if_enc.c Sat Mar 5 13:17:53 2016 (r296408)
+++ projects/vnet/sys/net/if_enc.c Sat Mar 5 15:07:25 2016 (r296409)
@@ -136,7 +136,6 @@ enc_clone_destroy(struct ifnet *ifp)
sc = ifp->if_softc;
KASSERT(sc == V_enc_sc, ("sc != ifp->if_softc"));
- enc_remove_hhooks(sc);
bpfdetach(ifp);
if_detach(ifp);
if_free(ifp);
@@ -170,10 +169,6 @@ enc_clone_create(struct if_clone *ifc, i
ifp->if_softc = sc;
if_attach(ifp);
bpfattach(ifp, DLT_ENC, sizeof(struct enchdr));
- if (enc_add_hhooks(sc) != 0) {
- enc_clone_destroy(ifp);
- return (ENXIO);
- }
return (0);
}
@@ -373,6 +368,17 @@ VNET_SYSINIT(vnet_enc_init, SI_SUB_PSEUD
vnet_enc_init, NULL);
static void
+vnet_enc_init_proto(void *unused __unused)
+{
+ KASSERT(V_enc_sc != NULL, ("%s: V_enc_sc is %p\n", __func__, V_enc_sc));
+
+ if (enc_add_hhooks(V_enc_sc) != 0)
+ enc_clone_destroy(V_enc_sc->sc_ifp);
+}
+VNET_SYSINIT(vnet_enc_init_proto, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY,
+ vnet_enc_init_proto, NULL);
+
+static void
vnet_enc_uninit(const void *unused __unused)
{
@@ -381,6 +387,16 @@ vnet_enc_uninit(const void *unused __unu
VNET_SYSUNINIT(vnet_enc_uninit, SI_SUB_PSEUDO, SI_ORDER_ANY,
vnet_enc_uninit, NULL);
+static void
+vnet_enc_uninit_proto(void *unused __unused)
+{
+ KASSERT(V_enc_sc != NULL, ("%s: V_enc_sc is %p\n", __func__, V_enc_sc));
+
+ enc_remove_hhooks(V_enc_sc);
+}
+VNET_SYSUNINIT(vnet_enc_uninit_proto, SI_SUB_PROTO_IFATTACHDOMAIN,
+ SI_ORDER_ANY, vnet_enc_uninit_proto, NULL);
+
static int
enc_modevent(module_t mod, int type, void *data)
{
More information about the svn-src-projects
mailing list