diff options
author | Jeff Layton <jlayton@redhat.com> | 2008-12-01 18:42:33 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2008-12-25 21:29:10 -0500 |
commit | d5c5605c27c92dac6de1a7a658af5b030847f949 (patch) | |
tree | 598d35bcf12439562f075ca7c92ba7a69becc790 /fs/cifs/connect.c | |
parent | bcf4b1063db246a90b9e09e0556f635d632eef36 (diff) |
cifs: make ipv6_connect take a TCP_Server_Info arg
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 103 |
1 files changed, 50 insertions, 53 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index a36f4bd5a764..d6a3c1c8a6f8 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -102,19 +102,16 @@ struct smb_vol { | |||
102 | }; | 102 | }; |
103 | 103 | ||
104 | static int ipv4_connect(struct TCP_Server_Info *server); | 104 | static int ipv4_connect(struct TCP_Server_Info *server); |
105 | static int ipv6_connect(struct sockaddr_in6 *psin_server, | 105 | static int ipv6_connect(struct TCP_Server_Info *server); |
106 | struct socket **csocket, bool noblocksnd); | ||
107 | |||
108 | |||
109 | /* | ||
110 | * cifs tcp session reconnection | ||
111 | * | ||
112 | * mark tcp session as reconnecting so temporarily locked | ||
113 | * mark all smb sessions as reconnecting for tcp session | ||
114 | * reconnect tcp session | ||
115 | * wake up waiters on reconnection? - (not needed currently) | ||
116 | */ | ||
117 | 106 | ||
107 | /* | ||
108 | * cifs tcp session reconnection | ||
109 | * | ||
110 | * mark tcp session as reconnecting so temporarily locked | ||
111 | * mark all smb sessions as reconnecting for tcp session | ||
112 | * reconnect tcp session | ||
113 | * wake up waiters on reconnection? - (not needed currently) | ||
114 | */ | ||
118 | static int | 115 | static int |
119 | cifs_reconnect(struct TCP_Server_Info *server) | 116 | cifs_reconnect(struct TCP_Server_Info *server) |
120 | { | 117 | { |
@@ -183,8 +180,7 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
183 | (server->tcpStatus != CifsGood)) { | 180 | (server->tcpStatus != CifsGood)) { |
184 | try_to_freeze(); | 181 | try_to_freeze(); |
185 | if (server->addr.sockAddr6.sin6_family == AF_INET6) | 182 | if (server->addr.sockAddr6.sin6_family == AF_INET6) |
186 | rc = ipv6_connect(&server->addr.sockAddr6, | 183 | rc = ipv6_connect(server); |
187 | &server->ssocket, server->noautotune); | ||
188 | else | 184 | else |
189 | rc = ipv4_connect(server); | 185 | rc = ipv4_connect(server); |
190 | if (rc) { | 186 | if (rc) { |
@@ -1501,8 +1497,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) | |||
1501 | memcpy(&tcp_ses->addr.sockAddr6, sin_server6, | 1497 | memcpy(&tcp_ses->addr.sockAddr6, sin_server6, |
1502 | sizeof(struct sockaddr_in6)); | 1498 | sizeof(struct sockaddr_in6)); |
1503 | sin_server6->sin6_port = htons(volume_info->port); | 1499 | sin_server6->sin6_port = htons(volume_info->port); |
1504 | rc = ipv6_connect(sin_server6, &tcp_ses->ssocket, | 1500 | rc = ipv6_connect(tcp_ses); |
1505 | volume_info->noblocksnd); | ||
1506 | } else { | 1501 | } else { |
1507 | memcpy(&tcp_ses->addr.sockAddr, sin_server, | 1502 | memcpy(&tcp_ses->addr.sockAddr, sin_server, |
1508 | sizeof(struct sockaddr_in)); | 1503 | sizeof(struct sockaddr_in)); |
@@ -1875,79 +1870,81 @@ ipv4_connect(struct TCP_Server_Info *server) | |||
1875 | } | 1870 | } |
1876 | 1871 | ||
1877 | static int | 1872 | static int |
1878 | ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket, | 1873 | ipv6_connect(struct TCP_Server_Info *server) |
1879 | bool noblocksnd) | ||
1880 | { | 1874 | { |
1881 | int rc = 0; | 1875 | int rc = 0; |
1882 | int connected = 0; | 1876 | bool connected = false; |
1883 | __be16 orig_port = 0; | 1877 | __be16 orig_port = 0; |
1878 | struct socket *socket = server->ssocket; | ||
1884 | 1879 | ||
1885 | if (*csocket == NULL) { | 1880 | if (socket == NULL) { |
1886 | rc = sock_create_kern(PF_INET6, SOCK_STREAM, | 1881 | rc = sock_create_kern(PF_INET6, SOCK_STREAM, |
1887 | IPPROTO_TCP, csocket); | 1882 | IPPROTO_TCP, &socket); |
1888 | if (rc < 0) { | 1883 | if (rc < 0) { |
1889 | cERROR(1, ("Error %d creating ipv6 socket", rc)); | 1884 | cERROR(1, ("Error %d creating ipv6 socket", rc)); |
1890 | *csocket = NULL; | 1885 | socket = NULL; |
1891 | return rc; | 1886 | return rc; |
1892 | } else { | ||
1893 | /* BB other socket options to set KEEPALIVE, NODELAY? */ | ||
1894 | cFYI(1, ("ipv6 Socket created")); | ||
1895 | (*csocket)->sk->sk_allocation = GFP_NOFS; | ||
1896 | cifs_reclassify_socket6(*csocket); | ||
1897 | } | 1887 | } |
1898 | } | ||
1899 | 1888 | ||
1900 | psin_server->sin6_family = AF_INET6; | 1889 | /* BB other socket options to set KEEPALIVE, NODELAY? */ |
1890 | cFYI(1, ("ipv6 Socket created")); | ||
1891 | server->ssocket = socket; | ||
1892 | socket->sk->sk_allocation = GFP_NOFS; | ||
1893 | cifs_reclassify_socket6(socket); | ||
1894 | } | ||
1901 | 1895 | ||
1902 | if (psin_server->sin6_port) { /* user overrode default port */ | 1896 | /* user overrode default port */ |
1903 | rc = (*csocket)->ops->connect(*csocket, | 1897 | if (server->addr.sockAddr6.sin6_port) { |
1904 | (struct sockaddr *) psin_server, | 1898 | rc = socket->ops->connect(socket, |
1899 | (struct sockaddr *) &server->addr.sockAddr6, | ||
1905 | sizeof(struct sockaddr_in6), 0); | 1900 | sizeof(struct sockaddr_in6), 0); |
1906 | if (rc >= 0) | 1901 | if (rc >= 0) |
1907 | connected = 1; | 1902 | connected = true; |
1908 | } | 1903 | } |
1909 | 1904 | ||
1910 | if (!connected) { | 1905 | if (!connected) { |
1911 | /* save original port so we can retry user specified port | 1906 | /* save original port so we can retry user specified port |
1912 | later if fall back ports fail this time */ | 1907 | later if fall back ports fail this time */ |
1913 | 1908 | ||
1914 | orig_port = psin_server->sin6_port; | 1909 | orig_port = server->addr.sockAddr6.sin6_port; |
1915 | /* do not retry on the same port we just failed on */ | 1910 | /* do not retry on the same port we just failed on */ |
1916 | if (psin_server->sin6_port != htons(CIFS_PORT)) { | 1911 | if (server->addr.sockAddr6.sin6_port != htons(CIFS_PORT)) { |
1917 | psin_server->sin6_port = htons(CIFS_PORT); | 1912 | server->addr.sockAddr6.sin6_port = htons(CIFS_PORT); |
1918 | 1913 | rc = socket->ops->connect(socket, (struct sockaddr *) | |
1919 | rc = (*csocket)->ops->connect(*csocket, | 1914 | &server->addr.sockAddr6, |
1920 | (struct sockaddr *) psin_server, | ||
1921 | sizeof(struct sockaddr_in6), 0); | 1915 | sizeof(struct sockaddr_in6), 0); |
1922 | if (rc >= 0) | 1916 | if (rc >= 0) |
1923 | connected = 1; | 1917 | connected = true; |
1924 | } | 1918 | } |
1925 | } | 1919 | } |
1926 | if (!connected) { | 1920 | if (!connected) { |
1927 | psin_server->sin6_port = htons(RFC1001_PORT); | 1921 | server->addr.sockAddr6.sin6_port = htons(RFC1001_PORT); |
1928 | rc = (*csocket)->ops->connect(*csocket, (struct sockaddr *) | 1922 | rc = socket->ops->connect(socket, (struct sockaddr *) |
1929 | psin_server, sizeof(struct sockaddr_in6), 0); | 1923 | &server->addr.sockAddr6, |
1924 | sizeof(struct sockaddr_in6), 0); | ||
1930 | if (rc >= 0) | 1925 | if (rc >= 0) |
1931 | connected = 1; | 1926 | connected = true; |
1932 | } | 1927 | } |
1933 | 1928 | ||
1934 | /* give up here - unless we want to retry on different | 1929 | /* give up here - unless we want to retry on different |
1935 | protocol families some day */ | 1930 | protocol families some day */ |
1936 | if (!connected) { | 1931 | if (!connected) { |
1937 | if (orig_port) | 1932 | if (orig_port) |
1938 | psin_server->sin6_port = orig_port; | 1933 | server->addr.sockAddr6.sin6_port = orig_port; |
1939 | cFYI(1, ("Error %d connecting to server via ipv6", rc)); | 1934 | cFYI(1, ("Error %d connecting to server via ipv6", rc)); |
1940 | sock_release(*csocket); | 1935 | sock_release(socket); |
1941 | *csocket = NULL; | 1936 | server->ssocket = NULL; |
1942 | return rc; | 1937 | return rc; |
1943 | } | 1938 | } |
1944 | /* Eventually check for other socket options to change from | ||
1945 | the default. sock_setsockopt not used because it expects | ||
1946 | user space buffer */ | ||
1947 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; | ||
1948 | if (!noblocksnd) | ||
1949 | (*csocket)->sk->sk_sndtimeo = 3 * HZ; | ||
1950 | 1939 | ||
1940 | /* | ||
1941 | * Eventually check for other socket options to change from | ||
1942 | * the default. sock_setsockopt not used because it expects | ||
1943 | * user space buffer | ||
1944 | */ | ||
1945 | socket->sk->sk_rcvtimeo = 7 * HZ; | ||
1946 | socket->sk->sk_sndtimeo = 3 * HZ; | ||
1947 | server->ssocket = socket; | ||
1951 | 1948 | ||
1952 | return rc; | 1949 | return rc; |
1953 | } | 1950 | } |