From owner-freebsd-net@FreeBSD.ORG Mon Oct 1 19:22:08 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D9E3E106564A; Mon, 1 Oct 2012 19:22:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id ABFE08FC1B; Mon, 1 Oct 2012 19:22:07 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 062D1B918; Mon, 1 Oct 2012 15:22:07 -0400 (EDT) From: John Baldwin To: freebsd-net@freebsd.org Date: Mon, 1 Oct 2012 15:21:53 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p20; KDE/4.5.5; amd64; ; ) References: <201209280835.56684.jhb@freebsd.org> In-Reply-To: <201209280835.56684.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201210011521.53397.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 01 Oct 2012 15:22:07 -0400 (EDT) Cc: Alexander Motin , Marcin Cieslak Subject: Re: enc(4) uninitialized in -current? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Oct 2012 19:22:08 -0000 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 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=C3=A9 > > >> wrote: > > >> > On Thu, Sep 27, 2012 at 12:10 AM, Marcin Cieslak wrote: > > >> >> I have just updated by 9.0-something laptop to 10.0-CURRENT r2409= 48 > > >> >> 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=20 > > > used in ipsec_output.c due to duplicate symbols. > >=20 > > 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.=20 > >=20 > > > OTOH, have you created an enc0 device? I can't find anything that=20 > > > automatically creates it. > >=20 > > No. Previously, in 9.x times, it was always present in the ifconfig out= put. >=20 > Ok, I think that is the root cause. >=20 > HEAD should still be creating an enc0. The enc.c file creates an enc_clo= ner: >=20 > IFC_SIMPLE_DECLARE(enc, 1); >=20 > 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; >=20 > 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 t= he module to "if_enc" instead of "enc" (this is more typical for network interfaces anyway). Index: if_enc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- if_enc.c (revision 241096) +++ if_enc.c (working copy) @@ -179,12 +179,12 @@ enc_modevent(module_t mod, int type, void *data) } =20 static moduledata_t enc_mod =3D { =2D "enc", + "if_enc", enc_modevent, 0 }; =20 =2DDECLARE_MODULE(enc, enc_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); +DECLARE_MODULE(if_enc, enc_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); =20 static int enc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, =2D-=20 John Baldwin