2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
17 * These replace NODIRECT functions of the same name in
18 * $SRC/lib/smbsrv/libsmb/common/smb_kmod.c including:
19 * smb_kmod_bind, smb_kmod_ioctl, smb_kmod_isbound,
20 * smb_kmod_start, smb_kmod_stop, smb_kmod_unbind.
22 * For all the other smb_kmod_... functions, we can just use the
23 * libsmb code because those all call smb_kmod_ioctl, for which
24 * we have an override here.
26 * The replacment functions here just call the libfksmbsrv code
27 * directly where the real (in-kernel) versions would be entered
28 * via the driver framework (open, close, ioctl). Aside from that,
29 * the call sequences are intentionally the same (where possible).
30 * In particular, that makes it possible to debug startup/teardown
31 * problems in the user-space version of this code.
34 #include <sys/types.h>
36 #include <sys/ioccom.h>
37 #include <sys/param.h>
48 #include <smbsrv/smbinfo.h>
49 #include <smbsrv/smb_ioctl.h>
52 boolean_t smbdrv_opened
= B_FALSE
;
55 * We want to adjust a few things in the standard configuration
56 * passed to the "fake" version of the smbsrv kernel module.
58 * Reduce the maximum number of connections and workers, just for
59 * convenience while debugging. (Don't want hundreds of threads.)
62 fksmbd_adjust_config(smb_ioc_header_t
*ioc_hdr
)
64 smb_ioc_cfg_t
*ioc
= (smb_ioc_cfg_t
*)ioc_hdr
;
67 ioc
->maxconnections
= 10;
69 smbd_report("maxconnections=%d, maxworkers=%d",
70 ioc
->maxconnections
, ioc
->maxworkers
);
72 if ((s
= getenv("SMB_SIGNING")) != NULL
) {
73 ioc
->signing_enable
= 0;
74 ioc
->signing_required
= 0;
77 ioc
->signing_enable
= 1;
80 ioc
->signing_enable
= 1;
81 ioc
->signing_required
= 1;
84 smbd_report("env SMB_SIGNING invalid");
88 smbd_report("signing: enable=%d, required=%d",
89 ioc
->signing_enable
, ioc
->signing_required
);
93 smb_kmod_isbound(void)
95 return (smbdrv_opened
);
104 smbdrv_opened
= B_FALSE
;
105 (void) fksmbsrv_drv_close();
108 rc
= fksmbsrv_drv_open();
110 smbdrv_opened
= B_TRUE
;
116 smb_kmod_unbind(void)
119 smbdrv_opened
= B_FALSE
;
120 (void) fksmbsrv_drv_close();
125 smb_kmod_ioctl(int cmd
, smb_ioc_header_t
*ioc
, uint32_t len
)
129 _NOTE(ARGUNUSED(len
));
134 if (cmd
== SMB_IOC_CONFIG
)
135 fksmbd_adjust_config(ioc
);
137 rc
= fksmbsrv_drv_ioctl(cmd
, ioc
);
143 smb_kmod_start(int opipe
, int lmshr
, int udoor
)
148 bzero(&ioc
, sizeof (ioc
));
150 /* These three are unused */
155 /* These are the "door" dispatch callbacks */
156 ioc
.lmshr_func
= NULL
; /* not used */
157 ioc
.opipe_func
= NULL
; /* not used */
158 ioc
.udoor_func
= (void *)fksmbd_door_dispatch
;
160 rc
= smb_kmod_ioctl(SMB_IOC_START
, &ioc
.hdr
, sizeof (ioc
));
167 smb_ioc_header_t ioc
;
169 bzero(&ioc
, sizeof (ioc
));
170 (void) smb_kmod_ioctl(SMB_IOC_STOP
, &ioc
, sizeof (ioc
));