From our Debian user:
Hi.
It took me quite some time to figure out what the cause was:
/sbin/mount.cifs //server/share mointpoint --verbose -o user=username,noperm
parsing options: user=username,noperm
Password:
mount.cifs kernel mount options unc=//server\share,pass=******,ver=1,user=username,noperm,uid=1024,gid=100
mount error(22): Invalid argument
Now 'server' has an ipv4 and an ipv6 address.
If I pass options -o user=user,ip=servername,noperm the same error 22 is risen.
If I pass options -o user=user,ip=ipv4-address-of-server,noperm the mount is successfull.
I didn't test if this is just ipv6 related, or just happens if a server has multiple Address records.
This does not happen with mount.cifs from etch (samba 3.0.24) or lenny (samba 3.2.5), then only the ipv4 address is being tried and it works
without specifying an ip= option.

When ip=<ipv6_address_of_the_samba_server> option is specified, nothing is
logged on the samba server, so nothing goes out on the wire from the cifs
vfs client (wireshark trace also confirms that) to the samba server.
Need to figure out what and why this error
fs/cifs/connect.c: Error -22 connecting to server via ipv6

I think this failure (in my case) has to do something with the scope of
the address (Scope:Link)
inet6 addr: fe80::214:5eff:fefb:3f7c/64 Scope:Link
I suspect the ipv6 address you are using has similar scope, Scope:Link
when the error EINVAL is genereated, connect just does not succeed.

Julien Cristau notes that, since the target IP in the example is a link-local address, it's necessary to specify an interface name the same as you do when calling ping. The syntax for this is:
fe80::214:5eff:fefb:3f7c%eth0
However, even when specifying the interface name a mount.cifs still fails for me.

Yes, I'm not sure that we really can support link-local addresses (and tbh: I'm not exactly sure yet how we should support them). Our address parser doesn't understand interface names in the scope...
I could be wrong, but aren't link-local addresses really only supposed to be used for things like neighbor discovery?
Some confirmation of the problem from the original reporter might be nice. An strace of the mount command that shows a link-local ip addr in the mount options, for instance...
> If I pass options -o user=user,ip=servername,noperm the same error 22 is risen.
That's expected since you're passing something that isn't an IP address into the kernel as if it were. When "ip=" is explicitly specified then the mount helper doesn't bother with name resolution and passes it on directly.