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
↓ 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>
↓ 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