Module Name: src
Committed By: tls
Date: Sun Aug 10 06:56:43 UTC 2014
Modified Files:
src/sys/netsmb [tls-earlyentropy]: smb_dev.c smb_trantcp.c
smb_trantcp.h
Log Message:
Rebase.
To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.2.1 src/sys/netsmb/smb_dev.c
cvs rdiff -u -r1.44 -r1.44.26.1 src/sys/netsmb/smb_trantcp.c
cvs rdiff -u -r1.6 -r1.6.56.1 src/sys/netsmb/smb_trantcp.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/netsmb/smb_dev.c
diff -u src/sys/netsmb/smb_dev.c:1.41 src/sys/netsmb/smb_dev.c:1.41.2.1
--- src/sys/netsmb/smb_dev.c:1.41 Sun Mar 16 05:20:30 2014
+++ src/sys/netsmb/smb_dev.c Sun Aug 10 06:56:43 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: smb_dev.c,v 1.41 2014/03/16 05:20:30 dholland Exp $ */
+/* $NetBSD: smb_dev.c,v 1.41.2.1 2014/08/10 06:56:43 tls Exp $ */
/*
* Copyright (c) 2000-2001 Boris Popov
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smb_dev.c,v 1.41 2014/03/16 05:20:30 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smb_dev.c,v 1.41.2.1 2014/08/10 06:56:43 tls Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -95,6 +95,7 @@ const struct cdevsw nsmb_cdevsw = {
.d_poll = nopoll,
.d_mmap = nommap,
.d_kqfilter = nokqfilter,
+ .d_discard = nodiscard,
.d_flag = D_OTHER,
};
Index: src/sys/netsmb/smb_trantcp.c
diff -u src/sys/netsmb/smb_trantcp.c:1.44 src/sys/netsmb/smb_trantcp.c:1.44.26.1
--- src/sys/netsmb/smb_trantcp.c:1.44 Wed Aug 31 18:31:04 2011
+++ src/sys/netsmb/smb_trantcp.c Sun Aug 10 06:56:43 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: smb_trantcp.c,v 1.44 2011/08/31 18:31:04 plunky Exp $ */
+/* $NetBSD: smb_trantcp.c,v 1.44.26.1 2014/08/10 06:56:43 tls Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,12 +61,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smb_trantcp.c,v 1.44 2011/08/31 18:31:04 plunky Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smb_trantcp.c,v 1.44.26.1 2014/08/10 06:56:43 tls Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/mbuf.h>
#include <sys/proc.h>
#include <sys/protosw.h>
@@ -92,17 +92,14 @@ __KERNEL_RCSID(0, "$NetBSD: smb_trantcp.
#include <netsmb/smb_trantcp.h>
#include <netsmb/smb_subr.h>
-#define M_NBDATA M_PCB
-
static int nb_tcpsndbuf = NB_SNDQ;
static int nb_tcprcvbuf = NB_RCVQ;
-static const struct timespec nb_timo = { 15, 0 }; /* XXX sysctl? */
#define nb_sosend(so,m,flags,l) (*(so)->so_send)(so, NULL, (struct uio *)0, \
m, (struct mbuf *)0, flags, l)
static int nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp,
- u_int8_t *rpcodep, struct lwp *l);
+ u_int8_t *rpcodep, bool firstwait, struct lwp *l);
static int smb_nbst_disconnect(struct smb_vc *vcp, struct lwp *l);
static int
@@ -113,14 +110,6 @@ nb_setsockopt_int(struct socket *so, int
}
static int
-nbssn_rselect(struct nbpcb *nbp, const struct timespec *ts, int events,
- struct lwp *l)
-{
-
- return pollsock(nbp->nbp_tso, ts, events);
-}
-
-static int
nb_intr(struct nbpcb *nbp, struct lwp *l)
{
return 0;
@@ -184,8 +173,8 @@ nb_connect_in(struct nbpcb *nbp, struct
so->so_rcv.sb_flags |= SB_UPCALL;
so->so_rcv.sb_flags &= ~SB_NOINTR;
so->so_snd.sb_flags &= ~SB_NOINTR;
- so->so_rcv.sb_timeo = NB_SNDTIMEO;
- so->so_snd.sb_timeo = NB_RCVTIMEO;
+ so->so_rcv.sb_timeo = NB_RCVTIMEO * hz;
+ so->so_snd.sb_timeo = NB_RCVTIMEO * hz;
error = soreserve(so, nb_tcpsndbuf, nb_tcprcvbuf);
sounlock(so);
if (error)
@@ -250,15 +239,12 @@ nbssn_rq_request(struct nbpcb *nbp, stru
mb_done(mbp);
if (error)
return error;
- error = nbssn_rselect(nbp, &nb_timo, POLLIN, l);
- if (error == EWOULDBLOCK) { /* Timeout */
- NBDEBUG(("initial request timeout\n"));
- return ETIMEDOUT;
- }
- if (error) /* restart or interrupt */
- return error;
- error = nbssn_recv(nbp, &m0, &rplen, &rpcode, l);
+ error = nbssn_recv(nbp, &m0, &rplen, &rpcode, true, l);
if (error) {
+ if (error == EWOULDBLOCK) { /* Timeout */
+ NBDEBUG(("initial request timeout\n"));
+ return ETIMEDOUT;
+ }
NBDEBUG(("recv() error %d\n", error));
return error;
}
@@ -338,7 +324,7 @@ nbssn_recvhdr(struct nbpcb *nbp, int *le
static int
nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp,
- u_int8_t *rpcodep, struct lwp *l)
+ u_int8_t *rpcodep, bool dowait, struct lwp *l)
{
struct socket *so = nbp->nbp_tso;
struct uio auio;
@@ -356,12 +342,13 @@ nbssn_recv(struct nbpcb *nbp, struct mbu
if (mpp)
*mpp = NULL;
m = NULL;
- for(;;) {
+ for(;; dowait = false) {
/*
* Poll for a response header.
* If we don't have one waiting, return.
*/
- error = nbssn_recvhdr(nbp, &len, &rpcode, MSG_DONTWAIT, l);
+ error = nbssn_recvhdr(nbp, &len, &rpcode,
+ dowait ? 0 : MSG_DONTWAIT, l);
if (so->so_state &
(SS_ISDISCONNECTING | SS_ISDISCONNECTED | SS_CANTRCVMORE)) {
nbp->nbp_state = NBST_CLOSED;
@@ -463,7 +450,7 @@ smb_nbst_create(struct smb_vc *vcp, stru
{
struct nbpcb *nbp;
- nbp = malloc(sizeof *nbp, M_NBDATA, M_WAITOK|M_ZERO);
+ nbp = kmem_zalloc(sizeof(*nbp), KM_SLEEP);
nbp->nbp_state = NBST_CLOSED;
nbp->nbp_vc = vcp;
vcp->vc_tdata = nbp;
@@ -482,7 +469,7 @@ smb_nbst_done(struct smb_vc *vcp, struct
free(nbp->nbp_laddr, M_SONAME);
if (nbp->nbp_paddr)
free(nbp->nbp_paddr, M_SONAME);
- free(nbp, M_NBDATA);
+ kmem_free(nbp, sizeof(*nbp));
return 0;
}
@@ -606,7 +593,7 @@ smb_nbst_recv(struct smb_vc *vcp, struct
int error, rplen;
nbp->nbp_flags |= NBF_RECVLOCK;
- error = nbssn_recv(nbp, mpp, &rplen, &rpcode, l);
+ error = nbssn_recv(nbp, mpp, &rplen, &rpcode, false, l);
nbp->nbp_flags &= ~NBF_RECVLOCK;
return error;
}
@@ -646,8 +633,8 @@ smb_nbst_getparam(struct smb_vc *vcp, in
break;
case SMBTP_TIMEOUT:
tvp = (struct timeval *)data;
- tvp->tv_sec = nb_timo.tv_sec;
- tvp->tv_usec = nb_timo.tv_nsec / 1000;
+ tvp->tv_sec = NB_RCVTIMEO;
+ tvp->tv_usec = 0;
break;
default:
return EINVAL;
Index: src/sys/netsmb/smb_trantcp.h
diff -u src/sys/netsmb/smb_trantcp.h:1.6 src/sys/netsmb/smb_trantcp.h:1.6.56.1
--- src/sys/netsmb/smb_trantcp.h:1.6 Tue Jun 24 10:37:19 2008
+++ src/sys/netsmb/smb_trantcp.h Sun Aug 10 06:56:43 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: smb_trantcp.h,v 1.6 2008/06/24 10:37:19 gmcgarry Exp $ */
+/* $NetBSD: smb_trantcp.h,v 1.6.56.1 2014/08/10 06:56:43 tls Exp $ */
/*
* Copyright (c) 2000-2001, Boris Popov
@@ -82,10 +82,10 @@ struct nbpcb {
#define NB_RCVQ (64 * 1024)
/*
- * Timeouts used for send/receive. XXX Sysctl this?
+ * Timeouts (s) used for send/receive. XXX Sysctl this?
*/
-#define NB_SNDTIMEO (5 * hz)
-#define NB_RCVTIMEO (5 * hz)
+#define NB_SNDTIMEO (5)
+#define NB_RCVTIMEO (5)
/*
* TCP slowstart presents a problem in conjunction with large