1 #!/bin/ksh -p
   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  25 #
  26 
  27 #
  28 # ID: misc_003
  29 #
  30 # DESCRIPTION:
  31 #       Verify reconnect after connection to server is lost.
  32 #
  33 # STRATEGY:
  34 #       1. run "mount -F smbfs //server/public /export/mnt"
  35 #       2. create a file
  36 #       3. force the connection to drop
  37 #       4. read the file (from step 2)
  38 #
  39 
  40 . $STF_SUITE/include/libtest.ksh
  41 
  42 tc_id="misc003"
  43 tc_desc=" Verify reconnect after connection loss."
  44 print_test_case $tc_id - $tc_desc
  45 
  46 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
  47         [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
  48     set -x
  49 fi
  50 
  51 server=$(server_name)||return
  52 
  53 testdir_init $TDIR
  54 smbmount_clean $TMNT
  55 smbmount_init $TMNT
  56 
  57 #       1. run "mount -F smbfs //server/public /export/mnt"
  58 
  59 cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $TMNT"
  60 cti_execute -i '' FAIL $cmd
  61 if [[ $? != 0 ]]; then
  62         cti_fail "FAIL: $cmd"
  63         return
  64 else
  65         cti_report "PASS: $cmd"
  66 fi
  67 
  68 #       2. create a file
  69 
  70 cmd="touch $TMNT/$tc_id"
  71 cti_execute_cmd $cmd
  72 if [[ $? != 0 ]]; then
  73         cti_fail "FAIL: $cmd"
  74         return
  75 fi
  76 
  77 #       3. force the connection to drop
  78 #       (SMB uses port: 445)
  79 
  80 cmd="abort_conn -p 445 $server "
  81 cti_execute_cmd sudo -n $cmd
  82 if [[ $? != 0 ]]; then
  83         cti_fail "FAIL: $cmd"
  84         return
  85 fi
  86 sleep 2
  87 
  88 #       Would be nice to verify the connections are IDLE,
  89 #       but it can be tricky to identify which is ours.
  90 #       For now, just log the connection states here.
  91 #       Our connetion will show state "IDLE".
  92 
  93 cmd="echo '::nsmb_vc' |sudo -n mdb -k"
  94 cti_execute_cmd $cmd
  95 if [[ $? != 0 ]]; then
  96         cti_fail "FAIL: $cmd"
  97         return
  98 fi
  99 
 100 #       4. read the file (from step 2)
 101 #       This will initiate a reconnect.
 102 
 103 cmd="ls -l $TMNT/$tc_id"
 104 cti_execute_cmd $cmd
 105 if [[ $? != 0 ]]; then
 106         cti_fail "FAIL: $cmd"
 107         return
 108 fi
 109 
 110 cti_execute_cmd "rm -rf $TMNT/*"
 111 
 112 smbmount_clean $TMNT
 113 cti_pass "$tc_id: PASS"