Print this page
NEX-14666 Need to provide SMB 2.1 Client
NEX-17187 panic in smbfs_acl_store
NEX-17231 smbfs create xattr files finds wrong file
NEX-17224 smbfs lookup EINVAL should be ENOENT
NEX-17260 SMB1 client fails to list directory after NEX-14666
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
and: (cleanup)
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)

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/netsmb/smb_dev.h
          +++ new/usr/src/uts/common/netsmb/smb_dev.h
↓ open down ↓ 25 lines elided ↑ open up ↑
  26   26   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27   27   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28   28   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29   29   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30   30   * SUCH DAMAGE.
  31   31   *
  32   32   * $Id: smb_dev.h,v 1.10.178.1 2005/05/27 02:35:29 lindak Exp $
  33   33   */
  34   34  
  35   35  /*
  36      - * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  37   36   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  38   37   * Use is subject to license terms.
       38 + *
       39 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  39   40   */
  40   41  
  41   42  #ifndef _NETSMB_DEV_H_
  42   43  #define _NETSMB_DEV_H_
  43   44  
  44   45  /*
  45   46   * This file defines an internal ABI for the "nsmb" driver,
  46   47   * particularly the various data structures passed to ioctl.
  47   48   * In order to avoid some messy 32-bit to 64-bit conversions
  48   49   * in the driver, we take pains to define all data structures
↓ open down ↓ 15 lines elided ↑ open up ↑
  64   65  #include <sys/socket_impl.h>
  65   66  #include <netinet/in.h>
  66   67  
  67   68  #define NSMB_NAME               "nsmb"
  68   69  
  69   70  /*
  70   71   * Update NSMB_VER* if any of the ioctl codes and/or
  71   72   * associated structures change in ways that would
  72   73   * make them incompatible with an old driver.
  73   74   */
  74      -#define NSMB_VERMAJ     1
  75      -#define NSMB_VERMIN     4000
  76      -#define NSMB_VERSION    (NSMB_VERMAJ * 100000 + NSMB_VERMIN)
       75 +#define NSMB_VERMAJ     2
       76 +#define NSMB_VERMIN     0x100
       77 +#define NSMB_VERSION    ((NSMB_VERMAJ << 16) | NSMB_VERMIN)
  77   78  
  78   79  /*
  79   80   * Some errno values we need to expose to the library.
  80   81   * NB: these are also defined in the library smbfs_api.h
  81   82   * to avoid exposing all of this stuff in that API.
  82   83   *
  83   84   * EBADRPC is used for message decoding errors.
  84   85   * EAUTH is used for CIFS authentication errors.
  85   86   */
  86   87  #ifndef EBADRPC
