On Tue, Nov 22, 2016 at 11:39:32AM +0100, Martin Pieuchot wrote:
> On 21/11/16(Mon) 20:07, Alexander Bluhm wrote:
> > [...] 
> > NFS hits you again.  nfs_boot_init() calls ifioctl().  Perhaps put
> > the splsoftnet() inside ifioctl().
> 
> I'll put it inside nfs_boot() because the function also iterate on
> structures that need to be protected.  Note that this should not matter
> during boot, but we might have to play tricks if we put too many
> asserts.

OK bluhm@

> 
> Index: kern/sys_socket.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/sys_socket.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 sys_socket.c
> --- kern/sys_socket.c 21 Nov 2016 10:30:42 -0000      1.24
> +++ kern/sys_socket.c 22 Nov 2016 10:30:18 -0000
> @@ -119,8 +119,12 @@ soo_ioctl(struct file *fp, u_long cmd, c
>        * interface and routing ioctls should have a
>        * different entry since a socket's unnecessary
>        */
> -     if (IOCGROUP(cmd) == 'i')
> -             return (ifioctl(so, cmd, data, p));
> +     if (IOCGROUP(cmd) == 'i') {
> +             s = splsoftnet();
> +             error = ifioctl(so, cmd, data, p);
> +             splx(s);
> +             return (error);
> +     }
>       if (IOCGROUP(cmd) == 'r')
>               return (EOPNOTSUPP);
>       s = splsoftnet();
> Index: nfs/nfs_boot.c
> ===================================================================
> RCS file: /cvs/src/sys/nfs/nfs_boot.c,v
> retrieving revision 1.39
> diff -u -p -r1.39 nfs_boot.c
> --- nfs/nfs_boot.c    1 Sep 2015 21:24:04 -0000       1.39
> +++ nfs/nfs_boot.c    22 Nov 2016 10:36:36 -0000
> @@ -122,7 +122,7 @@ nfs_boot_init(struct nfs_diskless *nd, s
>       struct socket *so;
>       struct ifaddr *ifa;
>       char addr[INET_ADDRSTRLEN];
> -     int error;
> +     int s, error;
>  
>       /*
>        * Find an interface, rarp for its ip address, stuff it, the
> @@ -159,11 +159,15 @@ nfs_boot_init(struct nfs_diskless *nd, s
>        */
>       if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0)) != 0)
>               panic("nfs_boot: socreate, error=%d", error);
> +     s = splsoftnet();
>       error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)&ireq, procp);
> +     splx(s);
>       if (error)
>               panic("nfs_boot: GIFFLAGS, error=%d", error);
>       ireq.ifr_flags |= IFF_UP;
> +     s = splsoftnet();
>       error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)&ireq, procp);
> +     splx(s);
>       if (error)
>               panic("nfs_boot: SIFFLAGS, error=%d", error);
>  
> @@ -186,7 +190,9 @@ nfs_boot_init(struct nfs_diskless *nd, s
>       sin->sin_len = sizeof(*sin);
>       sin->sin_family = AF_INET;
>       sin->sin_addr.s_addr = my_ip.s_addr;
> +     s = splsoftnet();
>       error = ifioctl(so, SIOCAIFADDR, (caddr_t)&ifra, procp);
> +     splx(s);
>       if (error)
>               panic("nfs_boot: set if addr, error=%d", error);
>  

Reply via email to