From owner-freebsd-current@freebsd.org Tue Feb 6 18:33:27 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94DB5EF0E86 for ; Tue, 6 Feb 2018 18:33:27 +0000 (UTC) (envelope-from lists@jnielsen.net) Received: from webmail5.jnielsen.net (webmail5.jnielsen.net [69.87.218.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "webmail2.jnielsen.net", Issuer "freebsdsolutions.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 2F385784BB for ; Tue, 6 Feb 2018 18:33:26 +0000 (UTC) (envelope-from lists@jnielsen.net) Received: from [10.3.135.23] (50-207-240-162-static.hfc.comcastbusiness.net [50.207.240.162]) (authenticated bits=0) by webmail5.jnielsen.net (8.15.2/8.15.2) with ESMTPSA id w16IXMJC000659 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 6 Feb 2018 11:33:25 -0700 (MST) (envelope-from lists@jnielsen.net) X-Authentication-Warning: webmail5.jnielsen.net: Host 50-207-240-162-static.hfc.comcastbusiness.net [50.207.240.162] claimed to be [10.3.135.23] Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: Fatal trap 12 booting FreeBSD-CURRENT via isboot kernel module. From: John Nielsen In-Reply-To: Date: Tue, 6 Feb 2018 11:33:22 -0700 Cc: freebsd-current , Daisuke Aoyama Content-Transfer-Encoding: quoted-printable Message-Id: <5EDB0747-41DE-4ECF-925E-EF24FAA550F3@jnielsen.net> References: <3E242843-7D43-4A36-A448-E4B0DACB2AB4@jnielsen.net> To: Maurizio Vairani X-Mailer: Apple Mail (2.3273) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 18:33:27 -0000 > On Feb 6, 2018, at 10:54 AM, John Nielsen wrote: >=20 >>=20 >> On Feb 4, 2018, at 2:50 AM, Maurizio Vairani = wrote: >>=20 >> 2018-01-29 18:38 GMT+01:00 John Nielsen : >> [ resending from correct email address ] >>=20 >>> On Jan 29, 2018, at 6:05 AM, Maurizio Vairani = wrote: >>>=20 >>> I am running >>> # uname >>> -a >>>=20 >>> FreeBSD 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r328383: Thu Jan 25 = 04:48:52 >>> UTC 2018 = root@releng3.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC >>> amd64 >>>=20 >>> After compiling the kernel module as discussed in this thread : >>> = https://lists.freebsd.org/pipermail/freebsd-current/2018-January/068272.ht= ml >>>=20 >>> I can boot FreeBSD via iSCSI using iPXE. But when the isboot, the = iSCSI >>> boot driver version 0.2.13, starts I receive a panic: >>> = https://mega.nz/#!tkVwBBKA!PUj14-Za6KCNaoo9hxuXORRLQoWkb4LMvTdUA1BorD4 >>>=20 >>> Any idea? >>=20 >> Bummer!=20 >>=20 >> Aoyama-san- >>=20 >> Are you still maintaining isboot? Can you help debug this issue on = FreeBSD 12-CURRENT? >>=20 >> Once we get it working I will update the port with whatever is needed = and send you the patches in case you'd like to cut a new release. >>=20 >> Thank you! >>=20 >> I have solved the issue changing the function isboot_ifup() in the = source file isboot.c. >=20 > Here is a patch with some changes to minimize the diff. Except for the = printed error messages does that look functionally equivalent? >=20 > Now the question is why is this change needed and for what values of = __FreeBSD_version is it appropriate? Apparently sending a NULL socket pointer to ifioctl hasn't worked since = this commit in 2011: https://svnweb.freebsd.org/base?view=3Drevision&revision=3D218757 So I'm going to add this patch to the port unconditionally once it = works. Unfortunately, I can't compile the port with either my patch below or = your original replacement version of isboot_ifup(). :( Did you make = other changes? Here's the error I'm getting: --- isboot.o --- isboot.c:425:53: error: incomplete definition of type 'struct thread' error =3D socreate(AF_INET, &so, SOCK_DGRAM, 0, td->td_ucred, td); ~~^ /usr/src/sys/sys/systm.h:185:8: note: forward declaration of 'struct = thread' struct thread; ^ 1 error generated. > # diff -u isboot.c.patched1 isboot.c > --- isboot.c.patched1 2018-02-06 10:35:20.808692000 -0700 > +++ isboot.c 2018-02-06 10:50:05.347663000 -0700 > @@ -417,28 +417,36 @@ > isboot_ifup(struct ifnet *ifp) > { > struct ifreq ifr; > + struct socket *so; > struct thread *td; > int error; >=20 > memset(&ifr, 0, sizeof(ifr)); > td =3D curthread; >=20 > + error =3D socreate(AF_INET, &so, SOCK_DGRAM, 0, td->td_ucred, = td); > + if (error) { > + printf("%s: socreate, error=3D%d\n", __func__, error); > + return (error); > + } > + > /* boot NIC */ > strlcpy(ifr.ifr_name, ifp->if_xname, sizeof(ifr.ifr_name)); >=20 > /* set IFF_UP */ > - error =3D ifioctl(NULL, SIOCGIFFLAGS, (caddr_t)&ifr, td); > + error =3D ifioctl(so, SIOCGIFFLAGS, (caddr_t)&ifr, td); > if (error) { > printf("ifioctl SIOCGIFFLAGS\n"); > return (error); > } > ifr.ifr_flags |=3D IFF_UP; > - error =3D ifioctl(NULL, SIOCSIFFLAGS, (caddr_t)&ifr, td); > + error =3D ifioctl(so, SIOCSIFFLAGS, (caddr_t)&ifr, td); > if (error) { > printf("ifioctl SIOCSIFFLAGS\n"); > return (error); > } >=20 > + soclose(so); > return (0); > } >=20 >=20 >> static int >> isboot_ifup(struct ifnet *ifp) >> { >> struct socket *so; >> struct ifreq ifr; >> struct thread *td; >> int error; >>=20 >> td =3D curthread; >> error =3D socreate(AF_INET, &so, SOCK_DGRAM, 0, td->td_ucred, td); >> if (error) { >> printf("%s: socreate, error=3D%d\n", __func__, error); >> return (error); >> } >>=20 >> /* boot NIC */ >> memset(&ifr, 0, sizeof(ifr)); >> strlcpy(ifr.ifr_name, ifp->if_xname, sizeof(ifr.ifr_name)); >>=20 >> /* set IFF_UP */ >> error =3D ifioctl(so, SIOCGIFFLAGS, (caddr_t)&ifr, td); >> if (error) { >> printf("%s: ifioctl SIOCGIFFLAGS, error=3D%d\n", __func__, = error); >> return (error); >> } >>=20 >> ifr.ifr_flags |=3D IFF_UP; >> error =3D ifioctl(so, SIOCSIFFLAGS, (caddr_t)&ifr, td); >> if (error) { >> printf("%s, ifioctl SIOCSIFFLAGS, error=3D%d\n", __func__, = error); >> return (error); >> } >> soclose(so); >> return (0); >> } >>=20 >> I have added a socket in the ifioctl() call as in the = /usr/src/sys/nfs/bootp_subr.c source. >> Please let me know if you prefer a patch. >> -- >> Regards, >> Maurizio