[Midnightbsd-cvs] src [9925] trunk/sys: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri May 25 09:07:02 EDT 2018


Revision: 9925
          http://svnweb.midnightbsd.org/src/?rev=9925
Author:   laffer1
Date:     2018-05-25 09:07:02 -0400 (Fri, 25 May 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/sys/netipx/README
    trunk/sys/netipx/ipx.c
    trunk/sys/netipx/ipx.h
    trunk/sys/netipx/ipx_cksum.c
    trunk/sys/netipx/ipx_if.h
    trunk/sys/netipx/ipx_input.c
    trunk/sys/netipx/ipx_outputfl.c
    trunk/sys/netipx/ipx_pcb.c
    trunk/sys/netipx/ipx_pcb.h
    trunk/sys/netipx/ipx_proto.c
    trunk/sys/netipx/ipx_usrreq.c
    trunk/sys/netipx/ipx_var.h
    trunk/sys/netipx/spx.h
    trunk/sys/netipx/spx_debug.c
    trunk/sys/netipx/spx_debug.h
    trunk/sys/netipx/spx_reass.c
    trunk/sys/netipx/spx_timer.h
    trunk/sys/netipx/spx_usrreq.c
    trunk/sys/netipx/spx_var.h
    trunk/sys/netnatm/natm.c
    trunk/sys/netnatm/natm.h
    trunk/sys/netnatm/natm_pcb.c
    trunk/sys/netnatm/natm_proto.c
    trunk/sys/netsmb/netbios.h
    trunk/sys/netsmb/smb.h
    trunk/sys/netsmb/smb_conn.c
    trunk/sys/netsmb/smb_conn.h
    trunk/sys/netsmb/smb_crypt.c
    trunk/sys/netsmb/smb_dev.c
    trunk/sys/netsmb/smb_dev.h
    trunk/sys/netsmb/smb_iod.c
    trunk/sys/netsmb/smb_rq.c
    trunk/sys/netsmb/smb_rq.h
    trunk/sys/netsmb/smb_smb.c
    trunk/sys/netsmb/smb_subr.c
    trunk/sys/netsmb/smb_subr.h
    trunk/sys/netsmb/smb_tran.h
    trunk/sys/netsmb/smb_trantcp.c
    trunk/sys/netsmb/smb_trantcp.h
    trunk/sys/netsmb/smb_usr.c

Property Changed:
----------------
    trunk/sys/netipx/README

Modified: trunk/sys/netipx/README
===================================================================
--- trunk/sys/netipx/README	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/README	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,4 +1,5 @@
 $MidnightBSD$
+$FreeBSD: stable/10/sys/netipx/README 194590 2009-06-21 16:11:26Z rwatson $
 
 This protocol implements IPX/SPX over Ethernet_II frame type 0x8137.
 Please note: the SPX implementation may require further work and testing


Property changes on: trunk/sys/netipx/README
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/netipx/ipx.c
===================================================================
--- trunk/sys/netipx/ipx.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/ipx.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.
@@ -62,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netipx/ipx.c 229621 2012-01-05 19:00:36Z jhb $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>

Modified: trunk/sys/netipx/ipx.h
===================================================================
--- trunk/sys/netipx/ipx.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/ipx.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -58,7 +59,7 @@
  *
  *	@(#)ipx.h
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netipx/ipx.h 170664 2007-06-13 14:01:43Z rwatson $
  */
 
 #ifndef _NETIPX_IPX_H_

Modified: trunk/sys/netipx/ipx_cksum.c
===================================================================
--- trunk/sys/netipx/ipx_cksum.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/ipx_cksum.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1982, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -60,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netipx/ipx_cksum.c 169463 2007-05-11 10:38:34Z rwatson $");
 
 #include <sys/param.h>
 #include <sys/mbuf.h>

Modified: trunk/sys/netipx/ipx_if.h
===================================================================
--- trunk/sys/netipx/ipx_if.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/ipx_if.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -58,7 +59,7 @@
  *
  *	@(#)ipx_if.h
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netipx/ipx_if.h 194905 2009-06-24 20:57:50Z rwatson $
  */
 
 #ifndef _NETIPX_IPX_IF_H_

Modified: trunk/sys/netipx/ipx_input.c
===================================================================
--- trunk/sys/netipx/ipx_input.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/ipx_input.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.
@@ -63,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netipx/ipx_input.c 263478 2014-03-21 15:15:30Z glebius $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -454,7 +455,7 @@
 	if (ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL) {
 		return (0);
 	}
-	ro->ro_rt->rt_use++;
+	counter_u64_add(ro->ro_rt->rt_pksent, 1);
 	return (1);
 }
 

Modified: trunk/sys/netipx/ipx_outputfl.c
===================================================================
--- trunk/sys/netipx/ipx_outputfl.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/ipx_outputfl.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -60,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netipx/ipx_outputfl.c 263478 2014-03-21 15:15:30Z glebius $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -129,7 +130,7 @@
 		error = ENETUNREACH;
 		goto bad;
 	}
-	ro->ro_rt->rt_use++;
+	counter_u64_add(ro->ro_rt->rt_pksent, 1);
 	if (ro->ro_rt->rt_flags & (RTF_GATEWAY|RTF_HOST))
 		dst = (struct sockaddr_ipx *)ro->ro_rt->rt_gateway;
 gotif:
@@ -270,7 +271,7 @@
 			if(ipx->ipx_sum != 0xffff)
 				ipx->ipx_sum = ipx_cksum(m, ntohs(ipx->ipx_len));
 
-			m1 = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
+			m1 = m_copym(m, 0, M_COPYALL, M_NOWAIT);
 			if(m1) {
 				error = (*ifp->if_output)(ifp, m1,
 					(struct sockaddr *)&dst, NULL);

Modified: trunk/sys/netipx/ipx_pcb.c
===================================================================
--- trunk/sys/netipx/ipx_pcb.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/ipx_pcb.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.
@@ -63,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netipx/ipx_pcb.c 194905 2009-06-24 20:57:50Z rwatson $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/netipx/ipx_pcb.h
===================================================================
--- trunk/sys/netipx/ipx_pcb.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/ipx_pcb.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.
@@ -61,7 +62,7 @@
  *
  *	@(#)ipx_pcb.h
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netipx/ipx_pcb.h 169463 2007-05-11 10:38:34Z rwatson $
  */
 
 #ifndef _NETIPX_IPX_PCB_H_

Modified: trunk/sys/netipx/ipx_proto.c
===================================================================
--- trunk/sys/netipx/ipx_proto.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/ipx_proto.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -60,11 +61,12 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netipx/ipx_proto.c 273736 2014-10-27 14:38:00Z hselasky $");
 
 #include "opt_ipx.h"
 
 #include <sys/param.h>
+#include <sys/systm.h>
 #include <sys/socket.h>
 #include <sys/protosw.h>
 #include <sys/domain.h>

Modified: trunk/sys/netipx/ipx_usrreq.c
===================================================================
--- trunk/sys/netipx/ipx_usrreq.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/ipx_usrreq.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.
@@ -63,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netipx/ipx_usrreq.c 243882 2012-12-05 08:04:20Z glebius $");
 
 #include "opt_ipx.h"
 
@@ -257,7 +258,7 @@
 			(m->m_len + m->m_data < &m->m_dat[MLEN])) {
 			mtod(m, char*)[m->m_len++] = 0;
 		} else {
-			struct mbuf *m1 = m_get(M_DONTWAIT, MT_DATA);
+			struct mbuf *m1 = m_get(M_NOWAIT, MT_DATA);
 
 			if (m1 == NULL) {
 				m_freem(m0);
@@ -278,7 +279,7 @@
 	if (ipxp->ipxp_flags & IPXP_RAWOUT) {
 		ipx = mtod(m, struct ipx *);
 	} else {
-		M_PREPEND(m, sizeof(struct ipx), M_DONTWAIT);
+		M_PREPEND(m, sizeof(struct ipx), M_NOWAIT);
 		if (m == NULL)
 			return (ENOBUFS);
 		ipx = mtod(m, struct ipx *);

Modified: trunk/sys/netipx/ipx_var.h
===================================================================
--- trunk/sys/netipx/ipx_var.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/ipx_var.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -58,7 +59,7 @@
  *
  *	@(#)ipx_var.h
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netipx/ipx_var.h 194591 2009-06-21 16:11:40Z rwatson $
  */
 
 #ifndef _NETIPX_IPX_VAR_H_

Modified: trunk/sys/netipx/spx.h
===================================================================
--- trunk/sys/netipx/spx.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/spx.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -58,7 +59,7 @@
  *
  *	@(#)spx.h
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netipx/spx.h 194547 2009-06-20 18:24:25Z rwatson $
  */
 
 #ifndef _NETIPX_SPX_H_

Modified: trunk/sys/netipx/spx_debug.c
===================================================================
--- trunk/sys/netipx/spx_debug.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/spx_debug.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -60,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netipx/spx_debug.c 193892 2009-06-10 09:28:50Z bz $");
 
 #include "opt_inet.h"
 #include "opt_tcpdebug.h"

Modified: trunk/sys/netipx/spx_debug.h
===================================================================
--- trunk/sys/netipx/spx_debug.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/spx_debug.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -58,7 +59,7 @@
  *
  *	@(#)spx_debug.h
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netipx/spx_debug.h 171656 2007-07-30 11:06:42Z des $
  */
 
 #ifndef _NETIPX_SPX_DEBUG_H_

Modified: trunk/sys/netipx/spx_reass.c
===================================================================
--- trunk/sys/netipx/spx_reass.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/spx_reass.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.
@@ -63,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netipx/spx_reass.c 243882 2012-12-05 08:04:20Z glebius $");
 
 #include <sys/param.h>
 #include <sys/lock.h>
@@ -399,7 +400,7 @@
 				spx_newchecks[4]++;
 				if (dt != cb->s_rhdr.spx_dt) {
 					struct mbuf *mm =
-					   m_getclr(M_DONTWAIT, MT_CONTROL);
+					   m_getclr(M_NOWAIT, MT_CONTROL);
 					spx_newchecks[0]++;
 					if (mm != NULL) {
 						u_short *s =

Modified: trunk/sys/netipx/spx_timer.h
===================================================================
--- trunk/sys/netipx/spx_timer.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/spx_timer.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1982, 1986, 1988, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -58,7 +59,7 @@
  *
  *	@(#)spx_timer.h
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netipx/spx_timer.h 165899 2007-01-08 22:14:00Z rwatson $
  */
 
 #ifndef _NETIPX_SPX_TIMER_H_

Modified: trunk/sys/netipx/spx_usrreq.c
===================================================================
--- trunk/sys/netipx/spx_usrreq.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/spx_usrreq.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.
@@ -63,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netipx/spx_usrreq.c 243882 2012-12-05 08:04:20Z glebius $");
 
 #include <sys/param.h>
 #include <sys/lock.h>
@@ -473,7 +474,7 @@
 
 				cb->s_cc &= ~SPX_EM;
 				while (len > mtu) {
-					m = m_copym(m0, 0, mtu, M_DONTWAIT);
+					m = m_copym(m0, 0, mtu, M_NOWAIT);
 					if (m == NULL) {
 					    cb->s_cc |= oldEM;
 					    m_freem(m0);
@@ -509,7 +510,7 @@
 			if (M_TRAILINGSPACE(m) >= 1)
 				m->m_len++;
 			else {
-				struct mbuf *m1 = m_get(M_DONTWAIT, MT_DATA);
+				struct mbuf *m1 = m_get(M_NOWAIT, MT_DATA);
 
 				if (m1 == NULL) {
 					m_freem(m0);
@@ -520,7 +521,7 @@
 				m->m_next = m1;
 			}
 		}
-		m = m_gethdr(M_DONTWAIT, MT_DATA);
+		m = m_gethdr(M_NOWAIT, MT_DATA);
 		if (m == NULL) {
 			m_freem(m0);
 			return (ENOBUFS);
@@ -734,7 +735,7 @@
 			spxstat.spxs_sndprobe++;
 		if (cb->s_flags & SF_ACKNOW)
 			spxstat.spxs_sndacks++;
-		m = m_gethdr(M_DONTWAIT, MT_DATA);
+		m = m_gethdr(M_NOWAIT, MT_DATA);
 		if (m == NULL)
 			return (ENOBUFS);
 
@@ -1091,7 +1092,7 @@
 	cb = malloc(sizeof *cb, M_PCB, M_NOWAIT | M_ZERO);
 	if (cb == NULL)
 		return (ENOBUFS);
-	mm = m_getclr(M_DONTWAIT, MT_DATA);
+	mm = m_getclr(M_NOWAIT, MT_DATA);
 	if (mm == NULL) {
 		free(cb, M_PCB);
 		return (ENOBUFS);

Modified: trunk/sys/netipx/spx_var.h
===================================================================
--- trunk/sys/netipx/spx_var.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netipx/spx_var.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1984, 1985, 1986, 1987, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -58,7 +59,7 @@
  *
  *	@(#)spx_var.h
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netipx/spx_var.h 194547 2009-06-20 18:24:25Z rwatson $
  */
 
 #ifndef _NETIPX_SPX_VAR_H_

Modified: trunk/sys/netnatm/natm.c
===================================================================
--- trunk/sys/netnatm/natm.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netnatm/natm.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2006 Robert N. M. Watson
  * All rights reserved.
@@ -60,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/sys/netnatm/natm.c,v 1.5 2013/01/17 23:29:41 laffer1 Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/netnatm/natm.c 255442 2013-09-10 10:05:59Z des $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -292,7 +293,7 @@
 	/*
 	 * Send the data.  We must put an atm_pseudohdr on first.
 	 */
-	M_PREPEND(m, sizeof(*aph), M_DONTWAIT);
+	M_PREPEND(m, sizeof(*aph), M_NOWAIT);
 	if (m == NULL) {
 		NATM_UNLOCK();
 		m_freem(control);

Modified: trunk/sys/netnatm/natm.h
===================================================================
--- trunk/sys/netnatm/natm.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netnatm/natm.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1996 Charles D. Cranor and Washington University.
  * All rights reserved.
@@ -29,7 +30,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $NetBSD: natm.h,v 1.1 1996/07/04 03:20:12 chuck Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netnatm/natm.h 168776 2007-04-16 12:31:35Z pjd $
  */
 
 /*

Modified: trunk/sys/netnatm/natm_pcb.c
===================================================================
--- trunk/sys/netnatm/natm_pcb.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netnatm/natm_pcb.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1996 Charles D. Cranor and Washington University.
  * All rights reserved.
@@ -39,7 +40,7 @@
 #include "opt_ddb.h"
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netnatm/natm_pcb.c 184205 2008-10-23 15:53:51Z des $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>

Modified: trunk/sys/netnatm/natm_proto.c
===================================================================
--- trunk/sys/netnatm/natm_proto.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netnatm/natm_proto.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1996 Charles D. Cranor and Washington University.
  * All rights reserved.
@@ -36,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netnatm/natm_proto.c 193219 2009-06-01 10:41:38Z rwatson $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/netsmb/netbios.h
===================================================================
--- trunk/sys/netsmb/netbios.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/netbios.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netsmb/netbios.h 206361 2010-04-07 16:50:38Z joel $
  */
 #ifndef _NETSMB_NETBIOS_H_
 #define	_NETSMB_NETBIOS_H_

Modified: trunk/sys/netsmb/smb.h
===================================================================
--- trunk/sys/netsmb/smb.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netsmb/smb.h 206361 2010-04-07 16:50:38Z joel $
  */
 
 /*

Modified: trunk/sys/netsmb/smb_conn.c
===================================================================
--- trunk/sys/netsmb/smb_conn.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_conn.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -29,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/sys/netsmb/smb_conn.c,v 1.6 2013/01/17 23:29:41 laffer1 Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/netsmb/smb_conn.c 291655 2015-12-02 21:48:34Z rmacklem $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -59,8 +60,6 @@
 static void smb_co_init(struct smb_connobj *cp, int level, char *ilockname,
     char *lockname);
 static void smb_co_done(struct smb_connobj *cp);
-static int  smb_co_lockstatus(struct smb_connobj *cp);
-
 static int  smb_vc_disconnect(struct smb_vc *vcp);
 static void smb_vc_free(struct smb_connobj *cp);
 static void smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred);
@@ -77,7 +76,9 @@
 {
 
 	smb_co_init(&smb_vclist, SMBL_SM, "smbsm ilock", "smbsm");
-	smb_co_unlock(&smb_vclist, 0);
+	sx_xlock(&smb_vclist.co_interlock);
+	smb_co_unlock(&smb_vclist);
+	sx_unlock(&smb_vclist.co_interlock);
 	return 0;
 }
 
@@ -90,16 +91,20 @@
 		SMBERROR("%d connections still active\n", smb_vclist.co_usecount - 1);
 		return EBUSY;
 	}
-	lockmgr(&smb_vclist.co_lock, LK_DRAIN, NULL);
 	smb_co_done(&smb_vclist);
 	return 0;
 }
 
 static int
-smb_sm_lockvclist(int flags)
+smb_sm_lockvclist(void)
 {
+	int error;
 
-	return smb_co_lock(&smb_vclist, flags | LK_CANRECURSE);
+	sx_xlock(&smb_vclist.co_interlock);
+	error = smb_co_lock(&smb_vclist);
+	sx_unlock(&smb_vclist.co_interlock);
+
+	return error;
 }
 
 static void
@@ -106,7 +111,9 @@
 smb_sm_unlockvclist(void)
 {
 
-	smb_co_unlock(&smb_vclist, LK_RELEASE);
+	sx_xlock(&smb_vclist.co_interlock);
+	smb_co_unlock(&smb_vclist);
+	sx_unlock(&smb_vclist.co_interlock);
 }
 
 static int
@@ -123,7 +130,7 @@
 	vcp = NULL;
 	SMBCO_FOREACH(scp, &smb_vclist) {
 		vcp = (struct smb_vc *)scp;
-		error = smb_vc_lock(vcp, LK_EXCLUSIVE);
+		error = smb_vc_lock(vcp);
 		if (error)
 			continue;
 
@@ -160,7 +167,7 @@
 	err1:
 		error = 1;
 	fail:
-		smb_vc_unlock(vcp, 0);
+		smb_vc_unlock(vcp);
 	}
 	if (vcp) {
 		smb_vc_ref(vcp);
@@ -179,7 +186,7 @@
 
 	*vcpp = vcp = NULL;
 
-	error = smb_sm_lockvclist(LK_EXCLUSIVE);
+	error = smb_sm_lockvclist();
 	if (error)
 		return error;
 	error = smb_sm_lookupint(vcspec, shspec, scred, vcpp);
@@ -211,7 +218,7 @@
 	if (error == 0)
 		*vcpp = vcp;
 	else if (vcp) {
-		smb_vc_lock(vcp, LK_EXCLUSIVE);
+		smb_vc_lock(vcp);
 		smb_vc_put(vcp, scred);
 	}
 	return error;
@@ -224,20 +231,26 @@
 smb_co_init(struct smb_connobj *cp, int level, char *ilockname, char *lockname)
 {
 	SLIST_INIT(&cp->co_children);
-	smb_sl_init(&cp->co_interlock, ilockname);
-	lockinit(&cp->co_lock, PZERO, lockname, 0, 0);
+	sx_init_flags(&cp->co_interlock, ilockname, SX_RECURSE);
+	cv_init(&cp->co_lock, "smblock");
+	cp->co_lockcnt = 0;
+	cp->co_locker = NULL;
 	cp->co_level = level;
 	cp->co_usecount = 1;
-	if (smb_co_lock(cp, LK_EXCLUSIVE) != 0)
-	    panic("smb_co_init: lock failed");
+	sx_xlock(&cp->co_interlock);
+	smb_co_lock(cp);
+	sx_unlock(&cp->co_interlock);
 }
 
 static void
 smb_co_done(struct smb_connobj *cp)
 {
-	smb_sl_destroy(&cp->co_interlock);
-	lockmgr(&cp->co_lock, LK_RELEASE, NULL);
-	lockdestroy(&cp->co_lock);
+
+	sx_destroy(&cp->co_interlock);
+	cv_destroy(&cp->co_lock);
+	cp->co_locker = NULL;
+	cp->co_flags = 0;
+	cp->co_lockcnt = 0;
 }
 
 static void
@@ -249,7 +262,9 @@
 		cp->co_gone(cp, scred);
 	parent = cp->co_parent;
 	if (parent) {
-		smb_co_lock(parent, LK_EXCLUSIVE);
+		sx_xlock(&parent->co_interlock);
+		smb_co_lock(parent);
+		sx_unlock(&parent->co_interlock);
 		SLIST_REMOVE(&parent->co_children, cp, smb_connobj, co_next);
 		smb_co_put(parent, scred);
 	}
@@ -261,9 +276,9 @@
 smb_co_ref(struct smb_connobj *cp)
 {
 
-	SMB_CO_LOCK(cp);
+	sx_xlock(&cp->co_interlock);
 	cp->co_usecount++;
-	SMB_CO_UNLOCK(cp);
+	sx_unlock(&cp->co_interlock);
 }
 
 void
@@ -270,40 +285,35 @@
 smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred)
 {
 
-	SMB_CO_LOCK(cp);
+	sx_xlock(&cp->co_interlock);
+	smb_co_unlock(cp);
 	if (cp->co_usecount > 1) {
 		cp->co_usecount--;
-		SMB_CO_UNLOCK(cp);
+		sx_unlock(&cp->co_interlock);
 		return;
 	}
 	if (cp->co_usecount == 0) {
 		SMBERROR("negative use_count for object %d", cp->co_level);
-		SMB_CO_UNLOCK(cp);
+		sx_unlock(&cp->co_interlock);
 		return;
 	}
 	cp->co_usecount--;
 	cp->co_flags |= SMBO_GONE;
-
-	lockmgr(&cp->co_lock, LK_DRAIN | LK_INTERLOCK, &cp->co_interlock);
+	sx_unlock(&cp->co_interlock);
 	smb_co_gone(cp, scred);
 }
 
 int
-smb_co_get(struct smb_connobj *cp, int flags, struct smb_cred *scred)
+smb_co_get(struct smb_connobj *cp, struct smb_cred *scred)
 {
 	int error;
 
-	if ((flags & LK_INTERLOCK) == 0)
-		SMB_CO_LOCK(cp);
+	MPASS(sx_xholder(&cp->co_interlock) == curthread);
 	cp->co_usecount++;
-	error = smb_co_lock(cp, flags | LK_INTERLOCK);
-	if (error) {
-		SMB_CO_LOCK(cp);
+	error = smb_co_lock(cp);
+	if (error) 
 		cp->co_usecount--;
-		SMB_CO_UNLOCK(cp);
-		return error;
-	}
-	return 0;
+	return error;
 }
 
 void
@@ -310,7 +320,7 @@
 smb_co_put(struct smb_connobj *cp, struct smb_cred *scred)
 {
 
-	SMB_CO_LOCK(cp);
+	sx_xlock(&cp->co_interlock);
 	if (cp->co_usecount > 1) {
 		cp->co_usecount--;
 	} else if (cp->co_usecount == 1) {
@@ -319,39 +329,45 @@
 	} else {
 		SMBERROR("negative usecount");
 	}
-	lockmgr(&cp->co_lock, LK_RELEASE | LK_INTERLOCK, &cp->co_interlock);
+	smb_co_unlock(cp);
+	sx_unlock(&cp->co_interlock);
 	if ((cp->co_flags & SMBO_GONE) == 0)
 		return;
-	lockmgr(&cp->co_lock, LK_DRAIN, NULL);
 	smb_co_gone(cp, scred);
 }
 
 int
-smb_co_lockstatus(struct smb_connobj *cp)
+smb_co_lock(struct smb_connobj *cp)
 {
-	return lockstatus(&cp->co_lock);
-}
 
-int
-smb_co_lock(struct smb_connobj *cp, int flags)
-{
-
-	if (cp->co_flags & SMBO_GONE)
-		return EINVAL;
-	if ((flags & LK_TYPE_MASK) == 0)
-		flags |= LK_EXCLUSIVE;
-	if (smb_co_lockstatus(cp) == LK_EXCLUSIVE && 
-	    (flags & LK_CANRECURSE) == 0) {
-		SMBERROR("recursive lock for object %d\n", cp->co_level);
-		return 0;
+	MPASS(sx_xholder(&cp->co_interlock) == curthread); 
+	for (;;) {
+		if (cp->co_flags & SMBO_GONE)
+			return EINVAL;
+		if (cp->co_locker == NULL) {
+			cp->co_locker = curthread;
+			return 0;
+		}
+		if (cp->co_locker == curthread) {
+			cp->co_lockcnt++;
+			return 0;
+		}
+		cv_wait(&cp->co_lock, &cp->co_interlock);
 	}
-	return lockmgr(&cp->co_lock, flags, &cp->co_interlock);
 }
 
 void
-smb_co_unlock(struct smb_connobj *cp, int flags)
+smb_co_unlock(struct smb_connobj *cp)
 {
-	(void)lockmgr(&cp->co_lock, flags | LK_RELEASE, &cp->co_interlock);
+
+	MPASS(sx_xholder(&cp->co_interlock) == curthread); 
+	MPASS(cp->co_locker == curthread);
+	if (cp->co_lockcnt != 0) {
+		cp->co_lockcnt--;
+		return;
+	}
+	cp->co_locker = NULL;
+	cv_signal(&cp->co_lock);
 }
 
 static void
@@ -358,11 +374,6 @@
 smb_co_addchild(struct smb_connobj *parent, struct smb_connobj *child)
 {
 
-	KASSERT(smb_co_lockstatus(parent) == LK_EXCLUSIVE,
-	    ("smb_co_addchild: parent not locked"));
-	KASSERT(smb_co_lockstatus(child) == LK_EXCLUSIVE,
-	    ("smb_co_addchild: child not locked"));
-
 	smb_co_ref(parent);
 	SLIST_INSERT_HEAD(&parent->co_children, child, co_next);
 	child->co_parent = parent;
@@ -520,7 +531,6 @@
 
 /*
  * Called when use count of VC dropped to zero.
- * VC should be locked on enter with LK_DRAIN.
  */
 static void
 smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred)
@@ -543,9 +553,16 @@
 }
 
 int
-smb_vc_get(struct smb_vc *vcp, int flags, struct smb_cred *scred)
+smb_vc_get(struct smb_vc *vcp, struct smb_cred *scred)
 {
-	return smb_co_get(VCTOCP(vcp), flags, scred);
+	struct smb_connobj *cp;
+	int error;
+
+	cp = VCTOCP(vcp);
+	sx_xlock(&cp->co_interlock);
+	error = smb_co_get(cp, scred);
+	sx_unlock(&cp->co_interlock);
+	return error;
 }
 
 void
@@ -555,15 +572,28 @@
 }
 
 int
-smb_vc_lock(struct smb_vc *vcp, int flags)
+smb_vc_lock(struct smb_vc *vcp)
 {
-	return smb_co_lock(VCTOCP(vcp), flags);
+	struct smb_connobj *cp;
+	int error;
+
+	cp = VCTOCP(vcp);
+	sx_xlock(&cp->co_interlock);
+	error = smb_co_lock(cp);
+	sx_unlock(&cp->co_interlock);
+	return error;
 }
 
 void
-smb_vc_unlock(struct smb_vc *vcp, int flags)
+smb_vc_unlock(struct smb_vc *vcp)
 {
-	smb_co_unlock(VCTOCP(vcp), flags);
+
+	struct smb_connobj *cp;
+
+	cp = VCTOCP(vcp);
+	sx_xlock(&cp->co_interlock);
+	smb_co_unlock(cp);
+	sx_unlock(&cp->co_interlock);
 }
 
 int
@@ -623,12 +653,12 @@
 	dp->scred = scred;
 	SMBCO_FOREACH(scp, VCTOCP(vcp)) {
 		ssp = (struct smb_share *)scp;
-		error = smb_share_lock(ssp, LK_EXCLUSIVE);
+		error = smb_share_lock(ssp);
 		if (error)
 			continue;
 		if (smb_vc_cmpshare(ssp, dp) == 0)
 			break;
-		smb_share_unlock(ssp, 0);
+		smb_share_unlock(ssp);
 	}
 	if (ssp) {
 		smb_share_ref(ssp);
@@ -654,7 +684,9 @@
 smb_vc_disconnect(struct smb_vc *vcp)
 {
 
-	smb_iod_request(vcp->vc_iod, SMBIOD_EV_DISCONNECT | SMBIOD_EV_SYNC, NULL);
+	if (vcp->vc_iod != NULL)
+		smb_iod_request(vcp->vc_iod, SMBIOD_EV_DISCONNECT |
+		    SMBIOD_EV_SYNC, NULL);
 	return 0;
 }
 
@@ -690,10 +722,10 @@
 smb_vc_nextmid(struct smb_vc *vcp)
 {
 	u_short r;
-
-	SMB_CO_LOCK(&vcp->obj);
+	
+	sx_xlock(&vcp->obj.co_interlock);
 	r = vcp->vc_mid++;
-	SMB_CO_UNLOCK(&vcp->obj);
+	sx_unlock(&vcp->obj.co_interlock);
 	return r;
 }
 
@@ -784,27 +816,46 @@
 }
 
 int
-smb_share_get(struct smb_share *ssp, int flags, struct smb_cred *scred)
+smb_share_get(struct smb_share *ssp, struct smb_cred *scred)
 {
-	return smb_co_get(SSTOCP(ssp), flags, scred);
+	struct smb_connobj *cp = SSTOCP(ssp);
+	int error;
+
+	sx_xlock(&cp->co_interlock);
+	error = smb_co_get(cp, scred);
+	sx_unlock(&cp->co_interlock);
+	return error;
 }
 
 void
 smb_share_put(struct smb_share *ssp, struct smb_cred *scred)
 {
+	
 	smb_co_put(SSTOCP(ssp), scred);
 }
 
 int
-smb_share_lock(struct smb_share *ssp, int flags)
+smb_share_lock(struct smb_share *ssp)
 {
-	return smb_co_lock(SSTOCP(ssp), flags);
+	struct smb_connobj *cp;
+	int error;
+	
+	cp = SSTOCP(ssp);
+	sx_xlock(&cp->co_interlock);
+	error = smb_co_lock(cp);
+	sx_unlock(&cp->co_interlock);
+	return error;
 }
 
 void
-smb_share_unlock(struct smb_share *ssp, int flags)
+smb_share_unlock(struct smb_share *ssp)
 {
-	smb_co_unlock(SSTOCP(ssp), flags);
+	struct smb_connobj *cp;
+	
+	cp = SSTOCP(ssp);
+	sx_xlock(&cp->co_interlock);
+	smb_co_unlock(cp);
+	sx_unlock(&cp->co_interlock);
 }
 
 int
@@ -868,8 +919,6 @@
 static int
 smb_sysctl_treedump(SYSCTL_HANDLER_ARGS)
 {
-	struct thread *td = req->td;
-	struct smb_cred scred;
 	struct smb_connobj *scp1, *scp2;
 	struct smb_vc *vcp;
 	struct smb_share *ssp;
@@ -877,38 +926,37 @@
 	struct smb_share_info ssi;
 	int error, itype;
 
-	smb_makescred(&scred, td, td->td_ucred);
 	error = sysctl_wire_old_buffer(req, 0);
 	if (error)
 		return (error);
-	error = smb_sm_lockvclist(LK_SHARED);
+	error = smb_sm_lockvclist();
 	if (error)
 		return error;
 	SMBCO_FOREACH(scp1, &smb_vclist) {
 		vcp = (struct smb_vc *)scp1;
-		error = smb_vc_lock(vcp, LK_SHARED);
+		error = smb_vc_lock(vcp);
 		if (error)
 			continue;
 		smb_vc_getinfo(vcp, &vci);
 		error = SYSCTL_OUT(req, &vci, sizeof(struct smb_vc_info));
 		if (error) {
-			smb_vc_unlock(vcp, 0);
+			smb_vc_unlock(vcp);
 			break;
 		}
 		SMBCO_FOREACH(scp2, VCTOCP(vcp)) {
 			ssp = (struct smb_share *)scp2;
-			error = smb_share_lock(ssp, LK_SHARED);
+			error = smb_share_lock(ssp);
 			if (error) {
 				error = 0;
 				continue;
 			}
 			smb_share_getinfo(ssp, &ssi);
-			smb_share_unlock(ssp, 0);
+			smb_share_unlock(ssp);
 			error = SYSCTL_OUT(req, &ssi, sizeof(struct smb_share_info));
 			if (error)
 				break;
 		}
-		smb_vc_unlock(vcp, 0);
+		smb_vc_unlock(vcp);
 		if (error)
 			break;
 	}

Modified: trunk/sys/netsmb/smb_conn.h
===================================================================
--- trunk/sys/netsmb/smb_conn.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_conn.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netsmb/smb_conn.h 250237 2013-05-04 14:18:10Z davide $
  */
 
 /*
@@ -158,9 +159,11 @@
 
 #ifdef _KERNEL
 
+#include <netsmb/smb_subr.h>
+#include <sys/param.h>
 #include <sys/lock.h>
-#include <sys/lockmgr.h>
-#include <netsmb/smb_subr.h>
+#include <sys/condvar.h>
+#include <sys/sx.h>
 
 #define CONNADDREQ(a1,a2)	((a1)->sa_len == (a2)->sa_len && \
 				 bcmp(a1, a2, (a1)->sa_len) == 0)
@@ -190,14 +193,13 @@
 typedef void smb_co_gone_t (struct smb_connobj *cp, struct smb_cred *scred);
 typedef void smb_co_free_t (struct smb_connobj *cp);
 
-#define	SMB_CO_LOCK(cp)		smb_sl_lock(&(cp)->co_interlock)
-#define	SMB_CO_UNLOCK(cp)	smb_sl_unlock(&(cp)->co_interlock)
-
 struct smb_connobj {
+	struct cv		co_lock;
+	struct thread		*co_locker;
+	struct sx		co_interlock;
+	int			co_lockcnt;
 	int			co_level;	/* SMBL_ */
 	int			co_flags;
-	struct lock		co_lock;
-	struct smb_slock	co_interlock;
 	int			co_usecount;
 	struct smb_connobj *	co_parent;
 	SLIST_HEAD(,smb_connobj)co_children;
@@ -225,7 +227,6 @@
 #define	SMBC_ST_LOCK(vcp)	smb_sl_lock(&(vcp)->vc_stlock)
 #define	SMBC_ST_UNLOCK(vcp)	smb_sl_unlock(&(vcp)->vc_stlock)
 
-
 struct smb_vc {
 	struct smb_connobj obj;
 	char *		vc_srvname;
@@ -361,10 +362,10 @@
  */
 void smb_co_ref(struct smb_connobj *cp);
 void smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred);
-int  smb_co_get(struct smb_connobj *cp, int flags, struct smb_cred *scred);
+int  smb_co_get(struct smb_connobj *cp, struct smb_cred *scred);
 void smb_co_put(struct smb_connobj *cp, struct smb_cred *scred);
-int  smb_co_lock(struct smb_connobj *cp, int flags);
-void smb_co_unlock(struct smb_connobj *cp, int flags);
+int  smb_co_lock(struct smb_connobj *cp);
+void smb_co_unlock(struct smb_connobj *cp);
 
 /*
  * session level functions
@@ -373,12 +374,12 @@
 	struct smb_cred *scred, struct smb_vc **vcpp);
 int  smb_vc_connect(struct smb_vc *vcp, struct smb_cred *scred);
 int  smb_vc_access(struct smb_vc *vcp, struct smb_cred *scred, mode_t mode);
-int  smb_vc_get(struct smb_vc *vcp, int flags, struct smb_cred *scred);
+int  smb_vc_get(struct smb_vc *vcp, struct smb_cred *scred);
 void smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred);
 void smb_vc_ref(struct smb_vc *vcp);
 void smb_vc_rele(struct smb_vc *vcp, struct smb_cred *scred);
-int  smb_vc_lock(struct smb_vc *vcp, int flags);
-void smb_vc_unlock(struct smb_vc *vcp, int flags);
+int  smb_vc_lock(struct smb_vc *vcp);
+void smb_vc_unlock(struct smb_vc *vcp);
 int  smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *shspec,
 	struct smb_cred *scred, struct smb_share **sspp);
 const char * smb_vc_getpass(struct smb_vc *vcp);
@@ -392,10 +393,10 @@
 int  smb_share_access(struct smb_share *ssp, struct smb_cred *scred, mode_t mode);
 void smb_share_ref(struct smb_share *ssp);
 void smb_share_rele(struct smb_share *ssp, struct smb_cred *scred);
-int  smb_share_get(struct smb_share *ssp, int flags, struct smb_cred *scred);
+int  smb_share_get(struct smb_share *ssp, struct smb_cred *scred);
 void smb_share_put(struct smb_share *ssp, struct smb_cred *scred);
-int  smb_share_lock(struct smb_share *ssp, int flags);
-void smb_share_unlock(struct smb_share *ssp, int flags);
+int  smb_share_lock(struct smb_share *ssp);
+void smb_share_unlock(struct smb_share *ssp);
 void smb_share_invalidate(struct smb_share *ssp);
 int  smb_share_valid(struct smb_share *ssp);
 const char * smb_share_getpass(struct smb_share *ssp);

Modified: trunk/sys/netsmb/smb_crypt.c
===================================================================
--- trunk/sys/netsmb/smb_crypt.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_crypt.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001, Boris Popov
  * All rights reserved.
@@ -34,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netsmb/smb_crypt.c 161523 2006-08-22 03:05:51Z marcel $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>

Modified: trunk/sys/netsmb/smb_dev.c
===================================================================
--- trunk/sys/netsmb/smb_dev.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_dev.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -25,10 +26,11 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netsmb/smb_dev.c 280258 2015-03-19 13:37:36Z rwatson $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
+#include <sys/capsicum.h>
 #include <sys/module.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
@@ -55,14 +57,9 @@
 #include <netsmb/smb_subr.h>
 #include <netsmb/smb_dev.h>
 
-#define SMB_GETDEV(dev)		((struct smb_dev*)(dev)->si_drv1)
-#define	SMB_CHECKMINOR(dev)	do { \
-				    sdp = SMB_GETDEV(dev); \
-				    if (sdp == NULL) return ENXIO; \
-				} while(0)
+static struct cdev *nsmb_dev;
 
 static d_open_t	 nsmb_dev_open;
-static d_close_t nsmb_dev_close;
 static d_ioctl_t nsmb_dev_ioctl;
 
 MODULE_DEPEND(netsmb, libiconv, 1, 1, 2);
@@ -69,6 +66,7 @@
 MODULE_VERSION(netsmb, NSMB_VERSION);
 
 static int smb_version = NSMB_VERSION;
+struct sx smb_lock;
 
 
 SYSCTL_DECL(_net_smb);
@@ -76,45 +74,55 @@
 
 static MALLOC_DEFINE(M_NSMBDEV, "NETSMBDEV", "NET/SMB device");
 
-
-/*
-int smb_dev_queue(struct smb_dev *ndp, struct smb_rq *rqp, int prio);
-*/
-
 static struct cdevsw nsmb_cdevsw = {
 	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT | D_NEEDMINOR,
 	.d_open =	nsmb_dev_open,
-	.d_close =	nsmb_dev_close,
 	.d_ioctl =	nsmb_dev_ioctl,
 	.d_name =	NSMB_NAME
 };
 
-static eventhandler_tag	 nsmb_dev_tag;
-static struct clonedevs	*nsmb_clones;
+static int
+nsmb_dev_init(void)
+{
 
-static void
-nsmb_dev_clone(void *arg, struct ucred *cred, char *name, int namelen,
-    struct cdev **dev)
+	nsmb_dev = make_dev(&nsmb_cdevsw, 0, UID_ROOT, GID_OPERATOR,
+	    0600, "nsmb");
+	if (nsmb_dev == NULL)
+		return (ENOMEM);  
+	return (0);
+}
+
+static void 
+nsmb_dev_destroy(void)
 {
-	int i, u;
 
-	if (*dev != NULL)
-		return;
+	MPASS(nsmb_dev != NULL);
+	destroy_dev(nsmb_dev);
+	nsmb_dev = NULL;
+}
 
-	if (strcmp(name, NSMB_NAME) == 0)
-		u = -1;
-	else if (dev_stdclone(name, NULL, NSMB_NAME, &u) != 1)
-		return;
-	i = clone_create(&nsmb_clones, &nsmb_cdevsw, &u, dev, 0);
-	if (i) {
-		*dev = make_dev(&nsmb_cdevsw, u, UID_ROOT, GID_WHEEL, 0600,
-		    "%s%d", NSMB_NAME, u);
-		if (*dev != NULL) {
-			dev_ref(*dev);
-			(*dev)->si_flags |= SI_CHEAPCLONE;
-		}
-	}
+static struct smb_dev *
+smbdev_alloc(struct cdev *dev)
+{
+	struct smb_dev *sdp;
+
+	sdp = malloc(sizeof(struct smb_dev), M_NSMBDEV, M_WAITOK | M_ZERO);
+	sdp->dev = dev;	
+	sdp->sd_level = -1;
+	sdp->sd_flags |= NSMBFL_OPEN;
+	sdp->refcount = 1;
+	return (sdp);	
+} 
+
+void
+sdp_dtor(void *arg)
+{
+	struct smb_dev *dev;
+
+	dev = (struct smb_dev *)arg;	
+	SMB_LOCK();
+	sdp_trydestroy(dev);
+	SMB_UNLOCK();
 }
 
 static int
@@ -121,67 +129,46 @@
 nsmb_dev_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
 {
 	struct smb_dev *sdp;
-	struct ucred *cred = td->td_ucred;
-	int s;
+	int error;
 
-	sdp = SMB_GETDEV(dev);
-	if (sdp && (sdp->sd_flags & NSMBFL_OPEN))
-		return EBUSY;
-	if (sdp == NULL) {
-		sdp = malloc(sizeof(*sdp), M_NSMBDEV, M_WAITOK);
-		dev->si_drv1 = (void*)sdp;
+	sdp = smbdev_alloc(dev);
+	error = devfs_set_cdevpriv(sdp, sdp_dtor);
+	if (error) {
+		free(sdp, M_NSMBDEV);	
+		return (error);
 	}
-	/*
-	 * XXX: this is just crazy - make a device for an already passed device...
-	 * someone should take care of it.
-	 */
-	if ((dev->si_flags & SI_NAMED) == 0)
-		make_dev(&nsmb_cdevsw, dev2unit(dev), cred->cr_uid,
-		    cred->cr_gid, 0700, NSMB_NAME"%d", dev2unit(dev));
-	bzero(sdp, sizeof(*sdp));
-/*
-	STAILQ_INIT(&sdp->sd_rqlist);
-	STAILQ_INIT(&sdp->sd_rplist);
-	bzero(&sdp->sd_pollinfo, sizeof(struct selinfo));
-*/
-	s = splimp();
-	sdp->sd_level = -1;
-	sdp->sd_flags |= NSMBFL_OPEN;
-	splx(s);
-	return 0;
+	return (0);
 }
 
-static int
-nsmb_dev_close(struct cdev *dev, int flag, int fmt, struct thread *td)
+void
+sdp_trydestroy(struct smb_dev *sdp)
 {
-	struct smb_dev *sdp;
 	struct smb_vc *vcp;
 	struct smb_share *ssp;
-	struct smb_cred scred;
-	int s;
+	struct smb_cred *scred;
 
-	SMB_CHECKMINOR(dev);
-	s = splimp();
-	if ((sdp->sd_flags & NSMBFL_OPEN) == 0) {
-		splx(s);
-		return EBADF;
+	SMB_LOCKASSERT();
+	if (!sdp)
+		panic("No smb_dev upon device close");
+	MPASS(sdp->refcount > 0);
+	sdp->refcount--;
+	if (sdp->refcount) 
+		return;
+	scred = malloc(sizeof(struct smb_cred), M_NSMBDEV, M_WAITOK);
+	smb_makescred(scred, curthread, NULL);
+	ssp = sdp->sd_share;
+	if (ssp != NULL) {
+		smb_share_lock(ssp);
+		smb_share_rele(ssp, scred);
 	}
-	smb_makescred(&scred, td, NULL);
-	ssp = sdp->sd_share;
-	if (ssp != NULL)
-		smb_share_rele(ssp, &scred);
 	vcp = sdp->sd_vc;
-	if (vcp != NULL)
-		smb_vc_rele(vcp, &scred);
-/*
-	smb_flushq(&sdp->sd_rqlist);
-	smb_flushq(&sdp->sd_rplist);
-*/
-	dev->si_drv1 = NULL;
+	if (vcp != NULL) {
+		smb_vc_lock(vcp);
+		smb_vc_rele(vcp, scred);
+	}
+	free(scred, M_NSMBDEV);
 	free(sdp, M_NSMBDEV);
-	destroy_dev_sched(dev);
-	splx(s);
-	return 0;
+	return;
 }
 
 
@@ -191,50 +178,61 @@
 	struct smb_dev *sdp;
 	struct smb_vc *vcp;
 	struct smb_share *ssp;
-	struct smb_cred scred;
+	struct smb_cred *scred;
 	int error = 0;
 
-	SMB_CHECKMINOR(dev);
-	if ((sdp->sd_flags & NSMBFL_OPEN) == 0)
-		return EBADF;
-
-	smb_makescred(&scred, td, NULL);
+	error = devfs_get_cdevpriv((void **)&sdp);
+	if (error)
+		return (error);
+	scred = malloc(sizeof(struct smb_cred), M_NSMBDEV, M_WAITOK);
+	SMB_LOCK();
+	smb_makescred(scred, td, NULL);
 	switch (cmd) {
 	    case SMBIOC_OPENSESSION:
-		if (sdp->sd_vc)
-			return EISCONN;
+		if (sdp->sd_vc) {
+			error = EISCONN;
+			goto out;
+		}
 		error = smb_usr_opensession((struct smbioc_ossn*)data,
-		    &scred, &vcp);
+		    scred, &vcp);
 		if (error)
 			break;
 		sdp->sd_vc = vcp;
-		smb_vc_unlock(vcp, 0);
+		smb_vc_unlock(vcp);
 		sdp->sd_level = SMBL_VC;
 		break;
 	    case SMBIOC_OPENSHARE:
-		if (sdp->sd_share)
-			return EISCONN;
-		if (sdp->sd_vc == NULL)
-			return ENOTCONN;
+		if (sdp->sd_share) {
+			error = EISCONN;
+			goto out;
+		}
+		if (sdp->sd_vc == NULL) {
+			error = ENOTCONN;
+			goto out;
+		}
 		error = smb_usr_openshare(sdp->sd_vc,
-		    (struct smbioc_oshare*)data, &scred, &ssp);
+		    (struct smbioc_oshare*)data, scred, &ssp);
 		if (error)
 			break;
 		sdp->sd_share = ssp;
-		smb_share_unlock(ssp, 0);
+		smb_share_unlock(ssp);
 		sdp->sd_level = SMBL_SHARE;
 		break;
 	    case SMBIOC_REQUEST:
-		if (sdp->sd_share == NULL)
-			return ENOTCONN;
+		if (sdp->sd_share == NULL) {
+			error = ENOTCONN;
+			goto out;
+		}
 		error = smb_usr_simplerequest(sdp->sd_share,
-		    (struct smbioc_rq*)data, &scred);
+		    (struct smbioc_rq*)data, scred);
 		break;
 	    case SMBIOC_T2RQ:
-		if (sdp->sd_share == NULL)
-			return ENOTCONN;
+		if (sdp->sd_share == NULL) {
+			error = ENOTCONN;
+			goto out;
+		}
 		error = smb_usr_t2request(sdp->sd_share,
-		    (struct smbioc_t2rq*)data, &scred);
+		    (struct smbioc_t2rq*)data, scred);
 		break;
 	    case SMBIOC_SETFLAGS: {
 		struct smbioc_flags *fl = (struct smbioc_flags*)data;
@@ -243,9 +241,11 @@
 		if (fl->ioc_level == SMBL_VC) {
 			if (fl->ioc_mask & SMBV_PERMANENT) {
 				on = fl->ioc_flags & SMBV_PERMANENT;
-				if ((vcp = sdp->sd_vc) == NULL)
-					return ENOTCONN;
-				error = smb_vc_get(vcp, LK_EXCLUSIVE, &scred);
+				if ((vcp = sdp->sd_vc) == NULL) {
+					error = ENOTCONN;
+					goto out;
+				}
+				error = smb_vc_get(vcp, scred);
 				if (error)
 					break;
 				if (on && (vcp->obj.co_flags & SMBV_PERMANENT) == 0) {
@@ -253,17 +253,19 @@
 					smb_vc_ref(vcp);
 				} else if (!on && (vcp->obj.co_flags & SMBV_PERMANENT)) {
 					vcp->obj.co_flags &= ~SMBV_PERMANENT;
-					smb_vc_rele(vcp, &scred);
+					smb_vc_rele(vcp, scred);
 				}
-				smb_vc_put(vcp, &scred);
+				smb_vc_put(vcp, scred);
 			} else
 				error = EINVAL;
 		} else if (fl->ioc_level == SMBL_SHARE) {
 			if (fl->ioc_mask & SMBS_PERMANENT) {
 				on = fl->ioc_flags & SMBS_PERMANENT;
-				if ((ssp = sdp->sd_share) == NULL)
-					return ENOTCONN;
-				error = smb_share_get(ssp, LK_EXCLUSIVE, &scred);
+				if ((ssp = sdp->sd_share) == NULL) {
+					error = ENOTCONN;
+					goto out;
+				}
+				error = smb_share_get(ssp, scred);
 				if (error)
 					break;
 				if (on && (ssp->obj.co_flags & SMBS_PERMANENT) == 0) {
@@ -271,9 +273,9 @@
 					smb_share_ref(ssp);
 				} else if (!on && (ssp->obj.co_flags & SMBS_PERMANENT)) {
 					ssp->obj.co_flags &= ~SMBS_PERMANENT;
-					smb_share_rele(ssp, &scred);
+					smb_share_rele(ssp, scred);
 				}
-				smb_share_put(ssp, &scred);
+				smb_share_put(ssp, scred);
 			} else
 				error = EINVAL;
 			break;
@@ -282,21 +284,23 @@
 		break;
 	    }
 	    case SMBIOC_LOOKUP:
-		if (sdp->sd_vc || sdp->sd_share)
-			return EISCONN;
+		if (sdp->sd_vc || sdp->sd_share) {
+			error = EISCONN;
+			goto out;
+		}
 		vcp = NULL;
 		ssp = NULL;
-		error = smb_usr_lookup((struct smbioc_lookup*)data, &scred, &vcp, &ssp);
+		error = smb_usr_lookup((struct smbioc_lookup*)data, scred, &vcp, &ssp);
 		if (error)
 			break;
 		if (vcp) {
 			sdp->sd_vc = vcp;
-			smb_vc_unlock(vcp, 0);
+			smb_vc_unlock(vcp);
 			sdp->sd_level = SMBL_VC;
 		}
 		if (ssp) {
 			sdp->sd_share = ssp;
-			smb_share_unlock(ssp, 0);
+			smb_share_unlock(ssp);
 			sdp->sd_level = SMBL_SHARE;
 		}
 		break;
@@ -305,8 +309,10 @@
 		struct uio auio;
 		struct iovec iov;
 	
-		if ((ssp = sdp->sd_share) == NULL)
-			return ENOTCONN;
+		if ((ssp = sdp->sd_share) == NULL) {
+			error = ENOTCONN;
+			goto out;
+	 	}
 		iov.iov_base = rwrq->ioc_base;
 		iov.iov_len = rwrq->ioc_cnt;
 		auio.uio_iov = &iov;
@@ -317,9 +323,9 @@
 		auio.uio_rw = (cmd == SMBIOC_READ) ? UIO_READ : UIO_WRITE;
 		auio.uio_td = td;
 		if (cmd == SMBIOC_READ)
-			error = smb_read(ssp, rwrq->ioc_fh, &auio, &scred);
+			error = smb_read(ssp, rwrq->ioc_fh, &auio, scred);
 		else
-			error = smb_write(ssp, rwrq->ioc_fh, &auio, &scred);
+			error = smb_write(ssp, rwrq->ioc_fh, &auio, scred);
 		rwrq->ioc_cnt -= auio.uio_resid;
 		break;
 	    }
@@ -326,6 +332,9 @@
 	    default:
 		error = ENODEV;
 	}
+out:
+	free(scred, M_NSMBDEV);
+	SMB_UNLOCK();
 	return error;
 }
 
@@ -344,8 +353,10 @@
 			smb_sm_done();
 			break;
 		}
-		clone_setup(&nsmb_clones);
-		nsmb_dev_tag = EVENTHANDLER_REGISTER(dev_clone, nsmb_dev_clone, 0, 1000);
+		error = nsmb_dev_init();
+		if (error)
+			break;
+		sx_init(&smb_lock, "samba device lock");
 		break;
 	    case MOD_UNLOAD:
 		smb_iod_done();
@@ -352,10 +363,8 @@
 		error = smb_sm_done();
 		if (error)
 			break;
-		EVENTHANDLER_DEREGISTER(dev_clone, nsmb_dev_tag);
-		drain_dev_clone_events();
-		clone_cleanup(&nsmb_clones);
-		destroy_dev_drain(&nsmb_cdevsw);
+		nsmb_dev_destroy();
+		sx_destroy(&smb_lock);
 		break;
 	    default:
 		error = EINVAL;
@@ -366,60 +375,41 @@
 
 DEV_MODULE (dev_netsmb, nsmb_dev_load, 0);
 
-/*
- * Convert a file descriptor to appropriate smb_share pointer
- */
-static struct file*
-nsmb_getfp(struct filedesc* fdp, int fd, int flag)
-{
-	struct file* fp;
-
-	FILEDESC_SLOCK(fdp);
-	if (((u_int)fd) >= fdp->fd_nfiles ||
-	    (fp = fdp->fd_ofiles[fd]) == NULL ||
-	    (fp->f_flag & flag) == 0) {
-		FILEDESC_SUNLOCK(fdp);
-		return (NULL);
-	}
-	fhold(fp);
-	FILEDESC_SUNLOCK(fdp);
-	return (fp);
-}
-
 int
 smb_dev2share(int fd, int mode, struct smb_cred *scred,
-	struct smb_share **sspp)
+	struct smb_share **sspp, struct smb_dev **ssdp)
 {
-	struct file *fp;
-	struct vnode *vp;
+	cap_rights_t rights;
+	struct file *fp, *fptmp;
 	struct smb_dev *sdp;
 	struct smb_share *ssp;
-	struct cdev *dev;
+	struct thread *td;
 	int error;
 
-	fp = nsmb_getfp(scred->scr_td->td_proc->p_fd, fd, FREAD | FWRITE);
-	if (fp == NULL)
-		return EBADF;
-	vp = fp->f_vnode;
-	if (vp == NULL) {
-		fdrop(fp, curthread);
-		return EBADF;
-	}
-	if (vp->v_type != VCHR) {
-		fdrop(fp, curthread);
-		return EBADF;
-	}
-	dev = vp->v_rdev;
-	SMB_CHECKMINOR(dev);
+	td = curthread;
+	error = fget(td, fd, cap_rights_init(&rights, CAP_READ), &fp);
+	if (error)
+		return (error);
+	fptmp = td->td_fpop;
+	td->td_fpop = fp;
+	error = devfs_get_cdevpriv((void **)&sdp);
+	td->td_fpop = fptmp;
+	fdrop(fp, td);
+	if (error || sdp == NULL)
+		return (error);
+	SMB_LOCK();
+	*ssdp = sdp;
 	ssp = sdp->sd_share;
 	if (ssp == NULL) {
-		fdrop(fp, curthread);
-		return ENOTCONN;
+		SMB_UNLOCK();
+		return (ENOTCONN);
 	}
-	error = smb_share_get(ssp, LK_EXCLUSIVE, scred);
-	if (error == 0) 
+	error = smb_share_get(ssp, scred);
+	if (error == 0) {
+		sdp->refcount++;
 		*sspp = ssp;
-	fdrop(fp, curthread);
+	}
+	SMB_UNLOCK();
 	return error;
 }
 

Modified: trunk/sys/netsmb/smb_dev.h
===================================================================
--- trunk/sys/netsmb/smb_dev.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_dev.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netsmb/smb_dev.h 250236 2013-05-04 14:03:18Z davide $
  */
 #ifndef _NETSMB_DEV_H_
 #define _NETSMB_DEV_H_
@@ -155,6 +156,7 @@
 STAILQ_HEAD(smbrqh, smb_rq);
 
 struct smb_dev {
+	struct cdev *	dev;
 	int		sd_opened;
 	int		sd_level;
 	struct smb_vc * sd_vc;		/* reference to VC */
@@ -161,16 +163,21 @@
 	struct smb_share *sd_share;	/* reference to share if any */
 	int		sd_poll;
 	int		sd_seq;
-/*	struct ifqueue	sd_rdqueue;
-	struct ifqueue	sd_wrqueue;
-	struct selinfo	sd_pollinfo;
-	struct smbrqh	sd_rqlist;
-	struct smbrqh	sd_rplist;
-	struct ucred 	*sd_owner;*/
 	int		sd_flags;
+	int		refcount;
+	int		usecount;
 };
 
+extern struct sx smb_lock;
+#define	SMB_LOCK()		sx_xlock(&smb_lock)
+#define	SMB_UNLOCK() 		sx_unlock(&smb_lock)
+#define	SMB_LOCKASSERT()	sx_assert(&smb_lock, SA_XLOCKED)
+
 struct smb_cred;
+
+void sdp_dtor(void *arg);
+void sdp_trydestroy(struct smb_dev *dev);
+
 /*
  * Compound user interface
  */
@@ -185,7 +192,7 @@
 int  smb_usr_t2request(struct smb_share *ssp, struct smbioc_t2rq *data,
 	struct smb_cred *scred);
 int  smb_dev2share(int fd, int mode, struct smb_cred *scred,
-	struct smb_share **sspp);
+	struct smb_share **sspp, struct smb_dev **ssdp);
 
 
 #endif /* _KERNEL */

Modified: trunk/sys/netsmb/smb_iod.c
===================================================================
--- trunk/sys/netsmb/smb_iod.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_iod.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netsmb/smb_iod.c 291655 2015-12-02 21:48:34Z rmacklem $");
  
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -87,8 +88,6 @@
 	 */
 	SMB_IOD_RQLOCK(iod);
 	TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) {
-		if (rqp->sr_flags & SMBR_INTERNAL)
-			SMBRQ_SUNLOCK(rqp);
 		rqp->sr_flags |= SMBR_RESTART;
 		smb_iod_rqprocessed(rqp, ENOTCONN);
 	}
@@ -255,7 +254,7 @@
 	}
 	SMBSDEBUG("M:%04x, P:%04x, U:%04x, T:%04x\n", rqp->sr_mid, 0, 0, 0);
 	m_dumpm(rqp->sr_rq.mb_top);
-	m = m_copym(rqp->sr_rq.mb_top, 0, M_COPYALL, M_WAIT);
+	m = m_copym(rqp->sr_rq.mb_top, 0, M_COPYALL, M_WAITOK);
 	error = rqp->sr_lerror = SMB_TRAN_SEND(vcp, m, td);
 	if (error == 0) {
 		getnanotime(&rqp->sr_timesent);
@@ -661,6 +660,11 @@
 			break;
 		tsleep(&iod->iod_flags, PWAIT, "90idle", iod->iod_sleeptimo);
 	}
+
+	/* We can now safely destroy the mutexes and free the iod structure. */
+	smb_sl_destroy(&iod->iod_rqlock);
+	smb_sl_destroy(&iod->iod_evlock);
+	free(iod, M_SMBIOD);
 	mtx_unlock(&Giant);
 	kproc_exit(0);
 }
@@ -687,6 +691,9 @@
 	    RFNOWAIT, 0, "smbiod%d", iod->iod_id);
 	if (error) {
 		SMBERROR("can't start smbiod: %d", error);
+		vcp->vc_iod = NULL;
+		smb_sl_destroy(&iod->iod_rqlock);
+		smb_sl_destroy(&iod->iod_evlock);
 		free(iod, M_SMBIOD);
 		return error;
 	}
@@ -697,9 +704,6 @@
 smb_iod_destroy(struct smbiod *iod)
 {
 	smb_iod_request(iod, SMBIOD_EV_SHUTDOWN | SMBIOD_EV_SYNC, NULL);
-	smb_sl_destroy(&iod->iod_rqlock);
-	smb_sl_destroy(&iod->iod_evlock);
-	free(iod, M_SMBIOD);
 	return 0;
 }
 

Modified: trunk/sys/netsmb/smb_rq.c
===================================================================
--- trunk/sys/netsmb/smb_rq.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_rq.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/sys/netsmb/smb_rq.c,v 1.6 2013/01/17 23:29:41 laffer1 Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/netsmb/smb_rq.c 243882 2012-12-05 08:04:20Z glebius $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -427,7 +428,7 @@
 	struct mbuf *m, *m0;
 	int len;
 
-	m0 = m_split(mtop, offset, M_WAIT);
+	m0 = m_split(mtop, offset, M_WAITOK);
 	len = m_length(m0, &m);
 	m->m_len -= len - count;
 	if (mdp->md_top == NULL) {

Modified: trunk/sys/netsmb/smb_rq.h
===================================================================
--- trunk/sys/netsmb/smb_rq.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_rq.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netsmb/smb_rq.h 206361 2010-04-07 16:50:38Z joel $
  */
 #ifndef _NETSMB_SMB_RQ_H_
 #define	_NETSMB_SMB_RQ_H_

Modified: trunk/sys/netsmb/smb_smb.c
===================================================================
--- trunk/sys/netsmb/smb_smb.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_smb.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -29,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netsmb/smb_smb.c 227650 2011-11-18 03:05:20Z kevlo $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/netsmb/smb_subr.c
===================================================================
--- trunk/sys/netsmb/smb_subr.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_subr.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/sys/netsmb/smb_subr.c,v 1.6 2013/01/17 23:29:41 laffer1 Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/netsmb/smb_subr.c 227650 2011-11-18 03:05:20Z kevlo $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/netsmb/smb_subr.h
===================================================================
--- trunk/sys/netsmb/smb_subr.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_subr.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netsmb/smb_subr.h 217174 2011-01-08 23:06:54Z csjp $
  */
 #ifndef _NETSMB_SMB_SUBR_H_
 #define _NETSMB_SMB_SUBR_H_

Modified: trunk/sys/netsmb/smb_tran.h
===================================================================
--- trunk/sys/netsmb/smb_tran.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_tran.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netsmb/smb_tran.h 206361 2010-04-07 16:50:38Z joel $
  */
 
 #ifndef _NETSMB_SMB_TRAN_H_

Modified: trunk/sys/netsmb/smb_trantcp.c
===================================================================
--- trunk/sys/netsmb/smb_trantcp.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_trantcp.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netsmb/smb_trantcp.c 258123 2013-11-14 09:19:50Z glebius $");
 
 #include <sys/param.h>
 #include <sys/condvar.h>
@@ -46,6 +47,7 @@
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/tcp.h>
@@ -79,6 +81,7 @@
 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;
@@ -85,7 +88,10 @@
 	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
@@ -150,8 +156,8 @@
 	SOCKBUF_LOCK(&so->so_rcv);
 	soupcall_set(so, SO_RCV, nb_upcall, nbp);
 	SOCKBUF_UNLOCK(&so->so_rcv);
-	so->so_rcv.sb_timeo = (5 * hz);
-	so->so_snd.sb_timeo = (5 * hz);
+	so->so_rcv.sb_timeo = (5 * SBT_1S);
+	so->so_snd.sb_timeo = (5 * SBT_1S);
 	error = soreserve(so, nbp->nbp_sndbuf, nbp->nbp_rcvbuf);
 	if (error)
 		goto bad;
@@ -192,8 +198,8 @@
 static int
 nbssn_rq_request(struct nbpcb *nbp, struct thread *td)
 {
-	struct mbchain mb, *mbp = &mb;
-	struct mdchain md, *mdp = &md;
+	struct mbchain *mbp;
+	struct mdchain *mdp;
 	struct mbuf *m0;
 	struct timeval tv;
 	struct sockaddr_in sin;
@@ -201,9 +207,14 @@
 	u_int8_t rpcode;
 	int error, rplen;
 
+	mbp = malloc(sizeof(struct mbchain), M_NBDATA, M_WAITOK);
+	mdp = malloc(sizeof(struct mbchain), M_NBDATA, M_WAITOK);
 	error = mb_init(mbp);
-	if (error)
+	if (error) {
+		free(mbp, M_NBDATA);
+		free(mdp, M_NBDATA);
 		return error;
+	}
 	mb_put_uint32le(mbp, 0);
 	nb_put_name(mbp, nbp->nbp_paddr);
 	nb_put_name(mbp, nbp->nbp_laddr);
@@ -214,19 +225,26 @@
 	}
 	mb_detach(mbp);
 	mb_done(mbp);
-	if (error)
+	free(mbp, M_NBDATA);
+	if (error) {
+		free(mdp, M_NBDATA);
 		return error;
+	}
 	TIMESPEC_TO_TIMEVAL(&tv, &nbp->nbp_timo);
 	error = selsocket(nbp->nbp_tso, POLLIN, &tv, td);
 	if (error == EWOULDBLOCK) {	/* Timeout */
 		NBDEBUG("initial request timeout\n");
+		free(mdp, M_NBDATA);
 		return ETIMEDOUT;
 	}
-	if (error)			/* restart or interrupt */
+	if (error) {			/* restart or interrupt */
+		free(mdp, M_NBDATA);
 		return error;
+	}
 	error = nbssn_recv(nbp, &m0, &rplen, &rpcode, td);
 	if (error) {
 		NBDEBUG("recv() error %d\n", error);
+		free(mdp, M_NBDATA);
 		return error;
 	}
 	/*
@@ -264,6 +282,7 @@
 	} while(0);
 	if (m0)
 		md_done(mdp);
+	free(mdp, M_NBDATA);
 	return error;
 }
 
@@ -286,8 +305,10 @@
 	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) {
@@ -371,8 +392,10 @@
 			 */
 			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)
@@ -523,8 +546,10 @@
 		return error;
 	getnanotime(&ts2);
 	timespecsub(&ts2, &ts1);
-	if (ts2.tv_sec == 0 && ts2.tv_sec == 0)
+	if (ts2.tv_sec == 0) {
 		ts2.tv_sec = 1;
+		ts2.tv_nsec = 0;
+	}
 	nbp->nbp_timo = ts2;
 	timespecadd(&nbp->nbp_timo, &ts2);
 	timespecadd(&nbp->nbp_timo, &ts2);
@@ -565,7 +590,7 @@
 		error = ENOTCONN;
 		goto abort;
 	}
-	M_PREPEND(m0, 4, M_WAIT);
+	M_PREPEND(m0, 4, M_WAITOK);
 	nb_sethdr(m0, NB_SSN_MESSAGE, m_fixhdr(m0) - 4);
 	error = nb_sosend(nbp->nbp_tso, m0, 0, td);
 	return error;

Modified: trunk/sys/netsmb/smb_trantcp.h
===================================================================
--- trunk/sys/netsmb/smb_trantcp.h	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_trantcp.h	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/netsmb/smb_trantcp.h 206361 2010-04-07 16:50:38Z joel $
  */
 #ifndef _NETSMB_SMB_TRANTCP_H_
 #define	_NETSMB_SMB_TRANTCP_H_

Modified: trunk/sys/netsmb/smb_usr.c
===================================================================
--- trunk/sys/netsmb/smb_usr.c	2018-05-25 13:05:17 UTC (rev 9924)
+++ trunk/sys/netsmb/smb_usr.c	2018-05-25 13:07:02 UTC (rev 9925)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2001 Boris Popov
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/netsmb/smb_usr.c 242386 2012-10-31 03:34:07Z davide $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -127,8 +128,8 @@
 	struct smb_vc **vcpp, struct smb_share **sspp)
 {
 	struct smb_vc *vcp = NULL;
-	struct smb_vcspec vspec;
-	struct smb_sharespec sspec, *sspecp = NULL;
+	struct smb_vcspec vspec;			/* XXX */
+	struct smb_sharespec sspec, *sspecp = NULL;	/* XXX */
 	int error;
 
 	if (dp->ioc_level < SMBL_VC || dp->ioc_level > SMBL_SHARE)
@@ -212,7 +213,7 @@
 smb_usr_simplerequest(struct smb_share *ssp, struct smbioc_rq *dp,
 	struct smb_cred *scred)
 {
-	struct smb_rq rq, *rqp = &rq;
+	struct smb_rq *rqp;
 	struct mbchain *mbp;
 	struct mdchain *mdp;
 	u_int8_t wc;
@@ -231,9 +232,12 @@
 	    case SMB_COM_TREE_CONNECT_ANDX:
 		return EPERM;
 	}
+	rqp = malloc(sizeof(struct smb_rq), M_SMBTEMP, M_WAITOK);
 	error = smb_rq_init(rqp, SSTOCP(ssp), dp->ioc_cmd, scred);
-	if (error)
+	if (error) {
+		free(rqp, M_SMBTEMP);
 		return error;
+	}
 	mbp = &rqp->sr_rq;
 	smb_rq_wstart(rqp);
 	error = mb_put_mem(mbp, dp->ioc_twords, dp->ioc_twc * 2, MB_MUSER);
@@ -271,6 +275,7 @@
 	dp->ioc_serror = rqp->sr_serror;
 	dp->ioc_error = rqp->sr_error;
 	smb_rq_done(rqp);
+	free(rqp, M_SMBTEMP);
 	return error;
 
 }
@@ -292,15 +297,18 @@
 smb_usr_t2request(struct smb_share *ssp, struct smbioc_t2rq *dp,
 	struct smb_cred *scred)
 {
-	struct smb_t2rq t2, *t2p = &t2;
+	struct smb_t2rq *t2p;
 	struct mdchain *mdp;
 	int error, len;
 
 	if (dp->ioc_setupcnt > 3)
 		return EINVAL;
+	t2p = malloc(sizeof(struct smb_t2rq), M_SMBTEMP, M_WAITOK);
 	error = smb_t2_init(t2p, SSTOCP(ssp), dp->ioc_setup[0], scred);
-	if (error)
+	if (error) {
+		free(t2p, M_SMBTEMP);
 		return error;
+	}
 	len = t2p->t2_setupcount = dp->ioc_setupcnt;
 	if (len > 1)
 		t2p->t2_setupdata = dp->ioc_setup; 
@@ -351,5 +359,6 @@
 	if (t2p->t_name)
 		smb_strfree(t2p->t_name);
 	smb_t2_done(t2p);
+	free(t2p, M_SMBTEMP);
 	return error;
 }



More information about the Midnightbsd-cvs mailing list