aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifsfs.c
diff options
context:
space:
mode:
authorBen Greear <greearb@candelatech.com>2010-09-01 20:06:02 -0400
committerSteve French <sfrench@us.ibm.com>2010-09-29 15:04:29 -0400
commit3eb9a8893a76cf1cda3b41c3212eb2cfe83eae0e (patch)
treefd4fb596113f27bcbe3bba1f2777c91f14521f48 /fs/cifs/cifsfs.c
parent2b149f11978b44199954710d32c0eecf6c9efd9c (diff)
cifs: Allow binding to local IP address.
When using multi-homed machines, it's nice to be able to specify the local IP to use for outbound connections. This patch gives cifs the ability to bind to a particular IP address. Usage: mount -t cifs -o srcaddr=192.168.1.50,user=foo, ... Usage: mount -t cifs -o srcaddr=2002::100:1,user=foo, ... Acked-by: Jeff Layton <jlayton@redhat.com> Acked-by: Dr. David Holder <david.holder@erion.co.uk> Signed-off-by: Ben Greear <greearb@candelatech.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/cifsfs.c')
-rw-r--r--fs/cifs/cifsfs.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index b7431afdd76d..1b6ddd6f760f 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -36,6 +36,7 @@
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/freezer.h> 37#include <linux/freezer.h>
38#include <linux/smp_lock.h> 38#include <linux/smp_lock.h>
39#include <net/ipv6.h>
39#include "cifsfs.h" 40#include "cifsfs.h"
40#include "cifspdu.h" 41#include "cifspdu.h"
41#define DECLARE_GLOBALS_HERE 42#define DECLARE_GLOBALS_HERE
@@ -367,6 +368,8 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
367{ 368{
368 struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb); 369 struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb);
369 struct cifsTconInfo *tcon = cifs_sb->tcon; 370 struct cifsTconInfo *tcon = cifs_sb->tcon;
371 struct sockaddr *srcaddr;
372 srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
370 373
371 seq_printf(s, ",unc=%s", tcon->treeName); 374 seq_printf(s, ",unc=%s", tcon->treeName);
372 if (tcon->ses->userName) 375 if (tcon->ses->userName)
@@ -374,6 +377,22 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
374 if (tcon->ses->domainName) 377 if (tcon->ses->domainName)
375 seq_printf(s, ",domain=%s", tcon->ses->domainName); 378 seq_printf(s, ",domain=%s", tcon->ses->domainName);
376 379
380 if (srcaddr->sa_family != AF_UNSPEC) {
381 struct sockaddr_in *saddr4;
382 struct sockaddr_in6 *saddr6;
383 saddr4 = (struct sockaddr_in *)srcaddr;
384 saddr6 = (struct sockaddr_in6 *)srcaddr;
385 if (srcaddr->sa_family == AF_INET6)
386 seq_printf(s, ",srcaddr=%pI6c",
387 &saddr6->sin6_addr);
388 else if (srcaddr->sa_family == AF_INET)
389 seq_printf(s, ",srcaddr=%pI4",
390 &saddr4->sin_addr.s_addr);
391 else
392 seq_printf(s, ",srcaddr=BAD-AF:%i",
393 (int)(srcaddr->sa_family));
394 }
395
377 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid); 396 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
378 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) 397 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
379 seq_printf(s, ",forceuid"); 398 seq_printf(s, ",forceuid");