Re: Fatal trap 12 booting FreeBSD-CURRENT via isboot kernel module.

From: John Nielsen <lists_at_jnielsen.net>
Date: Tue, 6 Feb 2018 15:02:10 -0700
> On Feb 6, 2018, at 11:50 AM, Ian Lepore <ian_at_FreeBSD.org> wrote:
> 
> On Tue, 2018-02-06 at 11:33 -0700, John Nielsen wrote:
>> 
>> Apparently sending a NULL socket pointer to ifioctl hasn't worked
>> since this commit in 2011:
>> https://svnweb.freebsd.org/base?view=revision&revision=218757
>> 
>> 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 = 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.
>> 
> 
> Try adding #include <sys/proc.h> if it's not already in the list.  It
> may be that that file got included via pollution from some other header
> file in the past and maybe now that has changed.
> 
> If you're already including sys/proc.h then I'm clueless.

Thanks Ian, that appears to work.

Maurizio, can you apply the attached patch to a clean ports tree and see if isboot-kmod will build and function properly for you? This is all the changes from this thread and the previous one. If you let me know it works I'll get the port updated.


diff -uPr isboot-kmod.orig/Makefile isboot-kmod/Makefile
--- isboot-kmod.orig/Makefile   2018-01-11 07:18:01.000000000 -0700
+++ isboot-kmod/Makefile        2018-02-06 14:56:23.654737000 -0700
_at__at_ -2,7 +2,7 _at__at_
 
 PORTNAME=      isboot-kmod
 PORTVERSION=   0.2.13
-PORTREVISION=  1
+PORTREVISION=  2
 CATEGORIES=    net
 MASTER_SITES=  http://www.peach.ne.jp/archives/isboot/
 DISTNAME=      isboot-${PORTVERSION}
_at__at_ -12,9 +12,7 _at__at_
 
 LICENSE=       BSD2CLAUSE
 
-BROKEN_aarch64=                fails to compile: /usr/src/sys/sys/bus.h:724:10: fatal error: 'device_if.h' file not found
 BROKEN_armv6=          fails to compile: implicit declaration of function 'cp15_pmccntr_get' is invalid in C99
-BROKEN_armv7=          fails to compile: /usr/src/sys/sys/bus.h:724:10: fatal error: 'device_if.h' file not found
 BROKEN_powerpc64=      fails to compile: pcpu.h: size of array '__assert_0' is negative
 
 USES=          kmod uidfix
