]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
mountd: support IPv6 [] escaping with fsloc hosts
authorWeston Andros Adamson <dros@netapp.com>
Tue, 1 May 2012 18:54:39 +0000 (14:54 -0400)
committerSteve Dickson <steved@redhat.com>
Tue, 1 May 2012 18:55:50 +0000 (14:55 -0400)
mountd uses colons to split fsloc hosts, but this doesn't work with IPv6
addresses (they contain ':').

To fix this, mountd is changed to expect all IPv6 addresses to be escaped
by '[' and ']' so colons that are part of the address may be skipped.
To fix IPv6 referrals, this patch must be used with the nfsd patch that
properly parses escaped IPv6 addresses in fs_location->hosts.

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
utils/mountd/fsloc.c

index 704b7a0860d1701fab07c21f12d94f79a5083029..bc737d191cf8b830ea9d8c748b5a8695e32e87e1 100644 (file)
@@ -120,10 +120,11 @@ static struct servers *parse_list(char **list)
  */
 static struct servers *method_list(char *data)
 {
-       char *copy, *ptr=data;
+       char *copy, *ptr=data, *p;
        char **list;
        int i, listsize;
        struct servers *rv=NULL;
+       bool v6esc = false;
 
        xlog(L_NOTICE, "method_list(%s)", data);
        for (ptr--, listsize=1; ptr; ptr=index(ptr, ':'), listsize++)
@@ -134,9 +135,22 @@ static struct servers *method_list(char *data)
                xlog(L_NOTICE, "converted to %s", copy);
        if (list && copy) {
                ptr = copy;
-               for (i=0; i<listsize; i++) {
-                       list[i] = strsep(&ptr, ":");
+               for (p = ptr, i = 0; *p && i < listsize; p++) {
+                       if (*p == '[')
+                               v6esc = true;
+                       else if (*p == ']')
+                               v6esc = false;
+
+                       if (!v6esc && *p == ':') {
+                               *p = '\0';
+                               if (*ptr)
+                                       list[i++] = ptr;
+                               ptr = p + 1;
+                       }
                }
+               if (*ptr)
+                       list[i++] = ptr;
+               list[i] = NULL;
                rv = parse_list(list);
        }
        free(copy);