diff options
author | Jeff Layton <jlayton@redhat.com> | 2008-12-01 15:23:50 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2008-12-25 21:29:09 -0500 |
commit | 8ecaf67a8ea58c8f131ff045475c74e9538d6b7a (patch) | |
tree | 115e941e0c13e633b7cb5fb9c9307c4e108533ad /fs | |
parent | 954d7a1cf12158fed23dd8b0f3f563d5a5c97f28 (diff) |
cifs: account for IPv6 in ses->serverName and clean up netbios name handling
The current code for setting the session serverName is IPv4-specific.
Allow it to be an IPv6 address as well. Use NIP* macros to set the
format.
This also entails increasing the length of the serverName field, so
declare a new macro for RFC1001 name length and use it in the
appropriate places.
Finally, drop the unicode_server_Name field from TCP_Server_Info since
it's not used. We can add it back later if needed, but for now it just
wastes memory.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/cifsglob.h | 11 | ||||
-rw-r--r-- | fs/cifs/connect.c | 38 |
2 files changed, 33 insertions, 16 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 9b002cca6bb7..0fb934d3623b 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -47,7 +47,11 @@ | |||
47 | */ | 47 | */ |
48 | #define CIFS_MAX_REQ 50 | 48 | #define CIFS_MAX_REQ 50 |
49 | 49 | ||
50 | #define SERVER_NAME_LENGTH 15 | 50 | #define RFC1001_NAME_LEN 15 |
51 | #define RFC1001_NAME_LEN_WITH_NULL (RFC1001_NAME_LEN + 1) | ||
52 | |||
53 | /* currently length of NIP6_FMT */ | ||
54 | #define SERVER_NAME_LENGTH 40 | ||
51 | #define SERVER_NAME_LEN_WITH_NULL (SERVER_NAME_LENGTH + 1) | 55 | #define SERVER_NAME_LEN_WITH_NULL (SERVER_NAME_LENGTH + 1) |
52 | 56 | ||
53 | /* used to define string lengths for reversing unicode strings */ | 57 | /* used to define string lengths for reversing unicode strings */ |
@@ -125,8 +129,7 @@ struct TCP_Server_Info { | |||
125 | struct list_head smb_ses_list; | 129 | struct list_head smb_ses_list; |
126 | int srv_count; /* reference counter */ | 130 | int srv_count; /* reference counter */ |
127 | /* 15 character server name + 0x20 16th byte indicating type = srv */ | 131 | /* 15 character server name + 0x20 16th byte indicating type = srv */ |
128 | char server_RFC1001_name[SERVER_NAME_LEN_WITH_NULL]; | 132 | char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL]; |
129 | char unicode_server_Name[SERVER_NAME_LEN_WITH_NULL * 2]; | ||
130 | char *hostname; /* hostname portion of UNC string */ | 133 | char *hostname; /* hostname portion of UNC string */ |
131 | struct socket *ssocket; | 134 | struct socket *ssocket; |
132 | union { | 135 | union { |
@@ -171,7 +174,7 @@ struct TCP_Server_Info { | |||
171 | __u16 CurrentMid; /* multiplex id - rotating counter */ | 174 | __u16 CurrentMid; /* multiplex id - rotating counter */ |
172 | char cryptKey[CIFS_CRYPTO_KEY_SIZE]; | 175 | char cryptKey[CIFS_CRYPTO_KEY_SIZE]; |
173 | /* 16th byte of RFC1001 workstation name is always null */ | 176 | /* 16th byte of RFC1001 workstation name is always null */ |
174 | char workstation_RFC1001_name[SERVER_NAME_LEN_WITH_NULL]; | 177 | char workstation_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL]; |
175 | __u32 sequence_number; /* needed for CIFS PDU signature */ | 178 | __u32 sequence_number; /* needed for CIFS PDU signature */ |
176 | struct mac_key mac_signing_key; | 179 | struct mac_key mac_signing_key; |
177 | char ntlmv2_hash[16]; | 180 | char ntlmv2_hash[16]; |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 61b68a0ee2ff..65c121940060 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -1690,22 +1690,30 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1690 | if (ses_init_buf) { | 1690 | if (ses_init_buf) { |
1691 | ses_init_buf->trailer.session_req.called_len = 32; | 1691 | ses_init_buf->trailer.session_req.called_len = 32; |
1692 | if (target_name && (target_name[0] != 0)) { | 1692 | if (target_name && (target_name[0] != 0)) { |
1693 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, | 1693 | rfc1002mangle(ses_init_buf->trailer. |
1694 | target_name, 16); | 1694 | session_req.called_name, |
1695 | target_name, | ||
1696 | RFC1001_NAME_LEN_WITH_NULL); | ||
1695 | } else { | 1697 | } else { |
1696 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, | 1698 | rfc1002mangle(ses_init_buf->trailer. |
1697 | DEFAULT_CIFS_CALLED_NAME, 16); | 1699 | session_req.called_name, |
1700 | DEFAULT_CIFS_CALLED_NAME, | ||
1701 | RFC1001_NAME_LEN_WITH_NULL); | ||
1698 | } | 1702 | } |
1699 | 1703 | ||
1700 | ses_init_buf->trailer.session_req.calling_len = 32; | 1704 | ses_init_buf->trailer.session_req.calling_len = 32; |
1701 | /* calling name ends in null (byte 16) from old smb | 1705 | /* calling name ends in null (byte 16) from old smb |
1702 | convention. */ | 1706 | convention. */ |
1703 | if (netbios_name && (netbios_name[0] != 0)) { | 1707 | if (netbios_name && (netbios_name[0] != 0)) { |
1704 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, | 1708 | rfc1002mangle(ses_init_buf->trailer. |
1705 | netbios_name, 16); | 1709 | session_req.calling_name, |
1710 | netbios_name, | ||
1711 | RFC1001_NAME_LEN_WITH_NULL); | ||
1706 | } else { | 1712 | } else { |
1707 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, | 1713 | rfc1002mangle(ses_init_buf->trailer. |
1708 | "LINUX_CIFS_CLNT", 16); | 1714 | session_req.calling_name, |
1715 | "LINUX_CIFS_CLNT", | ||
1716 | RFC1001_NAME_LEN_WITH_NULL); | ||
1709 | } | 1717 | } |
1710 | ses_init_buf->trailer.session_req.scope1 = 0; | 1718 | ses_init_buf->trailer.session_req.scope1 = 0; |
1711 | ses_init_buf->trailer.session_req.scope2 = 0; | 1719 | ses_init_buf->trailer.session_req.scope2 = 0; |
@@ -2194,9 +2202,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2194 | } | 2202 | } |
2195 | rc = 0; | 2203 | rc = 0; |
2196 | memcpy(srvTcp->workstation_RFC1001_name, | 2204 | memcpy(srvTcp->workstation_RFC1001_name, |
2197 | volume_info.source_rfc1001_name, 16); | 2205 | volume_info.source_rfc1001_name, |
2206 | RFC1001_NAME_LEN_WITH_NULL); | ||
2198 | memcpy(srvTcp->server_RFC1001_name, | 2207 | memcpy(srvTcp->server_RFC1001_name, |
2199 | volume_info.target_rfc1001_name, 16); | 2208 | volume_info.target_rfc1001_name, |
2209 | RFC1001_NAME_LEN_WITH_NULL); | ||
2200 | srvTcp->sequence_number = 0; | 2210 | srvTcp->sequence_number = 0; |
2201 | INIT_LIST_HEAD(&srvTcp->tcp_ses_list); | 2211 | INIT_LIST_HEAD(&srvTcp->tcp_ses_list); |
2202 | INIT_LIST_HEAD(&srvTcp->smb_ses_list); | 2212 | INIT_LIST_HEAD(&srvTcp->smb_ses_list); |
@@ -2235,8 +2245,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2235 | 2245 | ||
2236 | /* new SMB session uses our srvTcp ref */ | 2246 | /* new SMB session uses our srvTcp ref */ |
2237 | pSesInfo->server = srvTcp; | 2247 | pSesInfo->server = srvTcp; |
2238 | sprintf(pSesInfo->serverName, "%u.%u.%u.%u", | 2248 | if (addr.sa_family == AF_INET6) |
2239 | NIPQUAD(sin_server->sin_addr.s_addr)); | 2249 | sprintf(pSesInfo->serverName, NIP6_FMT, |
2250 | NIP6(sin_server6->sin6_addr)); | ||
2251 | else | ||
2252 | sprintf(pSesInfo->serverName, NIPQUAD_FMT, | ||
2253 | NIPQUAD(sin_server->sin_addr.s_addr)); | ||
2240 | 2254 | ||
2241 | write_lock(&cifs_tcp_ses_lock); | 2255 | write_lock(&cifs_tcp_ses_lock); |
2242 | list_add(&pSesInfo->smb_ses_list, &srvTcp->smb_ses_list); | 2256 | list_add(&pSesInfo->smb_ses_list, &srvTcp->smb_ses_list); |