@@ -102,7 +102,7 @@ enum {
102102 Opt_srcaddr , Opt_prefixpath ,
103103 Opt_iocharset , Opt_sockopt ,
104104 Opt_netbiosname , Opt_servern ,
105- Opt_ver , Opt_sec , Opt_cache ,
105+ Opt_ver , Opt_vers , Opt_sec , Opt_cache ,
106106
107107 /* Mount options to be ignored */
108108 Opt_ignore ,
@@ -210,6 +210,7 @@ static const match_table_t cifs_mount_option_tokens = {
210210 { Opt_netbiosname , "netbiosname=%s" },
211211 { Opt_servern , "servern=%s" },
212212 { Opt_ver , "ver=%s" },
213+ { Opt_vers , "vers=%s" },
213214 { Opt_sec , "sec=%s" },
214215 { Opt_cache , "cache=%s" },
215216
@@ -275,6 +276,10 @@ static const match_table_t cifs_cacheflavor_tokens = {
275276 { Opt_cache_err , NULL }
276277};
277278
279+ static const match_table_t cifs_smb_version_tokens = {
280+ { Smb_1 , SMB1_VERSION_STRING },
281+ };
282+
278283static int ip_connect (struct TCP_Server_Info * server );
279284static int generic_ip_connect (struct TCP_Server_Info * server );
280285static void tlink_rb_insert (struct rb_root * root , struct tcon_link * new_tlink );
@@ -1224,6 +1229,23 @@ cifs_parse_cache_flavor(char *value, struct smb_vol *vol)
12241229 return 0 ;
12251230}
12261231
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+
12271249static int
12281250cifs_parse_mount_options (const char * mountdata , const char * devname ,
12291251 struct smb_vol * vol )
@@ -1277,6 +1299,10 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
12771299
12781300 vol -> actimeo = CIFS_DEF_ACTIMEO ;
12791301
1302+ /* FIXME: add autonegotiation -- for now, SMB1 is default */
1303+ vol -> ops = & smb1_operations ;
1304+ vol -> vals = & smb1_values ;
1305+
12801306 if (!mountdata )
12811307 goto cifs_parse_mount_err ;
12821308
@@ -1880,6 +1906,14 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
18801906 printk (KERN_WARNING "CIFS: Invalid version"
18811907 " specified\n" );
18821908 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 ;
18831917 case Opt_sec :
18841918 string = match_strdup (args );
18851919 if (string == NULL )
@@ -2108,6 +2142,9 @@ match_security(struct TCP_Server_Info *server, struct smb_vol *vol)
21082142static int match_server (struct TCP_Server_Info * server , struct sockaddr * addr ,
21092143 struct smb_vol * vol )
21102144{
2145+ if ((server -> vals != vol -> vals ) || (server -> ops != vol -> ops ))
2146+ return 0 ;
2147+
21112148 if (!net_eq (cifs_net_ns (server ), current -> nsproxy -> net_ns ))
21122149 return 0 ;
21132150
@@ -2230,6 +2267,8 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
22302267 goto out_err ;
22312268 }
22322269
2270+ tcp_ses -> ops = volume_info -> ops ;
2271+ tcp_ses -> vals = volume_info -> vals ;
22332272 cifs_set_net_ns (tcp_ses , get_net (current -> nsproxy -> net_ns ));
22342273 tcp_ses -> hostname = extract_hostname (volume_info -> UNC );
22352274 if (IS_ERR (tcp_ses -> hostname )) {
@@ -3636,6 +3675,7 @@ cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data,
36363675 if (cifs_parse_mount_options (mount_data , devname , volume_info ))
36373676 return - EINVAL ;
36383677
3678+
36393679 if (volume_info -> nullauth ) {
36403680 cFYI (1 , "Anonymous login" );
36413681 kfree (volume_info -> username );
0 commit comments