From 0e75c988f02b4fe36a99d34e5039d61c0ab1b64f Mon Sep 17 00:00:00 2001 From: Richard Wareing Date: Thu, 5 Mar 2015 21:16:40 -0800 Subject: gluster: IPv6 single stack support Summary: - This diff changes all locations in the code to prefer inet6 family instead of inet. This will allow change GlusterFS to operate via IPv6 instead of IPv4 for all internal operations while still being able to serve (FUSE or NFS) clients via IPv4. - The changes apply to NFS as well. - This diff ports D1892990, D1897341 & D1896522 to the 3.8 branch. Test Plan: Prove tests! Reviewers: dph, rwareing Signed-off-by: Shreyas Siravara Change-Id: I34fdaaeb33c194782255625e00616faf75d60c33 Reviewed-on: http://review.gluster.org/16059 Reviewed-by: Shreyas Siravara Tested-by: Shreyas Siravara Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- tests/basic/accept-v6v4.t | 122 ++++++++++++++++++++++++++++++++++++++++++ tests/basic/exports_parsing.t | 15 +++++- tests/basic/mount-nfs-auth.t | 12 +++++ 3 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 tests/basic/accept-v6v4.t (limited to 'tests/basic') diff --git a/tests/basic/accept-v6v4.t b/tests/basic/accept-v6v4.t new file mode 100644 index 00000000000..7128c12c6be --- /dev/null +++ b/tests/basic/accept-v6v4.t @@ -0,0 +1,122 @@ +#!/bin/bash + +. $(dirname $0)/../nfs.rc + +# +# This test ensures that GlusterFS provides NFS, Mount and its Management daemon +# over both IPv4 and IPv6. It uses netcat to check the services running on both +# IPv4 & IPv6 addresses as well as a mount to test that mount & nfs work. +# + +IPV4_SUPPORT=false +IPV6_SUPPORT=false + +host $HOSTNAME | grep -q "has address" && IPV4_SUPPORT=true +host $HOSTNAME | grep -q "has IPv6 address" && IPV6_SUPPORT=true + +. $(dirname $0)/../include.rc + +cleanup; + +mkdir -p $B0/b{0,1,2} + +# make sure no registered rpcbind services are running +service rpcbind restart + +TEST glusterd +TEST pidof glusterd + +TEST $CLI vol create $V0 replica 3 $H0:$B0/b0 $H0:$B0/b1 $H0:$B0/b2 + +TEST $CLI vol set $V0 cluster.self-heal-daemon off +TEST $CLI vol set $V0 nfs.disable off +TEST $CLI vol set $V0 cluster.choose-local off +TEST $CLI vol start $V0 + +MOUNTD_PORT=38465 +MGMTD_PORT=24007 +NFSD_PORT=2049 + +function check_ip_port { + ip=$1 + port=$2 + type=$3 + + nc_flags="" + if [ "$type" == "v6" ] && [ "$ip" == "NONE" ]; then + echo "Y" + return + else + nc_flags="-6" + fi + + if [ "$type" == "v4" ] && [ "$ip" == "NONE" ]; then + echo "Y" + return + fi + + if exec 3<>/dev/tcp/$ip/$port; then + echo "Y" + else + echo "N" + fi +} + +function check_nfs { + ip=$1 + type=$2 + + if [ "$ip" == "NONE" ]; then + echo "Y" + return + fi + + if [ "$type" == "v6" ]; then + addr="[$ip]" + else + addr="$ip" + fi + + if mount_nfs $addr:/$V0 $N0; then + umount_nfs $N0 + echo "Y" + else + echo "N" + fi +} + +if [ ! $IPV4_SUPPORT ] && [ ! $IPV6_SUPPORT ]; then + exit 1 +fi + +# Get the V4 & V6 addresses of this host +if $IPV4_SUPPORT; then + V4=$(host $HOSTNAME | head -n1 | awk -F ' ' '{print $4}') +else + V4="NONE" +fi + +if $IPV6_SUPPORT; then + V6=$(host $HOSTNAME | tail -n1 | awk -F ' ' '{print $5}') +else + V6="NONE" +fi + +# First check the management daemon +EXPECT "Y" check_ip_port $V6 $MGMTD_PORT "v6" +EXPECT "Y" check_ip_port $V4 $MGMTD_PORT "v4" + +# Give the MOUNT/NFS Daemon some time to start up +sleep 4 + +EXPECT "Y" check_ip_port $V4 $MOUNTD_PORT "v6" +EXPECT "Y" check_ip_port $V6 $MOUNTD_PORT "v4" + +EXPECT "Y" check_ip_port $V4 $NFSD_PORT "v6" +EXPECT "Y" check_ip_port $V6 $NFSD_PORT "v4" + +# Mount the file system +EXPECT "Y" check_nfs $V6 "v6" +EXPECT "Y" check_nfs $V4 "v4" + +cleanup; diff --git a/tests/basic/exports_parsing.t b/tests/basic/exports_parsing.t index fdaf9c2822e..da88bbcb2cc 100644 --- a/tests/basic/exports_parsing.t +++ b/tests/basic/exports_parsing.t @@ -32,7 +32,20 @@ function test_bad_opt () glusterfsd --print-exports $1 2>&1 | sed -n 1p } -EXPECT_KEYWORD "/test @test(rw,anonuid=0,sec=sys,) 10.35.11.31(rw,anonuid=0,sec=sys,)" test_good_file $EXP_FILES/exports +function check_export_line() { + if [ "$1" == "$2" ]; then + echo "Y" + else + echo "N" + fi + return +} + +export_result=$(test_good_file $EXP_FILES/exports) +EXPECT "Y" check_export_line '/test @test(rw,anonuid=0,sec=sys,) 10.35.11.31(rw,anonuid=0,sec=sys,) ' "$export_result" + +export_result=$(test_good_file $EXP_FILES/exports-v6) +EXPECT "Y" check_export_line '/test @test(rw,anonuid=0,sec=sys,) 2401:db00:11:1:face:0:3d:0(rw,anonuid=0,sec=sys,) ' "$export_result" EXPECT_KEYWORD "Error parsing netgroups for:" test_bad_line $EXP_FILES/bad_exports EXPECT_KEYWORD "Error parsing netgroups for:" test_long_netgroup $EXP_FILES/bad_exports diff --git a/tests/basic/mount-nfs-auth.t b/tests/basic/mount-nfs-auth.t index 9df5cb45c3b..cd0189788ba 100755 --- a/tests/basic/mount-nfs-auth.t +++ b/tests/basic/mount-nfs-auth.t @@ -15,6 +15,9 @@ TEST glusterd TEST pidof glusterd TEST $CLI volume info +H0IP=$(ip addr show |grep -w inet |grep -v 127.0.0.1|awk '{ print $2 }'| cut -d "/" -f 1) +H0IP6=$(host $HOSTNAME | grep IPv6 | awk '{print $NF}') + # Export variables for allow & deny EXPORT_ALLOW="/$V0 $H0(sec=sys,rw,anonuid=0) @ngtop(sec=sys,rw,anonuid=0)" EXPORT_ALLOW_SLASH="/$V0/ $H0(sec=sys,rw,anonuid=0) @ngtop(sec=sys,rw,anonuid=0)" @@ -37,6 +40,10 @@ function build_dirs () { mkdir -p $B0/b{0,1,2}/L1/L2/L3 } +function export_allow_this_host_ipv6 () { + printf "$EXPORT_ALLOW6\n" > /var/lib/glusterd/nfs/exports +} + function export_allow_this_host () { printf "$EXPORT_ALLOW\n" > ${NFSDIR}/exports } @@ -186,6 +193,11 @@ EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available ## Mount NFS EXPECT "Y" check_mount_success $V0 +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" umount_nfs $N0 + +## Mount NFS using the IPv6 export +export_allow_this_host_ipv6 +EXPECT "Y" check_mount_success $V0 ## Disallow host TEST export_deny_this_host -- cgit