Author: davide
Date: Sat May  4 16:55:48 2013
New Revision: 250243
URL: http://svnweb.freebsd.org/changeset/base/250243

Log:
  If the kernel is compiled with VMIMAGE support, the first attempt of
  mounting smbfs share will cause a panic. Fix setting setting/restoring
  vnet context when needed.
  
  PR:           kern/168077
  Submitted by: dteske

Modified:
  head/sys/netsmb/smb_trantcp.c

Modified: head/sys/netsmb/smb_trantcp.c
==============================================================================
--- head/sys/netsmb/smb_trantcp.c       Sat May  4 16:41:14 2013        
(r250242)
+++ head/sys/netsmb/smb_trantcp.c       Sat May  4 16:55:48 2013        
(r250243)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/tcp.h>
@@ -79,13 +80,17 @@ static int
 nb_setsockopt_int(struct socket *so, int level, int name, int val)
 {
        struct sockopt sopt;
+       int error;
 
        bzero(&sopt, sizeof(sopt));
        sopt.sopt_level = level;
        sopt.sopt_name = name;
        sopt.sopt_val = &val;
        sopt.sopt_valsize = sizeof(val);
-       return sosetopt(so, &sopt);
+       CURVNET_SET(so->so_vnet);
+       error = sosetopt(so, &sopt);
+       CURVNET_RESTORE();
+       return error;
 }
 
 static int
@@ -299,8 +304,10 @@ nbssn_recvhdr(struct nbpcb *nbp, int *le
        auio.uio_offset = 0;
        auio.uio_resid = sizeof(len);
        auio.uio_td = td;
+       CURVNET_SET(so->so_vnet);
        error = soreceive(so, (struct sockaddr **)NULL, &auio,
            (struct mbuf **)NULL, (struct mbuf **)NULL, &flags);
+       CURVNET_RESTORE();
        if (error)
                return error;
        if (auio.uio_resid > 0) {
@@ -384,8 +391,10 @@ nbssn_recv(struct nbpcb *nbp, struct mbu
                         */
                        do {
                                rcvflg = MSG_WAITALL;
+                               CURVNET_SET(so->so_vnet);
                                error = soreceive(so, (struct sockaddr **)NULL,
                                    &auio, &tm, (struct mbuf **)NULL, &rcvflg);
+                               CURVNET_RESTORE();
                        } while (error == EWOULDBLOCK || error == EINTR ||
                                 error == ERESTART);
                        if (error)
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to