↓ open down ↓ 17 lines elided ↑ open up ↑
 104  105  #define SMBM_ANY_GROUP          ((gid_t)-1)
 105  106  
 106  107  /*
 107  108   * Option flags in smbioc_ossn.ioc_opt
 108  109   * and vcspec.optflags
 109  110   */
 110  111  #define SMBVOPT_CREATE          0x0001  /* create object if necessary */
 111  112  #define SMBVOPT_PRIVATE         0x0002  /* connection should be private */
 112  113  #define SMBVOPT_SINGLESHARE     0x0004  /* keep only one share at this VC */
 113  114  #define SMBVOPT_PERMANENT       0x0010  /* object will keep last reference */
 114      -#define SMBVOPT_EXT_SEC         0x0020  /* extended security negotiation */
 115      -#define SMBVOPT_USE_KEYCHAIN    0x0040  /* get p/w from keychain */
 116      -#define SMBVOPT_KC_DOMAIN       0x0080  /* keychain lookup uses domain */
      115 +#define SMBVOPT_ANONYMOUS       0x0020  /* using a NULL session */
 117  116  
 118      -#define SMBVOPT_SIGNING_ENABLED         0x0100  /* sign if server agrees */
 119      -#define SMBVOPT_SIGNING_REQUIRED        0x0200  /* signing required */
 120      -#define SMBVOPT_SIGNING_MASK            0x0300  /* all signing bits */
      117 +#define SMBVOPT_SIGNING_ENABLED         0x10000 /* sign if server agrees */
      118 +#define SMBVOPT_SIGNING_REQUIRED        0x20000 /* signing required */
      119 +#define SMBVOPT_SIGNING_MASK            0x30000 /* all signing bits */
 121  120  
      121 +#define SMB2_DIALECT_BASE       0x0200
      122 +#define SMB2_DIALECT_0202       0x0202
      123 +#define SMB2_DIALECT_02ff       0x02ff
      124 +#define SMB2_DIALECT_0210       0x0210
      125 +#define SMB2_DIALECT_0300       0x0300
      126 +#define SMB2_DIALECT_0302       0x0302
      127 +
      128 +/* Maximum supported dialect (for ssn_maxver) */
      129 +#define SMB2_DIALECT_MAX        SMB2_DIALECT_0210
      130 +
 122  131  /*
 123  132   * Option flags in smbioc_oshare.ioc_opt
 124  133   * and sharespec.optflags
 125  134   */
 126  135  #define SMBSOPT_CREATE          SMBVOPT_CREATE
 127  136  #define SMBSOPT_PERMANENT       SMBVOPT_PERMANENT
 128  137  
 129  138  /* All user and machine names. */
 130  139  #define SMBIOC_MAX_NAME         256
 131  140  
 132  141  /*
 133  142   * Size of storage for p/w hashes.
 134  143   * Also for SMBIOC_GETSSNKEY.
 135  144   */
 136  145  #define SMBIOC_HASH_SZ  16
 137  146  
 138  147  /*
 139  148   * network IO daemon states
 140      - * really connection states.
 141  149   */
 142  150  enum smbiod_state {
 143      -        SMBIOD_ST_IDLE = 0,     /* no user requests enqueued yet */
 144      -        SMBIOD_ST_RECONNECT,    /* a [re]connect attempt is in progress */
      151 +        SMBIOD_ST_UNINIT = 0,   /* uninitialized */
      152 +        SMBIOD_ST_RECONNECT,    /* a [re]connect attempt requested */
 145  153          SMBIOD_ST_RCFAILED,     /* a reconnect attempt has failed */
 146      -        SMBIOD_ST_VCACTIVE,     /* session established */
      154 +        SMBIOD_ST_CONNECTED,    /* Transport (TCP) connected */
      155 +        SMBIOD_ST_NEGOTIATED,   /* Negotiated SMB/SMB2+ */
      156 +        SMBIOD_ST_AUTHCONT,     /* Session setup continuing */
      157 +        SMBIOD_ST_AUTHFAIL,     /* Session setup failed */
      158 +        SMBIOD_ST_AUTHOK,       /* Session setup success */
      159 +        SMBIOD_ST_VCACTIVE,     /* iod_work running */
      160 +        SMBIOD_ST_IDLE,         /* no trees, will go DEAD */
 147  161          SMBIOD_ST_DEAD          /* connection gone, no IOD */
 148  162  };
 149  163  
 150  164  
 151  165  /*
 152  166   * We're now using structures that are invariant
 153  167   * across 32-bit vs 64-bit compilers for all
 154  168   * member sizes and offsets.  Scalar members
 155  169   * simply have to use fixed-size types.
 156  170   * Pointers are a little harder...
↓ open down ↓ 40 lines elided ↑ open up ↑
 197  211  
 198  212  /*
 199  213   * Flags for smbioc_ossn.ssn_opt
 200  214   */
 201  215  #define SMBLK_CREATE            SMBVOPT_CREATE
 202  216  
 203  217  /*
 204  218   * Structure used with SMBIOC_SSN_FIND, _CREATE
 205  219   */
 206  220  struct smbioc_ossn {
 207      -        uint32_t                ssn_vopt;       /* i.e. SMBVOPT_CREATE */
 208  221          uint32_t                ssn_owner;      /* Unix owner (UID) */
      222 +        uint32_t                ssn_vopt;       /* i.e. SMBVOPT_CREATE */
      223 +        uint16_t                ssn_minver;     /* Min SMB version. */
      224 +        uint16_t                ssn_maxver;     /* Max SMB version. */
 209  225          smbioc_ssn_ident_t      ssn_id;
 210  226          char                    ssn_srvname[SMBIOC_MAX_NAME];
 211  227  };
 212  228  typedef struct smbioc_ossn smbioc_ossn_t;
 213  229  /* Convenience names for members under ssn_id */
 214  230  #define ssn_srvaddr     ssn_id.id_srvaddr
 215  231  #define ssn_domain      ssn_id.id_domain
 216  232  #define ssn_user        ssn_id.id_user
 217  233  
 218  234  /*
↓ open down ↓ 6 lines elided ↑ open up ↑
 225  241          char            sh_pass[SMBIOC_MAX_NAME];
 226  242  };
 227  243  typedef struct smbioc_oshare smbioc_oshare_t;
 228  244  
 229  245  typedef struct smbioc_tcon {
 230  246          int32_t         tc_flags;
 231  247          int32_t         tc_opt;
 232  248          smbioc_oshare_t tc_sh;
 233  249  } smbioc_tcon_t;
 234  250  
 235      -
 236  251  /*
 237      - * Negotiated protocol parameters
 238      - */
 239      -struct smb_sopt {
 240      -        int16_t         sv_proto;       /* protocol dialect */
 241      -        uchar_t         sv_sm;          /* security mode */
 242      -        int16_t         sv_tz;          /* offset in min relative to UTC */
 243      -        uint16_t        sv_maxmux;      /* max number of outstanding rq's */
 244      -        uint16_t        sv_maxvcs;      /* max number of VCs */
 245      -        uint16_t        sv_rawmode;
 246      -        uint32_t        sv_maxtx;       /* maximum transmit buf size */
 247      -        uint32_t        sv_maxraw;      /* maximum raw-buffer size */
 248      -        uint32_t        sv_skey;        /* session key */
 249      -        uint32_t        sv_caps;        /* capabilites SMB_CAP_ */
 250      -};
 251      -typedef struct smb_sopt smb_sopt_t;
 252      -
 253      -/*
 254      - * State carried in/out of the driver by the IOD thread.
 255      - * Inside the driver, these are members of the "VC" object.
 256      - */
 257      -struct smb_iods {
 258      -        int32_t         is_tran_fd;     /* transport FD */
 259      -        uint32_t        is_vcflags;     /* SMBV_... */
 260      -        uint8_t         is_hflags;      /* SMB header flags */
 261      -        uint16_t        is_hflags2;     /* SMB header flags2 */
 262      -        uint16_t        is_smbuid;      /* SMB header UID */
 263      -        uint16_t        is_next_mid;    /* SMB header MID */
 264      -        uint32_t        is_txmax;       /* max tx/rx packet size */
 265      -        uint32_t        is_rwmax;       /* max read/write data size */
 266      -        uint32_t        is_rxmax;       /* max readx data size */
 267      -        uint32_t        is_wxmax;       /* max writex data size */
 268      -        uint8_t         is_ssn_key[SMBIOC_HASH_SZ]; /* session key */
 269      -        /* Signing state */
 270      -        uint32_t        is_next_seq;    /* my next sequence number */
 271      -        uint32_t        is_u_maclen;    /* MAC key length */
 272      -        lptr_t          is_u_mackey;    /* user-space ptr! */
 273      -};
 274      -typedef struct smb_iods smb_iods_t;
 275      -
 276      -/*
 277  252   * This is the operational state information passed
 278  253   * in and out of the driver for SMBIOC_SSN_WORK
 279  254   */
 280  255  struct smbioc_ssn_work {
 281      -        smb_iods_t      wk_iods;
 282      -        smb_sopt_t      wk_sopt;
 283      -        int             wk_out_state;
      256 +        uint32_t        wk_out_state;   /* out-only */
      257 +        uint32_t        wk_u_ssnkey_len; /* ssn key length */
      258 +        lptr_t          wk_u_ssnkey_buf; /* user-space ptr! */
      259 +        uint32_t        wk_u_auth_rlen; /* recv auth tok len */
      260 +        uint32_t        wk_u_auth_wlen; /* send auth tok len */
      261 +        lptr_t          wk_u_auth_rbuf; /* recv auth tok buf */
      262 +        lptr_t          wk_u_auth_wbuf; /* send auth tok buf */
      263 +        uint8_t         wk_cl_guid[16]; /* client GUID */
 284  264  };
 285  265  typedef struct smbioc_ssn_work smbioc_ssn_work_t;
 286  266  
 287  267  /*
 288  268   * User-level SMB requests
 289  269   */
 290  270  
 291      -/*
 292      - * SMBIOC_REQUEST (simple SMB request)
 293      - */
 294      -typedef struct smbioc_rq {
 295      -        uchar_t         ioc_cmd;
 296      -        uint8_t         ioc_errclass;
 297      -        uint16_t        ioc_serror;
 298      -        uint32_t        ioc_error;
 299      -        uint32_t        ioc_tbufsz;     /* transmit */
 300      -        uint32_t        ioc_rbufsz;     /* receive */
 301      -        lptr_t          _ioc_tbuf;
 302      -        lptr_t          _ioc_rbuf;
 303      -} smbioc_rq_t;
 304      -#define ioc_tbuf        _ioc_tbuf.lp_ptr
 305      -#define ioc_rbuf        _ioc_rbuf.lp_ptr
 306      -
 307      -
 308      -#define SMBIOC_T2RQ_MAXSETUP    4
 309      -#define SMBIOC_T2RQ_MAXNAME     128
 310      -
 311      -typedef struct smbioc_t2rq {
 312      -        uint16_t        ioc_setup[SMBIOC_T2RQ_MAXSETUP];
 313      -        int32_t         ioc_setupcnt;
 314      -        char            ioc_name[SMBIOC_T2RQ_MAXNAME];
 315      -        ushort_t        ioc_tparamcnt;
 316      -        ushort_t        ioc_tdatacnt;
 317      -        ushort_t        ioc_rparamcnt;
 318      -        ushort_t        ioc_rdatacnt;
 319      -        uint8_t         ioc__pad1;
 320      -        uint8_t         ioc_errclass;
 321      -        uint16_t        ioc_serror;
 322      -        uint32_t        ioc_error;
 323      -        uint16_t        ioc_rpflags2;
 324      -        uint16_t        ioc__pad2;
 325      -        lptr_t          _ioc_tparam;
 326      -        lptr_t          _ioc_tdata;
 327      -        lptr_t          _ioc_rparam;
 328      -        lptr_t          _ioc_rdata;
 329      -} smbioc_t2rq_t;
 330      -#define ioc_tparam      _ioc_tparam.lp_ptr
 331      -#define ioc_tdata       _ioc_tdata.lp_ptr
 332      -#define ioc_rparam      _ioc_rparam.lp_ptr
 333      -#define ioc_rdata       _ioc_rdata.lp_ptr
 334      -
 335      -
 336      -typedef struct smbioc_flags {
 337      -        int32_t         ioc_level;      /* 0 - session, 1 - share */
 338      -        int32_t         ioc_flags;
 339      -        int32_t         ioc_mask;
 340      -} smbioc_flags_t;
 341      -
 342  271  typedef struct smbioc_rw {
 343      -        int32_t         ioc_fh;
 344  272          uint32_t        ioc_cnt;
      273 +        uint32_t        ioc_flags;
 345  274          lloff_t _ioc_offset;
 346  275          lptr_t  _ioc_base;
 347  276  } smbioc_rw_t;
 348  277  #define ioc_offset      _ioc_offset._f
 349  278  #define ioc_base        _ioc_base.lp_ptr
 350  279  
      280 +/* Transact on named pipe (send/recv) */
      281 +typedef struct smbioc_xnp {
      282 +        uint32_t        ioc_tdlen;      /* transmit len */
      283 +        uint32_t        ioc_rdlen;      /* recv maxlen */
      284 +        uint32_t        ioc_more;       /* more data to read */
      285 +        uint32_t        ioc_pad1;
      286 +        lptr_t          _ioc_tdata;
      287 +        lptr_t          _ioc_rdata;
      288 +} smbioc_xnp_t;
      289 +#define ioc_tdata       _ioc_tdata.lp_ptr
      290 +#define ioc_rdata       _ioc_rdata.lp_ptr
      291 +
 351  292  typedef struct smbioc_ntcreate {
 352  293          uint32_t        ioc_req_acc;
 353  294          uint32_t        ioc_efattr;
 354  295          uint32_t        ioc_share_acc;
 355  296          uint32_t        ioc_open_disp;
 356  297          uint32_t        ioc_creat_opts;
 357  298          char            ioc_name[SMBIOC_MAX_NAME];
 358  299  } smbioc_ntcreate_t;
 359  300  
 360  301  typedef struct smbioc_printjob {
↓ open down ↓ 18 lines elided ↑ open up ↑
 379  320   * Define ioctl codes the way ZFS does.
 380  321   * The "base" value is arbitrary, and can
 381  322   * occupy the high word if we like, because
 382  323   * our driver does its own copyin/copyout.
 383  324   * Keep GETVERS first and use it to verify
 384  325   * driver compatibility with the library.
 385  326   */
 386  327  #define SMBIOC_BASE     ((('n' << 8) | 's') << 8)
 387  328  typedef enum nsmb_ioc {
 388  329          SMBIOC_GETVERS = SMBIOC_BASE,   /* keep first */
 389      -        SMBIOC_FLAGS2,          /* get hflags2 */
      330 +        SMBIOC_FLAGS2,          /* obsolete */
 390  331          SMBIOC_GETSSNKEY,       /* get SMB session key */
 391  332          SMBIOC_DUP_DEV,         /* duplicate dev handle */
 392  333  
 393      -        SMBIOC_REQUEST,         /* simple request */
 394      -        SMBIOC_T2RQ,            /* trans2 request */
 395      -
 396  334          SMBIOC_READ,            /* read (pipe) */
 397  335          SMBIOC_WRITE,           /* write (pipe) */
      336 +        SMBIOC_XACTNP,          /* "transact" (pipe) */
 398  337          SMBIOC_NTCREATE,        /* open or create */
 399  338          SMBIOC_PRINTJOB,        /* open print job */
 400  339          SMBIOC_CLOSEFH,         /* from ntcreate or printjob */
 401  340  
 402  341          SMBIOC_SSN_CREATE,
 403  342          SMBIOC_SSN_FIND,
 404  343          SMBIOC_SSN_KILL,        /* force disconnect */
 405  344          SMBIOC_SSN_RELE,        /* drop our reference */
 406  345  
 407  346          SMBIOC_TREE_CONNECT,    /* create and connect */
 408  347          SMBIOC_TREE_FIND,
 409  348          SMBIOC_TREE_KILL,
 410  349          SMBIOC_TREE_RELE,
 411  350  
      351 +        SMBIOC_IOD_CONNECT,     /* Setup connection */
      352 +        SMBIOC_IOD_NEGOTIATE,   /* SMB/SMB2 negotiate */
      353 +        SMBIOC_IOD_SSNSETUP,    /* SMB/SMB2 session setup */
 412  354          SMBIOC_IOD_WORK,        /* work on session requests */
 413  355          SMBIOC_IOD_IDLE,        /* wait for requests on this session */
 414      -        SMBIOC_IOD_RCFAIL,      /* notify that reconnect failed */
      356 +        SMBIOC_IOD_RCFAIL,      /* tell driver reconnect failed */
 415  357  
 416  358          /* Password Keychain (PK) support. */
 417  359          SMBIOC_PK_ADD,    /* Add/Modify a password entry */
 418  360          SMBIOC_PK_CHK,    /* Check for a password entry */
 419  361          SMBIOC_PK_DEL,    /* Delete specified password entry */
 420  362          SMBIOC_PK_DEL_OWNER,    /* all owned by the caller */
 421  363          SMBIOC_PK_DEL_EVERYONE  /* all owned by everyone */
 422  364  } nsmb_ioc_t;
 423  365  
 424  366  #endif /* _NETSMB_DEV_H_ */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX