aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c118
1 files changed, 32 insertions, 86 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index d81e933a796b..e0b56d7a19c5 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -109,6 +109,8 @@ enum {
109 109
110 /* Options which could be blank */ 110 /* Options which could be blank */
111 Opt_blank_pass, 111 Opt_blank_pass,
112 Opt_blank_user,
113 Opt_blank_ip,
112 114
113 Opt_err 115 Opt_err
114}; 116};
@@ -162,7 +164,8 @@ static const match_table_t cifs_mount_option_tokens = {
162 { Opt_sign, "sign" }, 164 { Opt_sign, "sign" },
163 { Opt_seal, "seal" }, 165 { Opt_seal, "seal" },
164 { Opt_direct, "direct" }, 166 { Opt_direct, "direct" },
165 { Opt_direct, "forceddirectio" }, 167 { Opt_direct, "directio" },
168 { Opt_direct, "forcedirectio" },
166 { Opt_strictcache, "strictcache" }, 169 { Opt_strictcache, "strictcache" },
167 { Opt_noac, "noac" }, 170 { Opt_noac, "noac" },
168 { Opt_fsc, "fsc" }, 171 { Opt_fsc, "fsc" },
@@ -183,11 +186,15 @@ static const match_table_t cifs_mount_option_tokens = {
183 { Opt_wsize, "wsize=%s" }, 186 { Opt_wsize, "wsize=%s" },
184 { Opt_actimeo, "actimeo=%s" }, 187 { Opt_actimeo, "actimeo=%s" },
185 188
189 { Opt_blank_user, "user=" },
190 { Opt_blank_user, "username=" },
186 { Opt_user, "user=%s" }, 191 { Opt_user, "user=%s" },
187 { Opt_user, "username=%s" }, 192 { Opt_user, "username=%s" },
188 { Opt_blank_pass, "pass=" }, 193 { Opt_blank_pass, "pass=" },
189 { Opt_pass, "pass=%s" }, 194 { Opt_pass, "pass=%s" },
190 { Opt_pass, "password=%s" }, 195 { Opt_pass, "password=%s" },
196 { Opt_blank_ip, "ip=" },
197 { Opt_blank_ip, "addr=" },
191 { Opt_ip, "ip=%s" }, 198 { Opt_ip, "ip=%s" },
192 { Opt_ip, "addr=%s" }, 199 { Opt_ip, "addr=%s" },
193 { Opt_unc, "unc=%s" }, 200 { Opt_unc, "unc=%s" },
@@ -209,6 +216,8 @@ static const match_table_t cifs_mount_option_tokens = {
209 216
210 { Opt_ignore, "cred" }, 217 { Opt_ignore, "cred" },
211 { Opt_ignore, "credentials" }, 218 { Opt_ignore, "credentials" },
219 { Opt_ignore, "cred=%s" },
220 { Opt_ignore, "credentials=%s" },
212 { Opt_ignore, "guest" }, 221 { Opt_ignore, "guest" },
213 { Opt_ignore, "rw" }, 222 { Opt_ignore, "rw" },
214 { Opt_ignore, "ro" }, 223 { Opt_ignore, "ro" },
@@ -1117,7 +1126,7 @@ static int get_option_ul(substring_t args[], unsigned long *option)
1117 string = match_strdup(args); 1126 string = match_strdup(args);
1118 if (string == NULL) 1127 if (string == NULL)
1119 return -ENOMEM; 1128 return -ENOMEM;
1120 rc = kstrtoul(string, 10, option); 1129 rc = kstrtoul(string, 0, option);
1121 kfree(string); 1130 kfree(string);
1122 1131
1123 return rc; 1132 return rc;
@@ -1534,15 +1543,17 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1534 1543
1535 /* String Arguments */ 1544 /* String Arguments */
1536 1545
1546 case Opt_blank_user:
1547 /* null user, ie. anonymous authentication */
1548 vol->nullauth = 1;
1549 vol->username = NULL;
1550 break;
1537 case Opt_user: 1551 case Opt_user:
1538 string = match_strdup(args); 1552 string = match_strdup(args);
1539 if (string == NULL) 1553 if (string == NULL)
1540 goto out_nomem; 1554 goto out_nomem;
1541 1555
1542 if (!*string) { 1556 if (strnlen(string, MAX_USERNAME_SIZE) >
1543 /* null user, ie. anonymous authentication */
1544 vol->nullauth = 1;
1545 } else if (strnlen(string, MAX_USERNAME_SIZE) >
1546 MAX_USERNAME_SIZE) { 1557 MAX_USERNAME_SIZE) {
1547 printk(KERN_WARNING "CIFS: username too long\n"); 1558 printk(KERN_WARNING "CIFS: username too long\n");
1548 goto cifs_parse_mount_err; 1559 goto cifs_parse_mount_err;
@@ -1611,14 +1622,15 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1611 } 1622 }
1612 vol->password[j] = '\0'; 1623 vol->password[j] = '\0';
1613 break; 1624 break;
1625 case Opt_blank_ip:
1626 vol->UNCip = NULL;
1627 break;
1614 case Opt_ip: 1628 case Opt_ip:
1615 string = match_strdup(args); 1629 string = match_strdup(args);
1616 if (string == NULL) 1630 if (string == NULL)
1617 goto out_nomem; 1631 goto out_nomem;
1618 1632
1619 if (!*string) { 1633 if (strnlen(string, INET6_ADDRSTRLEN) >
1620 vol->UNCip = NULL;
1621 } else if (strnlen(string, INET6_ADDRSTRLEN) >
1622 INET6_ADDRSTRLEN) { 1634 INET6_ADDRSTRLEN) {
1623 printk(KERN_WARNING "CIFS: ip address " 1635 printk(KERN_WARNING "CIFS: ip address "
1624 "too long\n"); 1636 "too long\n");
@@ -1636,12 +1648,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1636 if (string == NULL) 1648 if (string == NULL)
1637 goto out_nomem; 1649 goto out_nomem;
1638 1650
1639 if (!*string) {
1640 printk(KERN_WARNING "CIFS: invalid path to "
1641 "network resource\n");
1642 goto cifs_parse_mount_err;
1643 }
1644
1645 temp_len = strnlen(string, 300); 1651 temp_len = strnlen(string, 300);
1646 if (temp_len == 300) { 1652 if (temp_len == 300) {
1647 printk(KERN_WARNING "CIFS: UNC name too long\n"); 1653 printk(KERN_WARNING "CIFS: UNC name too long\n");
@@ -1670,11 +1676,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1670 if (string == NULL) 1676 if (string == NULL)
1671 goto out_nomem; 1677 goto out_nomem;
1672 1678
1673 if (!*string) { 1679 if (strnlen(string, 256) == 256) {
1674 printk(KERN_WARNING "CIFS: invalid domain"
1675 " name\n");
1676 goto cifs_parse_mount_err;
1677 } else if (strnlen(string, 256) == 256) {
1678 printk(KERN_WARNING "CIFS: domain name too" 1680 printk(KERN_WARNING "CIFS: domain name too"
1679 " long\n"); 1681 " long\n");
1680 goto cifs_parse_mount_err; 1682 goto cifs_parse_mount_err;
@@ -1693,11 +1695,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1693 if (string == NULL) 1695 if (string == NULL)
1694 goto out_nomem; 1696 goto out_nomem;
1695 1697
1696 if (!*string) { 1698 if (!cifs_convert_address(
1697 printk(KERN_WARNING "CIFS: srcaddr value not"
1698 " specified\n");
1699 goto cifs_parse_mount_err;
1700 } else if (!cifs_convert_address(
1701 (struct sockaddr *)&vol->srcaddr, 1699 (struct sockaddr *)&vol->srcaddr,
1702 string, strlen(string))) { 1700 string, strlen(string))) {
1703 printk(KERN_WARNING "CIFS: Could not parse" 1701 printk(KERN_WARNING "CIFS: Could not parse"
@@ -1710,11 +1708,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1710 if (string == NULL) 1708 if (string == NULL)
1711 goto out_nomem; 1709 goto out_nomem;
1712 1710
1713 if (!*string) {
1714 printk(KERN_WARNING "CIFS: Invalid path"
1715 " prefix\n");
1716 goto cifs_parse_mount_err;
1717 }
1718 temp_len = strnlen(string, 1024); 1711 temp_len = strnlen(string, 1024);
1719 if (string[0] != '/') 1712 if (string[0] != '/')
1720 temp_len++; /* missing leading slash */ 1713 temp_len++; /* missing leading slash */
@@ -1742,11 +1735,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1742 if (string == NULL) 1735 if (string == NULL)
1743 goto out_nomem; 1736 goto out_nomem;
1744 1737
1745 if (!*string) { 1738 if (strnlen(string, 1024) >= 65) {
1746 printk(KERN_WARNING "CIFS: Invalid iocharset"
1747 " specified\n");
1748 goto cifs_parse_mount_err;
1749 } else if (strnlen(string, 1024) >= 65) {
1750 printk(KERN_WARNING "CIFS: iocharset name " 1739 printk(KERN_WARNING "CIFS: iocharset name "
1751 "too long.\n"); 1740 "too long.\n");
1752 goto cifs_parse_mount_err; 1741 goto cifs_parse_mount_err;
@@ -1771,11 +1760,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1771 if (string == NULL) 1760 if (string == NULL)
1772 goto out_nomem; 1761 goto out_nomem;
1773 1762
1774 if (!*string) {
1775 printk(KERN_WARNING "CIFS: No socket option"
1776 " specified\n");
1777 goto cifs_parse_mount_err;
1778 }
1779 if (strnicmp(string, "TCP_NODELAY", 11) == 0) 1763 if (strnicmp(string, "TCP_NODELAY", 11) == 0)
1780 vol->sockopt_tcp_nodelay = 1; 1764 vol->sockopt_tcp_nodelay = 1;
1781 break; 1765 break;
@@ -1784,12 +1768,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1784 if (string == NULL) 1768 if (string == NULL)
1785 goto out_nomem; 1769 goto out_nomem;
1786 1770
1787 if (!*string) {
1788 printk(KERN_WARNING "CIFS: Invalid (empty)"
1789 " netbiosname\n");
1790 break;
1791 }
1792
1793 memset(vol->source_rfc1001_name, 0x20, 1771 memset(vol->source_rfc1001_name, 0x20,
1794 RFC1001_NAME_LEN); 1772 RFC1001_NAME_LEN);
1795 /* 1773 /*
@@ -1817,11 +1795,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1817 if (string == NULL) 1795 if (string == NULL)
1818 goto out_nomem; 1796 goto out_nomem;
1819 1797
1820 if (!*string) {
1821 printk(KERN_WARNING "CIFS: Empty server"
1822 " netbiosname specified\n");
1823 break;
1824 }
1825 /* last byte, type, is 0x20 for servr type */ 1798 /* last byte, type, is 0x20 for servr type */
1826 memset(vol->target_rfc1001_name, 0x20, 1799 memset(vol->target_rfc1001_name, 0x20,
1827 RFC1001_NAME_LEN_WITH_NULL); 1800 RFC1001_NAME_LEN_WITH_NULL);
@@ -1848,12 +1821,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1848 if (string == NULL) 1821 if (string == NULL)
1849 goto out_nomem; 1822 goto out_nomem;
1850 1823
1851 if (!*string) {
1852 cERROR(1, "no protocol version specified"
1853 " after vers= mount option");
1854 goto cifs_parse_mount_err;
1855 }
1856
1857 if (strnicmp(string, "cifs", 4) == 0 || 1824 if (strnicmp(string, "cifs", 4) == 0 ||
1858 strnicmp(string, "1", 1) == 0) { 1825 strnicmp(string, "1", 1) == 0) {
1859 /* This is the default */ 1826 /* This is the default */
@@ -1868,12 +1835,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1868 if (string == NULL) 1835 if (string == NULL)
1869 goto out_nomem; 1836 goto out_nomem;
1870 1837
1871 if (!*string) {
1872 printk(KERN_WARNING "CIFS: no security flavor"
1873 " specified\n");
1874 break;
1875 }
1876
1877 if (cifs_parse_security_flavors(string, vol) != 0) 1838 if (cifs_parse_security_flavors(string, vol) != 0)
1878 goto cifs_parse_mount_err; 1839 goto cifs_parse_mount_err;
1879 break; 1840 break;
@@ -2225,6 +2186,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
2225 tcp_ses->session_estab = false; 2186 tcp_ses->session_estab = false;
2226 tcp_ses->sequence_number = 0; 2187 tcp_ses->sequence_number = 0;
2227 tcp_ses->lstrp = jiffies; 2188 tcp_ses->lstrp = jiffies;
2189 spin_lock_init(&tcp_ses->req_lock);
2228 INIT_LIST_HEAD(&tcp_ses->tcp_ses_list); 2190 INIT_LIST_HEAD(&tcp_ses->tcp_ses_list);
2229 INIT_LIST_HEAD(&tcp_ses->smb_ses_list); 2191 INIT_LIST_HEAD(&tcp_ses->smb_ses_list);
2230 INIT_DELAYED_WORK(&tcp_ses->echo, cifs_echo_request); 2192 INIT_DELAYED_WORK(&tcp_ses->echo, cifs_echo_request);
@@ -3270,10 +3232,6 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
3270 3232
3271 cifs_sb->mnt_uid = pvolume_info->linux_uid; 3233 cifs_sb->mnt_uid = pvolume_info->linux_uid;
3272 cifs_sb->mnt_gid = pvolume_info->linux_gid; 3234 cifs_sb->mnt_gid = pvolume_info->linux_gid;
3273 if (pvolume_info->backupuid_specified)
3274 cifs_sb->mnt_backupuid = pvolume_info->backupuid;
3275 if (pvolume_info->backupgid_specified)
3276 cifs_sb->mnt_backupgid = pvolume_info->backupgid;
3277 cifs_sb->mnt_file_mode = pvolume_info->file_mode; 3235 cifs_sb->mnt_file_mode = pvolume_info->file_mode;
3278 cifs_sb->mnt_dir_mode = pvolume_info->dir_mode; 3236 cifs_sb->mnt_dir_mode = pvolume_info->dir_mode;
3279 cFYI(1, "file mode: 0x%hx dir mode: 0x%hx", 3237 cFYI(1, "file mode: 0x%hx dir mode: 0x%hx",
@@ -3304,10 +3262,14 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
3304 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RWPIDFORWARD; 3262 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RWPIDFORWARD;
3305 if (pvolume_info->cifs_acl) 3263 if (pvolume_info->cifs_acl)
3306 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL; 3264 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
3307 if (pvolume_info->backupuid_specified) 3265 if (pvolume_info->backupuid_specified) {
3308 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPUID; 3266 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPUID;
3309 if (pvolume_info->backupgid_specified) 3267 cifs_sb->mnt_backupuid = pvolume_info->backupuid;
3268 }
3269 if (pvolume_info->backupgid_specified) {
3310 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPGID; 3270 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPGID;
3271 cifs_sb->mnt_backupgid = pvolume_info->backupgid;
3272 }
3311 if (pvolume_info->override_uid) 3273 if (pvolume_info->override_uid)
3312 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID; 3274 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID;
3313 if (pvolume_info->override_gid) 3275 if (pvolume_info->override_gid)
@@ -3656,22 +3618,6 @@ cifs_get_volume_info(char *mount_data, const char *devname)
3656 return volume_info; 3618 return volume_info;
3657} 3619}
3658 3620
3659/* make sure ra_pages is a multiple of rsize */
3660static inline unsigned int
3661cifs_ra_pages(struct cifs_sb_info *cifs_sb)
3662{
3663 unsigned int reads;
3664 unsigned int rsize_pages = cifs_sb->rsize / PAGE_CACHE_SIZE;
3665
3666 if (rsize_pages >= default_backing_dev_info.ra_pages)
3667 return default_backing_dev_info.ra_pages;
3668 else if (rsize_pages == 0)
3669 return rsize_pages;
3670
3671 reads = default_backing_dev_info.ra_pages / rsize_pages;
3672 return reads * rsize_pages;
3673}
3674
3675int 3621int
3676cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) 3622cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info)
3677{ 3623{
@@ -3759,7 +3705,7 @@ try_mount_again:
3759 cifs_sb->rsize = cifs_negotiate_rsize(tcon, volume_info); 3705 cifs_sb->rsize = cifs_negotiate_rsize(tcon, volume_info);
3760 3706
3761 /* tune readahead according to rsize */ 3707 /* tune readahead according to rsize */
3762 cifs_sb->bdi.ra_pages = cifs_ra_pages(cifs_sb); 3708 cifs_sb->bdi.ra_pages = cifs_sb->rsize / PAGE_CACHE_SIZE;
3763 3709
3764remote_path_check: 3710remote_path_check:
3765#ifdef CONFIG_CIFS_DFS_UPCALL 3711#ifdef CONFIG_CIFS_DFS_UPCALL