Bug 13470 - DFS mounted shares do not allow to go subdirectories
Summary: DFS mounted shares do not allow to go subdirectories
Alias: None
Product: CifsVFS
Classification: Unclassified
Component: kernel fs (show other bugs)
Version: 3.x
Hardware: x86 Linux
: P5 normal
Target Milestone: ---
Assignee: Steve French
QA Contact: cifs QA contact
Depends on:
Reported: 2018-06-12 15:22 UTC by Sergey
Modified: 2020-07-31 15:07 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Sergey 2018-06-12 15:22:35 UTC
The company work at has a global server for all the offices around the world.
It's //epam.com

Shares on this server are accessible from Windows and with smbclient without any issue, but cifs behaviour is somewhat strange on the same directories where smbclient works fine.

I don't know how exactly DFS works but below is what I see..

I can check a list of shares with $ smbclient -L epam.com
After entering my password it will show the list. No other arguments required since smb.conf settings and current user name are good enough already.
Then I mount one of shares to /mnt

sudo mount -t cifs -o username=sergey,workgroup=subdomainx.epam.com,password=MyPassword,uid=1000,gid=1000 //epam.com/MyShare /mnt

Here username matches with my system username, password is the same as I use with smbclient and workgroup is the same as I use in smb.conf.
It's mounted and I can do ls /mnt to see contents.

$ ls /mnt

Now when I want to get inside the SubDirectory I get next

$ ls /mnt/SubDirectory
ls: cannot access '/mnt/SubDirectory': Invalid argument

The same for any other command. I straced ls and this error comes from stat syscall on the SubDirectory.

Also below is a final part of log I get on ls.

[ 6917.186847] /home/kernel/COD/linux/fs/cifs/cifs_dfs_ref.c: CIFS VFS: leaving cifs_dfs_do_automount (xid = 113) rc = 0
[ 6917.186850] /home/kernel/COD/linux/fs/cifs/cifs_dfs_ref.c: DFS: ref path: \epam.com\MyShare\SubDirectory
[ 6917.186852] /home/kernel/COD/linux/fs/cifs/cifs_dfs_ref.c: DFS: node path: \othercountry.epam.com\MyShare
[ 6917.186854] /home/kernel/COD/linux/fs/cifs/cifs_dfs_ref.c: DFS: fl: 2, srv_type: 0
[ 6917.186855] /home/kernel/COD/linux/fs/cifs/cifs_dfs_ref.c: DFS: ref_flags: 0, path_consumed: 25
[ 6917.186859] /home/kernel/COD/linux/fs/cifs/cifs_dfs_ref.c: cifs_dfs_do_automount: cifs_dfs_do_refmount:\othercountry.epam.com\MyShare , mnt:000000000435c64d
[ 6917.186873] /home/kernel/COD/linux/fs/cifs/cifs_dfs_ref.c: leaving cifs_dfs_do_automount
[ 6917.186874] /home/kernel/COD/linux/fs/cifs/cifs_dfs_ref.c: leaving cifs_dfs_d_automount [automount failed]

I tried to mount othercountry.epam.com\MyShare directly and it's mounted w/o issues. All files and directories are accessible (at least those I have access to). So the problem seems to be related to DFS only.

I tried to track in the code this invalid argument and came into conclusion it's either a problem with invalid (null) sb_mountdata or cifs_build_devname returns EINVAL (I guess this one is translated to Invalid Argument).

I have here Ubuntu 18.04 with kernel 4.17.1-041701-generic
Comment 1 Aurélien Aptel 2020-07-23 12:32:40 UTC
Have you tried a recent kernel? Lot of DFS changes went in the last few years.
Comment 2 Sergey 2020-07-28 18:09:14 UTC
Hi Aurélien Aptel,

Following my scenario above I couldn't reproduce it anymore. Seems to work.

btw I have a couple of questions unrelated to this issue:
1. Is it possible to force smbclient/cifs mount to try all nameservers from /etc/resolv.conf? 
2. Is it possible to mount dfs root? In my case it's //epam.com
Comment 3 Aurélien Aptel 2020-07-28 19:34:40 UTC
Regarding 1)

You can put multiple nameservers in /etc/resolv.conf but that might not have the effect you want.

If you have 2 nameserver A and B, it will try to resolve by contacting A first. But if A is *up* and replies that the the domain cannot be found it will stop there.
The nameserver B will only be tried if A is down, not if A replies "doesn't exist".

What I would suggest you do is setup dnsmasq. It's a tiny dns server proxy daemon.

You can tell it to forward all domain request for epam.com and any subdomain (e.g. a.epam.com, a.b.c.epam.com etc) to nameserver A, and forward all the other request to nameserver B.

To use it, install dnsmasq, and put this in the config file (usually /etc/dnsmasq.conf)

    # forward *.epam.com requests to
    # forward the rest to

You will also need to set your system dns server to point to the local dnsmasq. This can be done by putting in /etc/resolv.conf (and only one). There might be cleaner ways to do this depending on your distro as resolv.conf might be overwritten by the system each time you connect to some Wifi network for example.


Alternatively, if setting up dnsmasq is too much and you don't mind hardcoding the IP of each host used in the DFS namespace, you can simply list them in /etc/hosts

Regarding 2)

It should be possible to mount the dfs root yes. Once you have DNS working it should all be ok, assuming your kernel is recent enough.
Comment 4 Sergey 2020-07-28 19:50:47 UTC
Thank you very much Aurélien.

I already played with dnsmasq this way for different purposes. I hoped there is an easier way. But that's fine.

But mounting dfs root doesn't work for me.
Basically I take the mount line mentioned in the first post and remove MyShare.
Then I get something like following in dmesg

[95886.129233] CIFS: Attempting to mount //epam.com/
[95886.171103] CIFS VFS:  BAD_NETWORK_NAME: \\SUBDOMAINX.epam.com\epam.com
[95886.183185] CIFS VFS:  BAD_NETWORK_NAME: \\SUBDOMAINX.epam.com\epam.com
[95886.183836] CIFS VFS: cifs_mount failed w/return code = -112

Where SUBDOMAINX.epam.com is listable with smbclient -L

If I remove trailing / then I get next in dmesg

[96140.695029] CIFS VFS: Malformed UNC in devname

kernel 5.7.9

Ok. I think I need to report this under a different number.
Thanks again.
Comment 5 Sergey 2020-07-29 13:25:03 UTC
btw I can open smb://epam.com in KDE's Dolphin. I guess it's because it doesn't use kernel's capabilities for that.
Comment 6 Aurélien Aptel 2020-07-31 15:07:29 UTC
Can you open a new bug and attach a network trace of opening the DFS root with Dolphin, and another trace of trying to mount the root.

See instructions here: https://wiki.samba.org/index.php/Bug_Reporting#cifs.ko