From 76af9f62481b1ac910cd6a0f7237fe32b0657c29 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Thu, 31 May 2018 11:22:11 +0200 Subject: [PATCH] LU-11057 tests: exercise 'network' client mount option Test 'network' client mount option that enables to limit connections from the client to be on the network NID specified. This option is currently not compatible with Dynamic Peer Discovery. test_31 will have to be updated once Dynamic Peer Discovery is modified so that it does not conflict with 'network' client mount option. Test-Parameters: trivial testlist=sanity-sec Signed-off-by: Sebastien Buisson Change-Id: I4631a034137a346d0bb4efed20983e2a8bd7b0ec Reviewed-on: https://review.whamcloud.com/32590 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Amir Shehata Reviewed-by: Oleg Drokin --- lustre/tests/sanity-sec.sh | 119 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/lustre/tests/sanity-sec.sh b/lustre/tests/sanity-sec.sh index dfd07fa..86b991c 100755 --- a/lustre/tests/sanity-sec.sh +++ b/lustre/tests/sanity-sec.sh @@ -2137,6 +2137,125 @@ test_30() { } run_test 30 "check for invalid shared key" +cleanup_31() { + # unmount client + zconf_umount $HOSTNAME $MOUNT || error "unable to umount client" + + # remove ${NETTYPE}999 network on all nodes + do_nodes $(comma_list $(all_nodes)) \ + "$LNETCTL net del --net ${NETTYPE}999 && \ + $LNETCTL lnet unconfigure 2>/dev/null || true" + + # necessary to do writeconf in order to de-register + # @${NETTYPE}999 nid for targets + stopall + writeconf_all + setupall server_only + + # remount client normally + mount_client $MOUNT $MOUNT_OPTS || error "unable to remount client" + if [ "$MOUNT_2" ]; then + mount_client $MOUNT2 || error "unable to remount client2" + fi +} + +test_31() { + local nid=$(lctl list_nids | grep ${NETTYPE} | head -n1) + local addr=$(echo $nid | cut -f 1 -d @) + local net=$(echo $nid | cut -f 2 -d @) + + export LNETCTL=$(which lnetctl 2> /dev/null) + + [ -z "$LNETCTL" ] && skip "without lnetctl support." && return + local_mode && skip "in local mode." && return + + stack_trap cleanup_31 EXIT + + # unmount client + umount_client $MOUNT || error "unable to umount client" + if [ "$MOUNT_2" ]; then + umount_client $MOUNT2 || error "unable to umount client2" + fi + + # check exports on servers are empty for client + do_facet mgs "lctl get_param -n *.MGS*.exports.'$nid'.uuid 2>/dev/null \ + | grep -q -" && + error "export on MGS should be empty" + do_nodes $(comma_list $(mdts_nodes) $(osts_nodes)) \ + "lctl get_param -n *.${FSNAME}*.exports.'$nid'.uuid \ + 2>/dev/null | grep -q -" && + error "export on servers should be empty" + + # add network ${NETTYPE}999 on all nodes + do_nodes $(comma_list $(all_nodes)) \ + "$LNETCTL lnet configure && $LNETCTL net add --if \ + $($LNETCTL net show --net $net | awk 'BEGIN{inf=0} \ + {if (inf==1) print $2; fi; inf=0} /interfaces/{inf=1}') \ + --net ${NETTYPE}999" || + error "unable to configure NID ${NETTYPE}999" + + # necessary to do writeconf in order to register + # new @${NETTYPE}999 nid for targets + stopall + writeconf_all + setupall server_only + + # backup MGSNID + local mgsnid_orig=$MGSNID + # compute new MGSNID + MGSNID=$(do_facet mgs "$LCTL list_nids | grep ${NETTYPE}999") + + # on client, turn LNet Dynamic Discovery on + lnetctl set discovery 1 + + # mount client with -o network=${NETTYPE}999 option: + # should fail because of LNet Dynamic Discovery + mount_client $MOUNT ${MOUNT_OPTS},network=${NETTYPE}999 && + error "client mount with '-o network' option should be refused" + + # on client, reconfigure LNet and turn LNet Dynamic Discovery off + $LNETCTL net del --net ${NETTYPE}999 && lnetctl lnet unconfigure + lustre_rmmod + modprobe lnet + lnetctl set discovery 0 + modprobe ptlrpc + $LNETCTL lnet configure && $LNETCTL net add --if \ + $($LNETCTL net show --net $net | awk 'BEGIN{inf=0} \ + {if (inf==1) print $2; fi; inf=0} /interfaces/{inf=1}') \ + --net ${NETTYPE}999 || + error "unable to configure NID ${NETTYPE}999 on client" + + # mount client with -o network=${NETTYPE}999 option + mount_client $MOUNT ${MOUNT_OPTS},network=${NETTYPE}999 || + error "unable to remount client" + + # restore MGSNID + MGSNID=$mgsnid_orig + + # check export on MGS + do_facet mgs "lctl get_param -n *.MGS*.exports.'$nid'.uuid 2>/dev/null \ + | grep -q -" + [ $? -ne 0 ] || + error "export for $nid on MGS should not exist" + + do_facet mgs \ + "lctl get_param -n *.MGS*.exports.'${addr}@${NETTYPE}999'.uuid \ + 2>/dev/null | grep -q -" + [ $? -eq 0 ] || + error "export for ${addr}@${NETTYPE}999 on MGS should exist" + + # check {mdc,osc} imports + lctl get_param mdc.${FSNAME}-*.import | grep current_connection | + grep -q ${NETTYPE}999 + [ $? -eq 0 ] || + error "import for mdc should use ${addr}@${NETTYPE}999" + lctl get_param osc.${FSNAME}-*.import | grep current_connection | + grep -q ${NETTYPE}999 + [ $? -eq 0 ] || + error "import for osc should use ${addr}@${NETTYPE}999" +} +run_test 31 "client mount option '-o network'" + log "cleanup: ======================================================" sec_unsetup() { -- 1.8.3.1