diff -uPr isboot-kmod.orig/files/patch-Makefile isboot-kmod/files/patch-Makefile
--- isboot-kmod.orig/files/patch-Makefile       1969-12-31 17:00:00.000000000 -0700
+++ isboot-kmod/files/patch-Makefile    2018-01-29 10:24:27.372206000 -0700
_at__at_ -0,0 +1,10 _at__at_
+--- Makefile.orig      2015-09-23 22:33:04.000000000 -0600
++++ Makefile   2018-01-29 10:20:10.453188000 -0700
+_at__at_ -6,6 +6,7 _at__at_
+ SRCS= isboot.c ibft.c iscsi.c
+ SRCS+=        isboot.h ibft.h iscsi_compat.h
+ SRCS+=        opt_cam.h
++SRCS+=        device_if.h bus_if.h
+ #CFLAGS+= -DVIMAGE
+ #CFLAGS+= -DIBFT_VERBOSE
+ #CFLAGS+= -DDEBUG
diff -uPr isboot-kmod.orig/files/patch-isboot.c isboot-kmod/files/patch-isboot.c
--- isboot-kmod.orig/files/patch-isboot.c       2016-05-06 08:34:57.000000000 -0600
+++ isboot-kmod/files/patch-isboot.c    2018-02-06 14:24:47.447244000 -0700
_at__at_ -1,6 +1,14 _at__at_
---- isboot.c.orig      2015-11-05 16:50:51 UTC
-+++ isboot.c
-_at__at_ -347,9 +347,9 _at__at_ isboot_set_v4gw(struct sockaddr_in *gate
+--- isboot.c.orig      2015-11-05 09:50:51.000000000 -0700
++++ isboot.c   2018-02-06 14:23:24.479249000 -0700
+_at__at_ -38,6 +38,7 _at__at_
+ #include <sys/socketvar.h>
+ #include <sys/sockio.h>
+ #include <sys/sysctl.h>
++#include <sys/proc.h>
+ #include <net/if.h>
+ #include <net/if_dl.h>
+ #include <net/if_types.h>
+_at__at_ -347,9 +348,9 _at__at_
        netmask.sin_addr.s_addr = htonl(0);
  
        /* delete gateway if exists */
_at__at_ -12,7 +20,7 _at__at_
        if (error) {
                if (error != ESRCH) {
                        printf("rtrequest RTM_DELETE error %d\n",
-_at__at_ -359,9 +359,9 _at__at_ isboot_set_v4gw(struct sockaddr_in *gate
+_at__at_ -359,9 +360,9 _at__at_
        }
  
        /* set new default gateway */
_at__at_ -24,7 +32,7 _at__at_
        if (error) {
                printf("rtrequest RTM_ADD error %d\n", error);
                return (error);
-_at__at_ -391,9 +391,9 _at__at_ isboot_set_v6gw(struct sockaddr_in6 *gat
+_at__at_ -391,9 +392,9 _at__at_
        memset(&netmask.sin6_addr, 0, 16);
  
        /* delete gateway if exists */
_at__at_ -36,7 +44,7 _at__at_
        if (error) {
                if (error != ESRCH) {
                        printf("rtrequest RTM_DELETE error %d\n",
-_at__at_ -403,9 +403,9 _at__at_ isboot_set_v6gw(struct sockaddr_in6 *gat
+_at__at_ -403,9 +404,9 _at__at_
        }
  
        /* set new default gateway */
_at__at_ -48,3 +56,42 _at__at_
        if (error) {
                printf("rtrequest RTM_ADD error %d\n", error);
                return (error);
+_at__at_ -417,28 +418,36 _at__at_
+ isboot_ifup(struct ifnet *ifp)
+ {
+       struct ifreq ifr;
++      struct socket *so;
+       struct thread *td;
+       int error;
+ 
+       memset(&ifr, 0, sizeof(ifr));
+       td = curthread;
+ 
++      error = socreate(AF_INET, &so, SOCK_DGRAM, 0, td->td_ucred, td);
++      if (error) {
++              printf("%s: socreate, error=%d\n", __func__, error);
++              return (error);
++      }
++
+       /* boot NIC */
+       strlcpy(ifr.ifr_name, ifp->if_xname, sizeof(ifr.ifr_name));
+ 
+       /* set IFF_UP */
+-      error = ifioctl(NULL, SIOCGIFFLAGS, (caddr_t)&ifr, td);
++      error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)&ifr, td);
+       if (error) {
+               printf("ifioctl SIOCGIFFLAGS\n");
+               return (error);
+       }
+       ifr.ifr_flags |= IFF_UP;
+-      error = ifioctl(NULL, SIOCSIFFLAGS, (caddr_t)&ifr, td);
++      error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)&ifr, td);
+       if (error) {
+               printf("ifioctl SIOCSIFFLAGS\n");
+               return (error);
+       }
+ 
++      soclose(so);
+       return (0);
+ }
+ 
diff -uPr isboot-kmod.orig/files/patch-iscsi.c isboot-kmod/files/patch-iscsi.c
--- isboot-kmod.orig/files/patch-iscsi.c        1969-12-31 17:00:00.000000000 -0700
+++ isboot-kmod/files/patch-iscsi.c     2018-01-29 10:24:54.854580000 -0700
_at__at_ -0,0 +1,27 _at__at_
+--- iscsi.c.orig       2015-11-05 09:50:51.000000000 -0700
++++ iscsi.c    2018-01-29 10:20:00.586277000 -0700
+_at__at_ -1070,9 +1070,11 _at__at_
+       return (n);
+ }
+ 
+-
+-#if __FreeBSD_version >= 1100000
++#if __FreeBSD_version >= 1200051
+ static void
++isboot_free_mbufext(struct mbuf *m)
++#elif __FreeBSD_version >= 1100000
++static void
+ isboot_free_mbufext(struct mbuf *m, void *p, void *optarg)
+ #elif __FreeBSD_version >= 1000050 && __FreeBSD_version < 1100000
+ static int
+_at__at_ -1082,7 +1084,9 _at__at_
+ isboot_free_mbufext(void *p, void *optarg)
+ #endif
+ {
+-
++#if __FreeBSD_version >= 1200051
++      void *p = m->m_ext.ext_arg1;
++#endif
+       ISBOOT_TRACE("isboot_free_mbufext\n");
+       if (p == NULL)
+ #if __FreeBSD_version >= 1000050 && __FreeBSD_version < 1100000

Received on Tue Feb 06 2018 - 21:02:26 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:14 UTC