Re: [PATCH] mount.cifs: add support for IPv6 addresses in brackets V2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 22 Apr 2013 10:21:13 -0400
Scott Lovenberg <scott.lovenberg@xxxxxxxxx> wrote:

> On Mon, Apr 15, 2013 at 9:29 PM, <scott.lovenberg@xxxxxxxxx> wrote:
> >
> > From: Scott Lovenberg <scott.lovenberg@xxxxxxxxx>
> >
> > This is a respin of the last patch that returns EX_USAGE rather than OPT_ERROR as per Jeff's suggestion.
> >
> > Signed-off-by: Scott Lovenberg <scott.lovenberg@xxxxxxxxx>
> > ---
> >  AUTHORS      |    1 +
> >  mount.cifs.c |   62 ++++++++++++++++++++++++++++++++++++++++++----------------
> >  2 files changed, 46 insertions(+), 17 deletions(-)
> >
> > diff --git a/AUTHORS b/AUTHORS
> > index 2807079..081c2fe 100644
> > --- a/AUTHORS
> > +++ b/AUTHORS
> > @@ -5,5 +5,6 @@ Shirish Pargaonkar <shirishpargaonkar@xxxxxxxxx>
> >  Suresh Jayaraman <sjayaraman@xxxxxxx>
> >  Pavel Shilovsky <piastry@xxxxxxxxxxx>
> >  Igor Druzhinin <jaxbrigs@xxxxxxxxx>
> > +Scott Lovenberg <scott.lovenberg@xxxxxxxxx>
> >
> >  ...and others.
> > diff --git a/mount.cifs.c b/mount.cifs.c
> > index 3b2b89e..561517b 100644
> > --- a/mount.cifs.c
> > +++ b/mount.cifs.c
> > @@ -751,6 +751,47 @@ static int parse_opt_token(const char *token)
> >         return OPT_ERROR;
> >  }
> >
> > +/*
> > +  Extract an ipv4 or ipv6 address and put it into parsed_info.
> > +  Returns 0 on success.
> > +*/
> > +static int parse_ip(char *value, struct parsed_mount_info *parsed_info)
> > +{
> > +       char *closingBracket = NULL;
> > +
> > +       if (!value || !*value) {
> > +               fprintf(stderr, "target ip address argument missing\n");
> > +               return EX_USAGE;
> > +       }
> > +
> > +       /* check for ipv6 in brackets */
> > +       if (value[0] == '[') {
> > +               value++;
> > +               /* temporarily null the closing bracket */
> > +               closingBracket = strchr(value, ']');
> > +               if (closingBracket)
> > +                       *closingBracket = '\0';
> > +       }
> > +
> > +       /* check length of address */
> > +       if (strnlen(value, MAX_ADDRESS_LEN + 1) > MAX_ADDRESS_LEN) {
> > +               fprintf(stderr, "ip address too long\n");
> > +               if (closingBracket)
> > +                       *closingBracket = ']';
> > +               return EX_USAGE;
> > +       }
> > +
> > +       strcpy(parsed_info->addrlist, value);
> > +       if (parsed_info->verboseflag)
> > +               fprintf(stderr, "ip address %s override specified\n", value);
> > +
> > +       /* put back closing bracket */
> > +       if (closingBracket)
> > +               *closingBracket = ']';
> > +
> > +       return 0;
> > +}
> > +
> >  static int
> >  parse_options(const char *data, struct parsed_mount_info *parsed_info)
> >  {
> > @@ -861,23 +902,10 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info)
> >                         break;
> >
> >                 case OPT_IP:
> > -                       if (!value || !*value) {
> > -                               fprintf(stderr,
> > -                                       "target ip address argument missing\n");
> > -                       } else if (strnlen(value, MAX_ADDRESS_LEN) <=
> > -                               MAX_ADDRESS_LEN) {
> > -                               strcpy(parsed_info->addrlist, value);
> > -                               if (parsed_info->verboseflag)
> > -                                       fprintf(stderr,
> > -                                               "ip address %s override specified\n",
> > -                                               value);
> > -                               goto nocopy;
> > -                       } else {
> > -                               fprintf(stderr, "ip address too long\n");
> > -                               return EX_USAGE;
> > -
> > -                       }
> > -                       break;
> > +                       rc = parse_ip(value, parsed_info);
> > +                       if (rc)
> > +                               return rc;
> > +                       goto nocopy;
> >
> >                 /* unc || target || path */
> >                 case OPT_UNC:
> > --
> > 1.7.10.4
> >
> 
> 
> Ping.
> Any comments?
> 

I guess I don't quite understand why we need this patch. For NFS it's
pretty clear that we would since ':' has always served as the delimiter
between the hostname and the pathname.

For CIFS, not so much... IPv6 addresses typically don't have '/' or '\\'
characters in them, so why do we need to wrap them in []?

Note that this syntax doesn't follow what Windows does either, AFAIK.
There, you need something like this since UNC paths can't contain ':'
characters (and maybe also '%'):

    http://www.samba.org/~idra/code/nss-ipv6literal/README.html

...we have no such restriction under Linux though.

-- 
Jeff Layton <jlayton@xxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux