diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-05-15 12:20:51 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2012-05-16 21:13:34 -0400 |
commit | 23db65f511e6ee98ad767833f2ec58b0568ba32b (patch) | |
tree | 3e883154e734542aed2ec6e9e77dc22d24e8a54c /fs/cifs/connect.c | |
parent | 5249af32da5330c0bcaf0412a32aa30c5e93e908 (diff) |
cifs: add a smb_version_operations/values structures and a smb_version enum
We need a way to dispatch different operations for different versions.
Behold the smb_version_operations/values structures. For now, those
structures just hold the version enum value and nothing uses them.
Eventually, we'll expand them to cover other operations/values as we
change the callers to dispatch from here.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 4a6baa880506..5ac20fc2c312 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -102,7 +102,7 @@ enum { | |||
102 | Opt_srcaddr, Opt_prefixpath, | 102 | Opt_srcaddr, Opt_prefixpath, |
103 | Opt_iocharset, Opt_sockopt, | 103 | Opt_iocharset, Opt_sockopt, |
104 | Opt_netbiosname, Opt_servern, | 104 | Opt_netbiosname, Opt_servern, |
105 | Opt_ver, Opt_sec, Opt_cache, | 105 | Opt_ver, Opt_vers, Opt_sec, Opt_cache, |
106 | 106 | ||
107 | /* Mount options to be ignored */ | 107 | /* Mount options to be ignored */ |
108 | Opt_ignore, | 108 | Opt_ignore, |
@@ -210,6 +210,7 @@ static const match_table_t cifs_mount_option_tokens = { | |||
210 | { Opt_netbiosname, "netbiosname=%s" }, | 210 | { Opt_netbiosname, "netbiosname=%s" }, |
211 | { Opt_servern, "servern=%s" }, | 211 | { Opt_servern, "servern=%s" }, |
212 | { Opt_ver, "ver=%s" }, | 212 | { Opt_ver, "ver=%s" }, |
213 | { Opt_vers, "vers=%s" }, | ||
213 | { Opt_sec, "sec=%s" }, | 214 | { Opt_sec, "sec=%s" }, |
214 | { Opt_cache, "cache=%s" }, | 215 | { Opt_cache, "cache=%s" }, |
215 | 216 | ||
@@ -275,6 +276,10 @@ static const match_table_t cifs_cacheflavor_tokens = { | |||
275 | { Opt_cache_err, NULL } | 276 | { Opt_cache_err, NULL } |
276 | }; | 277 | }; |
277 | 278 | ||
279 | static const match_table_t cifs_smb_version_tokens = { | ||
280 | { Smb_1, SMB1_VERSION_STRING }, | ||
281 | }; | ||
282 | |||
278 | static int ip_connect(struct TCP_Server_Info *server); | 283 | static int ip_connect(struct TCP_Server_Info *server); |
279 | static int generic_ip_connect(struct TCP_Server_Info *server); | 284 | static int generic_ip_connect(struct TCP_Server_Info *server); |
280 | static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink); | 285 | static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink); |
@@ -1225,6 +1230,23 @@ cifs_parse_cache_flavor(char *value, struct smb_vol *vol) | |||
1225 | } | 1230 | } |
1226 | 1231 | ||
1227 | static int | 1232 | static int |
1233 | cifs_parse_smb_version(char *value, struct smb_vol *vol) | ||
1234 | { | ||
1235 | substring_t args[MAX_OPT_ARGS]; | ||
1236 | |||
1237 | switch (match_token(value, cifs_smb_version_tokens, args)) { | ||
1238 | case Smb_1: | ||
1239 | vol->ops = &smb1_operations; | ||
1240 | vol->vals = &smb1_values; | ||
1241 | break; | ||
1242 | default: | ||
1243 | cERROR(1, "Unknown vers= option specified: %s", value); | ||
1244 | return 1; | ||
1245 | } | ||
1246 | return 0; | ||
1247 | } | ||
1248 | |||
1249 | static int | ||
1228 | cifs_parse_mount_options(const char *mountdata, const char *devname, | 1250 | cifs_parse_mount_options(const char *mountdata, const char *devname, |
1229 | struct smb_vol *vol) | 1251 | struct smb_vol *vol) |
1230 | { | 1252 | { |
@@ -1277,6 +1299,10 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, | |||
1277 | 1299 | ||
1278 | vol->actimeo = CIFS_DEF_ACTIMEO; | 1300 | vol->actimeo = CIFS_DEF_ACTIMEO; |
1279 | 1301 | ||
1302 | /* FIXME: add autonegotiation -- for now, SMB1 is default */ | ||
1303 | vol->ops = &smb1_operations; | ||
1304 | vol->vals = &smb1_values; | ||
1305 | |||
1280 | if (!mountdata) | 1306 | if (!mountdata) |
1281 | goto cifs_parse_mount_err; | 1307 | goto cifs_parse_mount_err; |
1282 | 1308 | ||
@@ -1880,6 +1906,14 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, | |||
1880 | printk(KERN_WARNING "CIFS: Invalid version" | 1906 | printk(KERN_WARNING "CIFS: Invalid version" |
1881 | " specified\n"); | 1907 | " specified\n"); |
1882 | goto cifs_parse_mount_err; | 1908 | goto cifs_parse_mount_err; |
1909 | case Opt_vers: | ||
1910 | string = match_strdup(args); | ||
1911 | if (string == NULL) | ||
1912 | goto out_nomem; | ||
1913 | |||
1914 | if (cifs_parse_smb_version(string, vol) != 0) | ||
1915 | goto cifs_parse_mount_err; | ||
1916 | break; | ||
1883 | case Opt_sec: | 1917 | case Opt_sec: |
1884 | string = match_strdup(args); | 1918 | string = match_strdup(args); |
1885 | if (string == NULL) | 1919 | if (string == NULL) |
@@ -2108,6 +2142,9 @@ match_security(struct TCP_Server_Info *server, struct smb_vol *vol) | |||
2108 | static int match_server(struct TCP_Server_Info *server, struct sockaddr *addr, | 2142 | static int match_server(struct TCP_Server_Info *server, struct sockaddr *addr, |
2109 | struct smb_vol *vol) | 2143 | struct smb_vol *vol) |
2110 | { | 2144 | { |
2145 | if ((server->vals != vol->vals) || (server->ops != vol->ops)) | ||
2146 | return 0; | ||
2147 | |||
2111 | if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) | 2148 | if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) |
2112 | return 0; | 2149 | return 0; |
2113 | 2150 | ||
@@ -2230,6 +2267,8 @@ cifs_get_tcp_session(struct smb_vol *volume_info) | |||
2230 | goto out_err; | 2267 | goto out_err; |
2231 | } | 2268 | } |
2232 | 2269 | ||
2270 | tcp_ses->ops = volume_info->ops; | ||
2271 | tcp_ses->vals = volume_info->vals; | ||
2233 | cifs_set_net_ns(tcp_ses, get_net(current->nsproxy->net_ns)); | 2272 | cifs_set_net_ns(tcp_ses, get_net(current->nsproxy->net_ns)); |
2234 | tcp_ses->hostname = extract_hostname(volume_info->UNC); | 2273 | tcp_ses->hostname = extract_hostname(volume_info->UNC); |
2235 | if (IS_ERR(tcp_ses->hostname)) { | 2274 | if (IS_ERR(tcp_ses->hostname)) { |
@@ -3636,6 +3675,7 @@ cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data, | |||
3636 | if (cifs_parse_mount_options(mount_data, devname, volume_info)) | 3675 | if (cifs_parse_mount_options(mount_data, devname, volume_info)) |
3637 | return -EINVAL; | 3676 | return -EINVAL; |
3638 | 3677 | ||
3678 | |||
3639 | if (volume_info->nullauth) { | 3679 | if (volume_info->nullauth) { |
3640 | cFYI(1, "Anonymous login"); | 3680 | cFYI(1, "Anonymous login"); |
3641 | kfree(volume_info->username); | 3681 | kfree(volume_info->username); |