Skip to contentSkip to conversation

common: Fixes for testing NFS over IPv6

PATCH In review Anna Schumaker 2 participants 2 messages Oct 30, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 common: Fixes for testing NFS over IPv6

When testing NFS over IPv6, the user will set a $TEST_DEV of the form [fe80::42]:/export. The use of square brackets surrounding the IPv6 address is an accepted convention, but grep and awk think that our IPv6 address is actually a regex and tries to evaluate it instead. The result is that xfstests reports our filesystem "is busy or already mounted".

This patch fixes the IPv6 problem by telling awk and grep to treat $TEST_DEV as a fixed string rather than a regex.

---
 common/rc | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
common/rc +8 -4
index 747cf72..9f17564 100644
@@ -809,14 +809,16 @@ _df_device()
 	exit 1
     fi
 
+    # Note that we use "==" here so awk doesn't try to interpret an NFS over
+    # IPv6 server as a regular expression.
     $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
-        match($1,what) && NF==1 {
+        ($1==what) && (NF==1) {
             v=$1
             getline
             print v, $0
             exit
         }
-        match($1,what) {
+        ($1==what) {
             print
             exit
         }
@@ -1132,10 +1134,12 @@ _require_test()
     esac
 
     # mounted?
-    if _mount | grep -q $TEST_DEV
+    # Note that we use -F here so grep doesn't try to interpret an NFS over
+    # IPv6 server as a regular expression.
+    if _mount | grep -F -q $TEST_DEV
     then
         # if it's mounted, make sure its on $TEST_DIR
-        if ! _mount | grep $TEST_DEV | grep -q $TEST_DIR
+        if ! _mount | grep -F $TEST_DEV | grep -q $TEST_DIR
         then
             echo "\$TEST_DEV is mounted but not on \$TEST_DIR - aborting"
             exit 1
Signature · 1 line
2.1.3
#1 lore raw

Hi Anna-

Quoted 2 lines · Anna Schumaker

When testing NFS over IPv6, the user will set a $TEST_DEV of the form [fe80::42]:/export.

Fixing how fstests handles raw IPv6 addresses is a good idea.

However, testing NFS over IPv6 can be done in other ways. The preferred way this is done is by providing a DNS AAAA record for the NFS server (or by fixing up /etc/hosts), and then using “proto=tcp6” or “proto=udp6” when mounting the server.

I just mention that because people shouldn’t get the idea that NFS IPv6 testing can only be done using a raw link-local address.

Could the first line of the patch description be changed to say “When testing NFS by mounting the NFS server with a raw IPv6 address, the user . . .” ?

The rest seems reasonable to me.

Quoted 59 lines

The use of square brackets surrounding the IPv6
address is an accepted convention, but grep and awk think that our IPv6 address is actually a regex and tries to evaluate it instead. The result is that xfstests reports our filesystem "is busy or already mounted".

This patch fixes the IPv6 problem by telling awk and grep to treat $TEST_DEV as a fixed string rather than a regex.

---
common/rc | 12 ++++++++----

1 file changed, 8 insertions(+), 4 deletions(-)
common/rc +8 -4
index 747cf72..9f17564 100644
@@ -809,14 +809,16 @@ _df_device()
 	exit 1
    fi
 
+    # Note that we use "==" here so awk doesn't try to interpret an NFS over
+    # IPv6 server as a regular expression.
    $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
-        match($1,what) && NF==1 {
+        ($1==what) && (NF==1) {
            v=$1
            getline
            print v, $0
            exit
        }
-        match($1,what) {
+        ($1==what) {
            print
            exit
        }
@@ -1132,10 +1134,12 @@ _require_test()
    esac
 
    # mounted?
-    if _mount | grep -q $TEST_DEV
+    # Note that we use -F here so grep doesn't try to interpret an NFS over
+    # IPv6 server as a regular expression.
+    if _mount | grep -F -q $TEST_DEV
    then
        # if it's mounted, make sure its on $TEST_DIR
-        if ! _mount | grep $TEST_DEV | grep -q $TEST_DIR
+        if ! _mount | grep -F $TEST_DEV | grep -q $TEST_DIR
        then
            echo "\$TEST_DEV is mounted but not on \$TEST_DIR - aborting"
            exit 1
Signature · 6 lines
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com