From: Steve French Date: Wed, 25 Apr 2007 11:59:10 +0000 (+0000) Subject: [CIFS] Add IPv6 support X-Git-Tag: v2.6.22-rc1~1010^2~8 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5858ae44e289ac6c809af3fe81b9a6ed41914d41;p=linux-2.6 [CIFS] Add IPv6 support IPv6 support was started a few years ago in the cifs client, but lacked a kernel helper function for parsing the ascii form of the ipv6 address. Now that that is added (and now IPv6 is the default that some OS use now) it was fairly easy to finish the cifs ipv6 support. This requires that CIFS_EXPERIMENTAL be enabled and (at least until the mount.cifs module is modified to use a new ipv6 friendly call instead of gethostbyname) and the ipv6 address be passed on the mount as "ip=" mount option. Thanks Signed-off-by: Steve French --- diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES index 713fec6691..301631cac7 100644 --- a/fs/cifs/CHANGES +++ b/fs/cifs/CHANGES @@ -1,4 +1,10 @@ -Verison 1.48 +Version 1.49 +------------ +IPv6 support. Enable ipv6 addresses to be passed on mount (put the ipv6 +address after the "ip=" mount option, at least until mount.cifs is fixed to +handle DNS host to ipv6 name translation). + +Version 1.48 ------------ Fix mtime bouncing around from local idea of last write times to remote time. Fix hang (in i_size_read) when simultaneous size update of same remote file diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 9e41f8ea5f..c139fbd24b 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1790,11 +1790,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr, NULL /* no ipv6 addr */, volume_info.username, &srvTcp); - else if(address_type == AF_INET6) + else if(address_type == AF_INET6) { + cFYI(1,("looking for ipv6 address")); existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */, &sin_server6.sin6_addr, volume_info.username, &srvTcp); - else { + } else { kfree(volume_info.UNC); kfree(volume_info.password); kfree(volume_info.prepath); @@ -1810,12 +1811,18 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, sin_server.sin_port = htons(volume_info.port); else sin_server.sin_port = 0; - rc = ipv4_connect(&sin_server,&csocket, + if (address_type == AF_INET6) { + cFYI(1,("attempting ipv6 connect")); + /* BB should we allow ipv6 on port 139? */ + /* other OS never observed in Wild doing 139 with v6 */ + rc = ipv6_connect(&sin_server6,&csocket); + } else + rc = ipv4_connect(&sin_server,&csocket, volume_info.source_rfc1001_name, volume_info.target_rfc1001_name); if (rc < 0) { cERROR(1, - ("Error connecting to IPv4 socket. Aborting operation")); + ("Error connecting to IPv4 socket. Aborting operation")); if(csocket != NULL) sock_release(csocket); kfree(volume_info.UNC); diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index 992e80edc7..53e304d595 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c @@ -30,6 +30,9 @@ #include #include #include +#ifdef CONFIG_CIFS_EXPERIMENTAL +#include +#endif #include "cifsfs.h" #include "cifspdu.h" #include "cifsglob.h" @@ -129,11 +132,27 @@ static const struct smb_to_posix_error mapping_table_ERRHRD[] = { /* Convert string containing dotted ip address to binary form */ /* returns 0 if invalid address */ -/* BB add address family, change rc to status flag and return union or for ipv6 */ -/* will need parent to call something like inet_pton to convert ipv6 address BB */ int cifs_inet_pton(int address_family, char *cp,void *dst) { +#ifdef CONFIG_CIFS_EXPERIMENTAL + int ret = 0; + + /* calculate length by finding first slash or NULL */ + /* BB Should we convert '/' slash to '\' here since it seems already done + before this */ + if( address_family == AF_INET ){ + ret = in4_pton(cp, -1 /* len */, dst , '\\', NULL); + } else if( address_family == AF_INET6 ){ + ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL); + } +#ifdef CONFIG_CIFS_DEBUG2 + cFYI(1,("address conversion returned %d for %s", ret, cp)); +#endif + if (ret > 0) + ret = 1; + return ret; +#else int value; int digit; int i; @@ -192,6 +211,7 @@ cifs_inet_pton(int address_family, char *cp,void *dst) *((__be32 *)dst) = *((__be32 *) bytes) | htonl(value); return 1; /* success */ +#endif /* EXPERIMENTAL */ } /*****************************************************************************