diff options
-rw-r--r-- | fs/cifs/cifsproto.h | 4 | ||||
-rw-r--r-- | fs/cifs/connect.c | 12 | ||||
-rw-r--r-- | fs/cifs/dns_resolve.c | 2 | ||||
-rw-r--r-- | fs/cifs/netmisc.c | 23 |
4 files changed, 31 insertions, 10 deletions
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index fb6318b81509..2eaebbd31132 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -86,7 +86,9 @@ extern unsigned int smbCalcSize(struct smb_hdr *ptr); | |||
86 | extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr); | 86 | extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr); |
87 | extern int decode_negTokenInit(unsigned char *security_blob, int length, | 87 | extern int decode_negTokenInit(unsigned char *security_blob, int length, |
88 | struct TCP_Server_Info *server); | 88 | struct TCP_Server_Info *server); |
89 | extern int cifs_convert_address(char *src, void *dst); | 89 | extern int cifs_convert_address(struct sockaddr *dst, char *src); |
90 | extern int cifs_fill_sockaddr(struct sockaddr *dst, char *src, | ||
91 | unsigned short int port); | ||
90 | extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr); | 92 | extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr); |
91 | extern void header_assemble(struct smb_hdr *, char /* command */ , | 93 | extern void header_assemble(struct smb_hdr *, char /* command */ , |
92 | const struct cifsTconInfo *, int /* length of | 94 | const struct cifsTconInfo *, int /* length of |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 90354e39e565..eca86256709b 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -1382,7 +1382,7 @@ cifs_parse_mount_options(char *options, const char *devname, | |||
1382 | } | 1382 | } |
1383 | 1383 | ||
1384 | static struct TCP_Server_Info * | 1384 | static struct TCP_Server_Info * |
1385 | cifs_find_tcp_session(struct sockaddr_storage *addr, unsigned short int port) | 1385 | cifs_find_tcp_session(struct sockaddr_storage *addr) |
1386 | { | 1386 | { |
1387 | struct list_head *tmp; | 1387 | struct list_head *tmp; |
1388 | struct TCP_Server_Info *server; | 1388 | struct TCP_Server_Info *server; |
@@ -1406,7 +1406,6 @@ cifs_find_tcp_session(struct sockaddr_storage *addr, unsigned short int port) | |||
1406 | case AF_INET: | 1406 | case AF_INET: |
1407 | if (addr4->sin_addr.s_addr == | 1407 | if (addr4->sin_addr.s_addr == |
1408 | server->addr.sockAddr.sin_addr.s_addr) { | 1408 | server->addr.sockAddr.sin_addr.s_addr) { |
1409 | addr4->sin_port = htons(port); | ||
1410 | /* user overrode default port? */ | 1409 | /* user overrode default port? */ |
1411 | if (addr4->sin_port) { | 1410 | if (addr4->sin_port) { |
1412 | if (addr4->sin_port != | 1411 | if (addr4->sin_port != |
@@ -1422,7 +1421,6 @@ cifs_find_tcp_session(struct sockaddr_storage *addr, unsigned short int port) | |||
1422 | &server->addr.sockAddr6.sin6_addr) && | 1421 | &server->addr.sockAddr6.sin6_addr) && |
1423 | (addr6->sin6_scope_id == | 1422 | (addr6->sin6_scope_id == |
1424 | server->addr.sockAddr6.sin6_scope_id)) { | 1423 | server->addr.sockAddr6.sin6_scope_id)) { |
1425 | addr6->sin6_port = htons(port); | ||
1426 | /* user overrode default port? */ | 1424 | /* user overrode default port? */ |
1427 | if (addr6->sin6_port) { | 1425 | if (addr6->sin6_port) { |
1428 | if (addr6->sin6_port != | 1426 | if (addr6->sin6_port != |
@@ -1482,7 +1480,9 @@ cifs_get_tcp_session(struct smb_vol *volume_info) | |||
1482 | cFYI(1, "UNC: %s ip: %s", volume_info->UNC, volume_info->UNCip); | 1480 | cFYI(1, "UNC: %s ip: %s", volume_info->UNC, volume_info->UNCip); |
1483 | 1481 | ||
1484 | if (volume_info->UNCip && volume_info->UNC) { | 1482 | if (volume_info->UNCip && volume_info->UNC) { |
1485 | rc = cifs_convert_address(volume_info->UNCip, &addr); | 1483 | rc = cifs_fill_sockaddr((struct sockaddr *)&addr, |
1484 | volume_info->UNCip, | ||
1485 | volume_info->port); | ||
1486 | if (!rc) { | 1486 | if (!rc) { |
1487 | /* we failed translating address */ | 1487 | /* we failed translating address */ |
1488 | rc = -EINVAL; | 1488 | rc = -EINVAL; |
@@ -1502,7 +1502,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) | |||
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | /* see if we already have a matching tcp_ses */ | 1504 | /* see if we already have a matching tcp_ses */ |
1505 | tcp_ses = cifs_find_tcp_session(&addr, volume_info->port); | 1505 | tcp_ses = cifs_find_tcp_session(&addr); |
1506 | if (tcp_ses) | 1506 | if (tcp_ses) |
1507 | return tcp_ses; | 1507 | return tcp_ses; |
1508 | 1508 | ||
@@ -1546,12 +1546,10 @@ cifs_get_tcp_session(struct smb_vol *volume_info) | |||
1546 | cFYI(1, "attempting ipv6 connect"); | 1546 | cFYI(1, "attempting ipv6 connect"); |
1547 | /* BB should we allow ipv6 on port 139? */ | 1547 | /* BB should we allow ipv6 on port 139? */ |
1548 | /* other OS never observed in Wild doing 139 with v6 */ | 1548 | /* other OS never observed in Wild doing 139 with v6 */ |
1549 | sin_server6->sin6_port = htons(volume_info->port); | ||
1550 | memcpy(&tcp_ses->addr.sockAddr6, sin_server6, | 1549 | memcpy(&tcp_ses->addr.sockAddr6, sin_server6, |
1551 | sizeof(struct sockaddr_in6)); | 1550 | sizeof(struct sockaddr_in6)); |
1552 | rc = ipv6_connect(tcp_ses); | 1551 | rc = ipv6_connect(tcp_ses); |
1553 | } else { | 1552 | } else { |
1554 | sin_server->sin_port = htons(volume_info->port); | ||
1555 | memcpy(&tcp_ses->addr.sockAddr, sin_server, | 1553 | memcpy(&tcp_ses->addr.sockAddr, sin_server, |
1556 | sizeof(struct sockaddr_in)); | 1554 | sizeof(struct sockaddr_in)); |
1557 | rc = ipv4_connect(tcp_ses); | 1555 | rc = ipv4_connect(tcp_ses); |
diff --git a/fs/cifs/dns_resolve.c b/fs/cifs/dns_resolve.c index 853a968e82d7..3ad7f4300c45 100644 --- a/fs/cifs/dns_resolve.c +++ b/fs/cifs/dns_resolve.c | |||
@@ -44,7 +44,7 @@ is_ip(char *name) | |||
44 | { | 44 | { |
45 | struct sockaddr_storage ss; | 45 | struct sockaddr_storage ss; |
46 | 46 | ||
47 | return cifs_convert_address(name, &ss); | 47 | return cifs_convert_address((struct sockaddr *)&ss, name); |
48 | } | 48 | } |
49 | 49 | ||
50 | static int | 50 | static int |
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index d35d52889cb5..3489468d070b 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c | |||
@@ -164,7 +164,7 @@ cifs_inet_pton(const int address_family, const char *cp, void *dst) | |||
164 | * Returns 0 on failure. | 164 | * Returns 0 on failure. |
165 | */ | 165 | */ |
166 | int | 166 | int |
167 | cifs_convert_address(char *src, void *dst) | 167 | cifs_convert_address(struct sockaddr *dst, char *src) |
168 | { | 168 | { |
169 | int rc; | 169 | int rc; |
170 | char *pct, *endp; | 170 | char *pct, *endp; |
@@ -201,6 +201,27 @@ cifs_convert_address(char *src, void *dst) | |||
201 | return rc; | 201 | return rc; |
202 | } | 202 | } |
203 | 203 | ||
204 | int | ||
205 | cifs_fill_sockaddr(struct sockaddr *dst, char *src, | ||
206 | const unsigned short int port) | ||
207 | { | ||
208 | if (!cifs_convert_address(dst, src)) | ||
209 | return 0; | ||
210 | |||
211 | switch (dst->sa_family) { | ||
212 | case AF_INET: | ||
213 | ((struct sockaddr_in *)dst)->sin_port = htons(port); | ||
214 | break; | ||
215 | case AF_INET6: | ||
216 | ((struct sockaddr_in6 *)dst)->sin6_port = htons(port); | ||
217 | break; | ||
218 | default: | ||
219 | return 0; | ||
220 | } | ||
221 | |||
222 | return 1; | ||
223 | } | ||
224 | |||
204 | /***************************************************************************** | 225 | /***************************************************************************** |
205 | convert a NT status code to a dos class/code | 226 | convert a NT status code to a dos class/code |
206 | *****************************************************************************/ | 227 | *****************************************************************************/ |