enc(4) uninitialized in -current?

John Baldwin jhb at freebsd.org
Mon Oct 1 19:22:08 UTC 2012


On Friday, September 28, 2012 8:35:56 am John Baldwin wrote:
> On Thursday, September 27, 2012 9:02:59 am Marcin Cieslak wrote:
> > >> John Baldwin <jhb at freebsd.org> wrote:
> > > On Wednesday, September 26, 2012 6:42:19 pm Garrett Cooper wrote:
> > >> On Wed, Sep 26, 2012 at 3:33 PM, Olivier Cochard-Labbé
> > >> <olivier at cochard.me> wrote:
> > >> > On Thu, Sep 27, 2012 at 12:10 AM, Marcin Cieslak <saper at saper.info> wrote:
> > >> >> I have just updated by 9.0-something laptop to 10.0-CURRENT r240948
> > >> >> and it very quickly panics after enabling network with IPsec
> > >> >> (I am using IPsec w/racoon for IPv4 over 802.11, also using
> > >> >> tunelled IPv6).
> > >> >
> > >> > I don't know if it's related, but one of the first dmesg message
> > >> > displayd on my -current (rev 240921) is:
> > >> >
> > >> > module_register: module enc already exists!
> > >> > Module enc failed to register: 17
> > >
> > > I suspect this is the root cause and that the "wrong" global variable is being 
> > > used in ipsec_output.c due to duplicate symbols.
> > 
> > As the original poster: I don't have this "module enc already exists!" message.
> > I have had "device enc" in the kernel config file and I didn't try
> > to load if_enc as module. I have IPSEC permanently enabled
> > in the kernel and it is initialized at boot with setkey and later
> > with racoon. 
> > 
> > > OTOH, have you created an enc0 device?  I can't find anything that 
> > > automatically creates it.
> > 
> > No. Previously, in 9.x times, it was always present in the ifconfig output.
> 
> Ok, I think that is the root cause.
> 
> HEAD should still be creating an enc0.  The enc.c file creates an enc_cloner:
> 
> IFC_SIMPLE_DECLARE(enc, 1);
> 
> static int
> enc_modevent(module_t mod, int type, void *data)
> {
> 	switch (type) {
> 	case MOD_LOAD:
> 		mtx_init(&enc_mtx, "enc mtx", NULL, MTX_DEF);
> 		if_clone_attach(&enc_cloner);
> 		break;
> 
> That '1' is the minimum number of interfaces to create on attach in
> ifc_simple_attach().  I've no idea why enc0 isn't being created on boot, but
> it should be.

I tracked this down.  At some point a new CAM 'enc' module was added, and it
used the same module name as 'device enc'.  As a result, when both were
compiled into the kernel, only one of the modules was included (and had its
event handler run).  Since CAM is earlier in the link order, it always won
and enc(4) was never initialized.  The patch below fixes this by renaming the
module to "if_enc" instead of "enc" (this is more typical for network
interfaces anyway).

Index: if_enc.c
===================================================================
--- if_enc.c	(revision 241096)
+++ if_enc.c	(working copy)
@@ -179,12 +179,12 @@ enc_modevent(module_t mod, int type, void *data)
 }
 
 static moduledata_t enc_mod = {
-	"enc",
+	"if_enc",
 	enc_modevent,
 	0
 };
 
-DECLARE_MODULE(enc, enc_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY);
+DECLARE_MODULE(if_enc, enc_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY);
 
 static int
 enc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,

-- 
John Baldwin


More information about the freebsd-net mailing list