Print this page
NEX-16824 SMB client connection setup rework
NEX-17232 SMB client reconnect failures
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
and: (improve debug)
NEX-16818 Add fksmbcl development tool
NEX-17264 SMB client test tp_smbutil_013 fails after NEX-14666
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
and: (fix ref leaks)
NEX-16805 Add smbutil discon command
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/lib/libsmbfs/smb/findvc.c
+++ new/usr/src/lib/libsmbfs/smb/findvc.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 + *
26 + * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
25 27 */
26 28
27 29 /*
28 30 * Find existing an VC given a list of addresses.
29 31 */
30 32
31 33 #include <errno.h>
32 34 #include <stdio.h>
33 35 #include <string.h>
34 36 #include <strings.h>
35 37 #include <stdlib.h>
36 38 #include <unistd.h>
37 39 #include <netdb.h>
38 40 #include <libintl.h>
39 41 #include <xti.h>
40 42 #include <assert.h>
41 43
42 44 #include <sys/types.h>
43 45 #include <sys/time.h>
44 46 #include <sys/byteorder.h>
45 47 #include <sys/socket.h>
46 48 #include <sys/fcntl.h>
47 49
48 50 #include <netinet/in.h>
49 51 #include <netinet/tcp.h>
50 52 #include <arpa/inet.h>
51 53
52 54 #include <netsmb/smb.h>
53 55 #include <netsmb/smb_lib.h>
54 56 #include <netsmb/netbios.h>
55 57 #include <netsmb/nb_lib.h>
56 58 #include <netsmb/smb_dev.h>
57 59
58 60 #include "charsets.h"
59 61 #include "private.h"
60 62
61 63 /*
62 64 * Ask the driver if it has a VC with this IP address.
63 65 */
64 66 static int
65 67 findvc(struct smb_ctx *ctx, struct addrinfo *ai)
66 68 {
67 69 smbioc_ossn_t *ssn = &ctx->ct_ssn;
68 70
|
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
69 71 /*
70 72 * Copy the passed address into ssn_srvaddr,
71 73 * but first sanity-check lengths. Also,
72 74 * zero it first to avoid trailing junk.
73 75 */
74 76 if (ai->ai_addrlen > sizeof (ssn->ssn_srvaddr))
75 77 return (EINVAL);
76 78 bzero(&ssn->ssn_srvaddr, sizeof (ssn->ssn_srvaddr));
77 79 bcopy(ai->ai_addr, &ssn->ssn_srvaddr, ai->ai_addrlen);
78 80
79 - if (ioctl(ctx->ct_dev_fd, SMBIOC_SSN_FIND, ssn) == -1)
81 + if (nsmb_ioctl(ctx->ct_dev_fd, SMBIOC_SSN_FIND, ssn) == -1)
80 82 return (errno);
81 83
82 84 return (0);
83 85 }
84 86
85 87 /*
86 88 * Find (and reuse) an existing VC.
87 89 * See also: newvc.c
88 90 */
89 91 int
90 92 smb_ctx_findvc(struct smb_ctx *ctx)
91 93 {
92 94 struct addrinfo *ai;
93 95 int err;
94 96
95 97 /* Should already have the address list. */
96 98 if ((ctx->ct_flags & SMBCF_RESOLVED) == 0)
97 99 return (EINVAL);
98 100
101 + if (ctx->ct_dev_fd < 0) {
102 + if ((err = smb_ctx_gethandle(ctx)))
103 + return (err);
104 + }
105 +
99 106 for (ai = ctx->ct_addrinfo; ai; ai = ai->ai_next) {
100 107
101 108 switch (ai->ai_family) {
102 109
103 110 case AF_INET:
104 111 case AF_INET6:
105 112 case AF_NETBIOS:
106 113 err = findvc(ctx, ai);
107 114 break;
108 115
109 116 default:
110 117 DPRINT("skipped family %d", ai->ai_family);
111 118 err = EPROTONOSUPPORT;
112 119 break;
113 120 }
114 121
115 122 if (err == 0) {
116 123 /* re-use an existing VC */
117 - ctx->ct_flags |= SMBCF_SSNACTIVE;
118 124 return (0);
119 125 }
120 126 }
121 127
122 128 return (ENOENT);
123 129 }
124 130
125 131 /*
126 132 * Forcibly disconnect the current session, even if
127 133 * there are others using it! This is used by the
128 134 * SMB server netlogon when it wants to setup a new
129 135 * logon session and does not want any re-use.
130 136 */
131 137 int
132 138 smb_ctx_kill(struct smb_ctx *ctx)
133 139 {
134 140
135 - if (ioctl(ctx->ct_dev_fd, SMBIOC_SSN_KILL, NULL) == -1)
141 + if (nsmb_ioctl(ctx->ct_dev_fd, SMBIOC_SSN_KILL, NULL) == -1)
136 142 return (errno);
137 143
138 144 return (0);
139 145 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX