diff options
-rw-r--r-- | fs/cifs/Makefile | 2 | ||||
-rw-r--r-- | fs/cifs/cifsfs.c | 1 | ||||
-rw-r--r-- | fs/cifs/cifsglob.h | 19 | ||||
-rw-r--r-- | fs/cifs/connect.c | 42 | ||||
-rw-r--r-- | fs/cifs/smb1ops.c | 27 |
5 files changed, 89 insertions, 2 deletions
diff --git a/fs/cifs/Makefile b/fs/cifs/Makefile index 005d524c3a4a..0fe70258caf0 100644 --- a/fs/cifs/Makefile +++ b/fs/cifs/Makefile | |||
@@ -6,7 +6,7 @@ obj-$(CONFIG_CIFS) += cifs.o | |||
6 | cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \ | 6 | cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \ |
7 | link.o misc.o netmisc.o smbencrypt.o transport.o asn1.o \ | 7 | link.o misc.o netmisc.o smbencrypt.o transport.o asn1.o \ |
8 | cifs_unicode.o nterr.o xattr.o cifsencrypt.o \ | 8 | cifs_unicode.o nterr.o xattr.o cifsencrypt.o \ |
9 | readdir.o ioctl.o sess.o export.o | 9 | readdir.o ioctl.o sess.o export.o smb1ops.o |
10 | 10 | ||
11 | cifs-$(CONFIG_CIFS_ACL) += cifsacl.o | 11 | cifs-$(CONFIG_CIFS_ACL) += cifsacl.o |
12 | 12 | ||
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index f718d5780062..8a6928c4537d 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -354,6 +354,7 @@ cifs_show_options(struct seq_file *s, struct dentry *root) | |||
354 | struct sockaddr *srcaddr; | 354 | struct sockaddr *srcaddr; |
355 | srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr; | 355 | srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr; |
356 | 356 | ||
357 | seq_printf(s, ",vers=%s", tcon->ses->server->vals->version_string); | ||
357 | cifs_show_security(s, tcon->ses->server); | 358 | cifs_show_security(s, tcon->ses->server); |
358 | cifs_show_cache_flavor(s, cifs_sb); | 359 | cifs_show_cache_flavor(s, cifs_sb); |
359 | 360 | ||
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index a867d9923d7d..812e22ab0a49 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -150,6 +150,17 @@ struct cifs_cred { | |||
150 | ***************************************************************** | 150 | ***************************************************************** |
151 | */ | 151 | */ |
152 | 152 | ||
153 | enum smb_version { | ||
154 | Smb_1 = 1, | ||
155 | }; | ||
156 | |||
157 | struct smb_version_operations { | ||
158 | }; | ||
159 | |||
160 | struct smb_version_values { | ||
161 | char *version_string; | ||
162 | }; | ||
163 | |||
153 | struct smb_vol { | 164 | struct smb_vol { |
154 | char *username; | 165 | char *username; |
155 | char *password; | 166 | char *password; |
@@ -205,6 +216,8 @@ struct smb_vol { | |||
205 | bool sockopt_tcp_nodelay:1; | 216 | bool sockopt_tcp_nodelay:1; |
206 | unsigned short int port; | 217 | unsigned short int port; |
207 | unsigned long actimeo; /* attribute cache timeout (jiffies) */ | 218 | unsigned long actimeo; /* attribute cache timeout (jiffies) */ |
219 | struct smb_version_operations *ops; | ||
220 | struct smb_version_values *vals; | ||
208 | char *prepath; | 221 | char *prepath; |
209 | struct sockaddr_storage srcaddr; /* allow binding to a local IP */ | 222 | struct sockaddr_storage srcaddr; /* allow binding to a local IP */ |
210 | struct nls_table *local_nls; | 223 | struct nls_table *local_nls; |
@@ -242,6 +255,8 @@ struct TCP_Server_Info { | |||
242 | int srv_count; /* reference counter */ | 255 | int srv_count; /* reference counter */ |
243 | /* 15 character server name + 0x20 16th byte indicating type = srv */ | 256 | /* 15 character server name + 0x20 16th byte indicating type = srv */ |
244 | char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL]; | 257 | char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL]; |
258 | struct smb_version_operations *ops; | ||
259 | struct smb_version_values *vals; | ||
245 | enum statusEnum tcpStatus; /* what we think the status is */ | 260 | enum statusEnum tcpStatus; /* what we think the status is */ |
246 | char *hostname; /* hostname portion of UNC string */ | 261 | char *hostname; /* hostname portion of UNC string */ |
247 | struct socket *ssocket; | 262 | struct socket *ssocket; |
@@ -1069,4 +1084,8 @@ void cifs_oplock_break(struct work_struct *work); | |||
1069 | extern const struct slow_work_ops cifs_oplock_break_ops; | 1084 | extern const struct slow_work_ops cifs_oplock_break_ops; |
1070 | extern struct workqueue_struct *cifsiod_wq; | 1085 | extern struct workqueue_struct *cifsiod_wq; |
1071 | 1086 | ||
1087 | /* Operations for different SMB versions */ | ||
1088 | #define SMB1_VERSION_STRING "1.0" | ||
1089 | extern struct smb_version_operations smb1_operations; | ||
1090 | extern struct smb_version_values smb1_values; | ||
1072 | #endif /* _CIFS_GLOB_H */ | 1091 | #endif /* _CIFS_GLOB_H */ |
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); |
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c new file mode 100644 index 000000000000..d2850d194eb5 --- /dev/null +++ b/fs/cifs/smb1ops.c | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | * SMB1 (CIFS) version specific operations | ||
3 | * | ||
4 | * Copyright (c) 2012, Jeff Layton <jlayton@redhat.com> | ||
5 | * | ||
6 | * This library is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License v2 as published | ||
8 | * by the Free Software Foundation. | ||
9 | * | ||
10 | * This library is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | ||
13 | * the GNU Lesser General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public License | ||
16 | * along with this library; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include "cifsglob.h" | ||
21 | |||
22 | struct smb_version_operations smb1_operations = { | ||
23 | }; | ||
24 | |||
25 | struct smb_version_values smb1_values = { | ||
26 | .version_string = SMB1_VERSION_STRING, | ||
27 | }; | ||