cifs: Allow binding to local IP address.
Subsystems (4)
PATCH v2 1/1 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 bindaddr=192.168.1.50,user=foo, ...
---
:100644 100644 b7431af... 77293db... M fs/cifs/cifsfs.c
:100644 100644 c9d0cfc... c0176d8... M fs/cifs/cifsglob.h
:100644 100644 ec0ea4a... bacbf46... M fs/cifs/connect.c
fs/cifs/cifsfs.c | 4 +++ fs/cifs/cifsglob.h | 1 + fs/cifs/connect.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 2 deletions(-)
fs/cifs/cifsfs.c +4 -0
@@ -374,6 +374,10 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)if (tcon->ses->domainName)seq_printf (s,",domain=%s" , tcon->ses->domainName); +if (tcon->ses->server->ip4_local_ip) +seq_printf (s,",bindaddr=%pI4" , + &tcon->ses->server->ip4_local_ip); +seq_printf (s,",uid=%d" , cifs_sb->mnt_uid);if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_OVERR_UID )seq_printf (s,",forceuid" );
fs/cifs/cifsglob.h +1 -0
@@ -157,6 +157,7 @@ struct TCP_Server_Info {struct sockaddr_in sockAddr;struct sockaddr_in6 sockAddr6; } addr; +u32 ip4_local_ip;wait_queue_head_t response_q;wait_queue_head_t request_q;/* if more than maxmpx to srvr must block*/ struct list_head pending_mid_q;
fs/cifs/connect.c +51 -2
101 lines not on this page · raw message
Signature · 1 line
1.6.2.5
A message that is not in the archive (sent off-list or not yet received): 1282844096-13295-1-git-send-email-greearb-my8/[email protected]
Quoted 146 lines · On Thu, 26 Aug 2010 10:34:56 -0700 Ben Greear…
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 bindaddr=192.168.1.50,user=foo, ...
Signed-off-by Ben Greear <greearb-my8/[email protected]>---
:100644 100644 b7431af... 77293db... Mfs/cifs/cifsfs.c
:100644 100644 c9d0cfc... c0176d8... Mfs/cifs/cifsglob.h
:100644 100644 ec0ea4a... bacbf46... Mfs/cifs/connect.cfs/cifs/cifsfs.c | 4 +++ fs/cifs/cifsglob.h | 1 + fs/cifs/connect.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 2 deletions(-)fs/cifs/cifsfs.c +4
-0@@ -374,6 +374,10 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)if (tcon->ses->domainName)seq_printf (s,",domain=%s" , tcon->ses->domainName); +if (tcon->ses->server->ip4_local_ip) +seq_printf (s,",bindaddr=%pI4" , + &tcon->ses->server->ip4_local_ip); +seq_printf (s,",uid=%d" , cifs_sb->mnt_uid);if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_OVERR_UID )seq_printf (s,",forceuid" );fs/cifs/cifsglob.h +1
-0@@ -157,6 +157,7 @@ struct TCP_Server_Info {struct sockaddr_in sockAddr;struct sockaddr_in6 sockAddr6; } addr; +u32 ip4_local_ip;wait_queue_head_t response_q;wait_queue_head_t request_q;/* if more than maxmpx to srvr must block*/ struct list_head pending_mid_q;fs/cifs/connect.c +44
-2@@ -105,6 +105,7 @@ struct smb_vol { bool sockopt_tcp_nodelay:1;unsigned short int port;char *prepath; +u32 local_ip;/* allow binding to a local IP address if != 0 */ struct nls_table *local_nls; };@@ -1064,6 +1065,32 @@ cifs_parse_mount_options(char *options, const char *devname, "long\n");return 1 ; } + }else if (strnicmp (data,"bindaddr" ,8 ) ==0 ) { +struct sockaddr_storage laddr; +memset (&laddr,0 ,sizeof (laddr)); + +if (!value || !*value) { +printk (KERN_WARNING "CIFS: bindaddr value" +" not specified.\n" ); +return 1 ;/* needs_arg; */ + } + i =cifs_convert_address ((struct sockaddr *)(&laddr), + value,strlen (value)); +if (i <0 ) { + vol->local_ip =0 ; +printk (KERN_WARNING "CIFS: Could not parse" +" bindaddr: %s\n" , + value); +return 1 ; + }else { +struct sockaddr_in *s4; + s4 = (struct sockaddr_in *)&laddr; +if (s4->sin_family ==AF_INET ) + vol->local_ip = s4->sin_addr.s_addr; +else +printk (KERN_WARNING "WARNING: IPv6 " +"bindaddr not supported yet.\n" ); + } }else if (strnicmp (data,"prefixpath" ,10 ) ==0 ) {if (!value || !*value) { printk(KERN_WARNING@@ -1393,7 +1420,8 @@ cifs_parse_mount_options(char *options, const char *devname, }static bool -match_address (struct TCP_Server_Info *server,struct sockaddr *addr) +match_address (struct TCP_Server_Info *server,struct sockaddr *addr, +u32 local_ip4) {struct sockaddr_in *addr4 = (struct sockaddr_in *)addr;struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr;@@ -1406,6 +1434,8 @@ match_address(struct TCP_Server_Info *server, struct sockaddr *addr)if (addr4->sin_port && addr4->sin_port != server->addr.sockAddr.sin_port)return false; +if (local_ip4 && (local_ip4 != server->ip4_local_ip)) +return false;break ;case AF_INET6 : if (!ipv6_addr_equal(&addr6->sin6_addr,@@ -1487,7 +1517,7 @@ cifs_find_tcp_session(struct sockaddr *addr, struct smb_vol *vol)if (server->tcpStatus == CifsNew)continue ; -if (!match_address (server, addr)) +if (!match_address (server, addr, vol->local_ip))continue ;if (!match_security (server, vol))@@ -1602,6 +1632,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)* no need to spinlock this init of tcpStatus or srv_count */ tcp_ses->tcpStatus = CifsNew; + tcp_ses->ip4_local_ip = volume_info->local_ip; ++tcp_ses->srv_count;if (addr.ss_family ==AF_INET6 ) {@@ -1678,6 +1709,10 @@ cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb_vol *vol) vol->password ? vol->password :"" , MAX_PASSWORD_SIZE)) continue; +if (server->ip4_local_ip && + (server->ip4_local_ip != ses->server->ip4_local_ip)) +continue ; +/* TODO: Deal with IPv6 local addr matching? --Ben */ } ++ses->ses_count;write_unlock (&cifs_tcp_ses_lock);@@ -2051,6 +2086,20 @@ ipv4_connect(struct TCP_Server_Info *server)cifs_reclassify_socket4 (socket); } +/* Bind to the local IP address if specified */ +if (server->ip4_local_ip) { +struct sockaddr_in myaddr = { + .sin_family =AF_INET , + }; + myaddr.sin_addr.s_addr = server->ip4_local_ip; + myaddr.sin_port =0 ;/* any */
fs/cifs/connect.c ipv4_connect(struct TCP_Server_Info *server) · line 2105
Quoted 10 lines
fs/cifs/connect.c +7
-0+ rc = socket->ops->bind (socket, (struct sockaddr *) &myaddr, +sizeof (myaddr)); +if (rc <0 ) +cERROR (1 ,"Failed to bind to: %pI4, error: %d\n" , + &server->ip4_local_ip, rc); + } +/* user overrode default port */ if (server->addr.sockAddr.sin_port) { rc = socket->ops->connect(socket, (struct sockaddr *)
I'm not crazy about this patch. It seems like this ought to be the purview of the routing table. I know however that there are situations where that's not really possible (clusters with floating IP addrs, for instance).
That said, even if we were to do something along these lines, it seems like it ought to be more transport neutral (i.e. not IPv4 only like this patch is).
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20100826155733.6eccc377-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
There are clearly valid reasons for being able to select outgoing interface - I wouldn't mind doing this using IPv6 address format if that is more natural (since that can include ipv4 addresses) - or distinct ipv4/ipv6
Quoted 177 lines · Jeff Layton
Quoted 146 lines · On Thu, 26 Aug 2010 10:34:56 -0700 Ben Greear…
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 bindaddr=192.168.1.50,user=foo, ...
Signed-off-by Ben Greear <greearb-my8/[email protected]>---
:100644 100644 b7431af... 77293db... M fs/cifs/cifsfs.c :100644 100644 c9d0cfc... c0176d8... M fs/cifs/cifsglob.h :100644 100644 ec0ea4a... bacbf46... M fs/cifs/connect.cfs/cifs/cifsfs.c| 4 +++
fs/cifs/cifsglob.h | 1 +
fs/cifs/connect.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++-3 files changed, 56 insertions(+), 2 deletions(-)fs/cifs/cifsfs.c +4
-0@@ -374,6 +374,10 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m) if (tcon->ses->domainName) seq_printf(s, ",domain=%s", tcon->ses->domainName); + if (tcon->ses->server->ip4_local_ip) + seq_printf(s, ",bindaddr=%pI4", + &tcon->ses->server->ip4_local_ip); + seq_printf(s, ",uid=%d", cifs_sb->mnt_uid); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) seq_printf(s, ",forceuid");fs/cifs/cifsglob.h +1
-0@@ -157,6 +157,7 @@ struct TCP_Server_Info { struct sockaddr_in sockAddr; struct sockaddr_in6 sockAddr6; } addr; + u32 ip4_local_ip; wait_queue_head_t response_q;
wait_queue_head_trequest_q; /* if more than maxmpx to srvr must block*/ structlist_headpending_mid_q;fs/cifs/connect.c +27
-0@@ -105,6 +105,7 @@ struct smb_vol { bool sockopt_tcp_nodelay:1; unsigned short int port; char *prepath; + u32 local_ip; /* allow binding to a local IP address if != 0 */ struct nls_table *local_nls; };@@ -1064,6 +1065,32 @@ cifs_parse_mount_options(char *options, const char *devname, "long\n"); return 1; } + } else if (strnicmp(data, "bindaddr", 8) == 0) { + struct sockaddr_storage laddr; + memset(&laddr, 0, sizeof(laddr)); + + if (!value || !*value) { + printk(KERN_WARNING "CIFS: bindaddr value" + " not specified.\n"); + return 1; /* needs_arg; */ + } + i = cifs_convert_address((struct sockaddr *)(&laddr), + value, strlen(value)); + if (i < 0) { + vol->local_ip = 0; + printk(KERN_WARNING "CIFS: Could not parse" + " bindaddr: %s\n", + value); + return 1; + } else { + struct sockaddr_in *s4; + s4 = (struct sockaddr_in *)&laddr; + if (s4->sin_family == AF_INET) + vol->local_ip = s4->sin_addr.s_addr; + else + printk(KERN_WARNING "WARNING: IPv6 " + "bindaddr not supported yet.\n"); + } } else if (strnicmp(data, "prefixpath", 10) == 0) { if (!value || !*value) {printk(KERN_WARNING
fs/cifs/connect.c +0
-0@@ -1393,7 +1420,8 @@ cifs_parse_mount_options(char *options, const char *devname, }static bool
fs/cifs/connect.c +2
-1-match_address(struct TCP_Server_Info *server, struct sockaddr *addr) +match_address(struct TCP_Server_Info *server, struct sockaddr *addr, + u32 local_ip4){
structsockaddr_in*addr4 = (structsockaddr_in*)addr; structsockaddr_in6*addr6 = (structsockaddr_in6*)addr;fs/cifs/connect.c +0
-0@@ -1406,6 +1434,8 @@ match_address(struct TCP_Server_Info *server, struct sockaddr *addr)if (
addr4->sin_port&&
addr4->sin_port!=server->addr.sockAddr.sin_port) return false;
+ if (local_ip4&& (local_ip4!=server->ip4_local_ip))
+ return false;
break;
caseAF_INET6:
if (!ipv6_addr_equal(&addr6->sin6_addr,fs/cifs/connect.c +13
-1@@ -1487,7 +1517,7 @@ cifs_find_tcp_session(struct sockaddr *addr, struct smb_vol *vol) if (server->tcpStatus == CifsNew) continue; - if (!match_address(server, addr)) + if (!match_address(server, addr, vol->local_ip)) continue; if (!match_security(server, vol))@@ -1602,6 +1632,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)* no need to spinlock this init of tcpStatus or srv_count */ tcp_ses->tcpStatus = CifsNew; + tcp_ses->ip4_local_ip = volume_info->local_ip; ++tcp_ses->srv_count; if (addr.ss_family == AF_INET6) {@@ -1678,6 +1709,10 @@ cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb_vol *vol) vol->password ? vol->password : "", MAX_PASSWORD_SIZE)) continue; + if (server->ip4_local_ip && + (server->ip4_local_ip != ses->server->ip4_local_ip)) + continue; + /* TODO: Deal with IPv6 local addr matching? --Ben */ } ++ses->ses_count; write_unlock(&cifs_tcp_ses_lock);@@ -2051,6 +2086,20 @@ ipv4_connect(struct TCP_Server_Info *server) cifs_reclassify_socket4(socket); } + /* Bind to the local IP address if specified */ + if (server->ip4_local_ip) { + struct sockaddr_in myaddr = { + .sin_family = AF_INET, + }; + myaddr.sin_addr.s_addr = server->ip4_local_ip; + myaddr.sin_port = 0; /* any */fs/cifs/connect.c ipv4_connect(struct TCP_Server_Info *server) · line 2105
Quoted 10 lines
fs/cifs/connect.c +7
-0+ rc = socket->ops->bind(socket, (struct sockaddr *) &myaddr, + sizeof(myaddr)); + if (rc < 0) + cERROR(1, "Failed to bind to: %pI4, error: %d\n", + &server->ip4_local_ip, rc); + } + /* user overrode default port */ if (server->addr.sockAddr.sin_port) { rc = socket->ops->connect(socket, (struct sockaddr *)I'm not crazy about this patch. It seems like this ought to be the purview of the routing table. I know however that there are situations where that's not really possible (clusters with floating IP addrs, for instance).
That said, even if we were to do something along these lines, it seems like it ought to be more transport neutral (i.e. not IPv4 only like this patch is).
--
Jeff Layton <[email protected]> --
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): AANLkTikdghfNW0Qq9DkWk8a363EYvKHQn65iOn0ni6e7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 5 lines · On Thu, 26 Aug 2010 18:36:54 -0500 Steve French…
There are clearly valid reasons for being able to select outgoing interface - I wouldn't mind doing this using IPv6 address format if that is more natural (since that can include ipv4 addresses) - or distinct ipv4/ipv6
The patch already uses cifs_convert_address which handles IPv4 or IPv6 addresses just fine. I don't think it would be that difficult to optionally store a v4 or v6 address to bind socket.
You'll also need to think about what this means for ip address selection in the mount helper. It'll need to be modified to make sure that the address families between the two match. What happens if someone specifies and IPv4 bindaddr, and the host in the UNC resolves to an IPv6 address?
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20100827095433.26bb3c3e-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org
Quoted 5 lines · Jeff Layton
Quoted 3 lines
Also, I think bindaddr might not be the best name for the option. How about sourceaddr or srcaddr?
Sounds reasonable.
It doesn't matter to me. Please tell me which one you want me to use and I'll work on re-spinning this patch with ipv6 support.
Thanks,
Ben
Signature · 2 lines
Ben Greear <greearb-my8/[email protected]> Candela Technologies Inc http://www.candelatech.com
A message that is not in the archive (sent off-list or not yet received): 4C77D9ED.4050101-my8/[email protected]
Quoted 6 lines · On Fri, 27 Aug 2010 08:29:49 -0700 Ben Greear…
Quoted 4 lines · Jeff Layton
Quoted 3 lines
Also, I think bindaddr might not be the best name for the option. How about sourceaddr or srcaddr?
Quoted 8 lines
Quoted 1 line
Sounds reasonable.
It doesn't matter to me. Please tell me which one you want me to use and I'll work on re-spinning this patch with ipv6 support.
Thanks,
Ben
My preference would be "srcaddr=".
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20100827125242.0798ffe9-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Quoted 11 lines · Jeff Layton
Quoted 8 lines · On Fri, 27 Aug 2010 08:29:49 -0700 Ben Greear…
Quoted 5 lines · Jeff Layton
Quoted 3 lines
Also, I think bindaddr might not be the best name for the option. How about sourceaddr or srcaddr?
Sounds reasonable.
Quoted 8 lines
Quoted 6 lines
It doesn't matter to me. Please tell me which one you want me to use and I'll work on re-spinning this patch with ipv6 support.
Thanks,
BenMy preference would be "srcaddr=".
Shorter is good ...
srcaddr wins unless we have a particular compatibility objective with other fs mounts (ie an existing mount option - which so far I have not been able to find).
For completeness we should consider, at least briefly, one alternative name. Note that smb.conf (and thus smbclient indirectly uses this) can override the local interface using the optional smb.conf parm
"interfaces" - we could shorten this to "interface" If anyone feels
strongly about this being better ...
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): AANLkTim-Hsn77fJUR1TrM_szVaJ3_vYzw61j0GYMt+Rr-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 26 lines · Steve French
Quoted 11 lines · Jeff Layton
Quoted 8 lines · On Fri, 27 Aug 2010 08:29:49 -0700 Ben Greear<greearb-my8/4N5VtI7c+919tysfdA@pu…
Quoted 5 lines · Jeff Layton
Quoted 3 lines
Also, I think bindaddr might not be the best name for the option. How about sourceaddr or srcaddr?
Sounds reasonable.
Quoted 8 lines
Quoted 6 lines
It doesn't matter to me. Please tell me which one you want me to use and I'll work on re-spinning this patch with ipv6 support.
Thanks,
BenMy preference would be "srcaddr=".
Shorter is good ...
srcaddr wins unless we have a particular compatibility objective with other fs mounts (ie an existing mount option - which so far I have not been able to find).
Quoted 5 lines
For completeness we should consider, at least briefly, one alternative name. Note that smb.conf (and thus smbclient indirectly uses this) can override the local interface using the optional smb.conf parm
"interfaces" - we could shorten this to "interface" If anyone feels
strongly about this being better ...
I don't like that, as we're binding to IPs, not interfaces.
If we ever need to support SO_BINDTODEV logic, then could use interface= for that.
srcaddr= sounds fine to me.
Thanks,
Ben
Quoted 2 lines
Signature · 2 lines
Ben Greear <greearb-my8/[email protected]> Candela Technologies Inc http://www.candelatech.com
A message that is not in the archive (sent off-list or not yet received): 4C77F1F0.4070800-my8/[email protected]
Quoted 33 lines · On Fri, 27 Aug 2010 10:12:16 -0700 Ben Greear…
Quoted 26 lines · Steve French
Quoted 11 lines · Jeff Layton
Quoted 8 lines · On Fri, 27 Aug 2010 08:29:49 -0700 Ben Greear<greearb-my8/4N5VtI7c+919tysfdA@pu…
Quoted 5 lines · Jeff Layton
Quoted 3 lines
Also, I think bindaddr might not be the best name for the option. How about sourceaddr or srcaddr?
Sounds reasonable.
Quoted 8 lines
Quoted 6 lines
It doesn't matter to me. Please tell me which one you want me to use and I'll work on re-spinning this patch with ipv6 support.
Thanks,
BenMy preference would be "srcaddr=".
Shorter is good ...
srcaddr wins unless we have a particular compatibility objective with other fs mounts (ie an existing mount option - which so far I have not been able to find).Quoted 5 lines
For completeness we should consider, at least briefly, one alternative name. Note that smb.conf (and thus smbclient indirectly uses this) can override the local interface using the optional smb.conf parm
"interfaces" - we could shorten this to "interface" If anyone feels
strongly about this being better ...
Quoted 7 lines
I don't like that, as we're binding to IPs, not interfaces.
If we ever need to support
SO_BINDTODEVlogic, then could use interface= for that.srcaddr= sounds fine to me.
Agreed. The samba config option seems poorly named in that regard. They're sort of stuck with it though for legacy reasons, but there's no reason to saddle cifs with it.
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20100827133401.75eb7f7f-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Quoted 38 lines · Jeff Layton
Quoted 35 lines · On Fri, 27 Aug 2010 10:12:16 -0700 Ben Greear…
Quoted 26 lines · Steve French
Quoted 11 lines · Jeff Layton
Quoted 8 lines · On Fri, 27 Aug 2010 08:29:49 -0700 Ben Greear<greearb-my8/4N5VtI7c+919tysfdA@pu…
Quoted 5 lines · Jeff Layton
Quoted 3 lines
Also, I think bindaddr might not be the best name for the option. How about sourceaddr or srcaddr?
Sounds reasonable.
Quoted 8 lines
Quoted 6 lines
It doesn't matter to me. Please tell me which one you want me to use and I'll work on re-spinning this patch with ipv6 support.
Thanks,
BenMy preference would be "srcaddr=".
Shorter is good ...
srcaddr wins unless we have a particular compatibility objective with other fs mounts (ie an existing mount option - which so far I have not been able to find).Quoted 5 lines
For completeness we should consider, at least briefly, one alternative name. Note that smb.conf (and thus smbclient indirectly uses this) can override the local interface using the optional smb.conf parm "interfaces" - we could shorten this to "interface" If anyone feels strongly about this being better ...
I don't like that, as we're binding to IPs, not interfaces.
Quoted 8 lines
Quoted 5 lines
If we ever need to support
SO_BINDTODEVlogic, then could use interface= for that.srcaddr= sounds fine to me.
Agreed.
OK - srcaddr it is ...
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): AANLkTikDjbWv0F18WevNbsfJyutEu28RCCgtmp1=ZBd4-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Updated patch is attached. It *should* support IPv4 & IPv6, but I've only tested IPv4 to date. I need to work on my test rig before I can test v6, hopefully will get that done in a day or two.
Thanks,
Ben
Signature · 2 lines
Ben Greear <greearb-my8/[email protected]> Candela Technologies Inc http://www.candelatech.com
fs/cifs/cifsfs.c +31 -0
@@ -357,6 +357,24 @@ cifs_show_address(struct seq_file *s, struct TCP_Server_Info *server) } } +bool +cifs_addr_is_specified (struct sockaddr * srcaddr) { +struct sockaddr_in *saddr4 = (struct sockaddr_in *)srcaddr; +struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *)srcaddr; +switch (srcaddr->sa_family) { +case AF_INET : +return saddr4->sin_addr.s_addr !=0 ; + +#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +case AF_INET6 : +/* in6addr_any isn't available if IPv6 isn't compiled in */ +return (memcmp (&in6addr_any, &saddr6->sin6_addr, +sizeof (in6addr_any)) ==0 ); +#endif + } +return false; +} +/* * cifs_show_options() is for displaying mount options in /proc/mounts. * Not all settable options are displayed but most of the important
@@ -374,6 +392,19 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)if (tcon->ses->domainName)seq_printf (s,",domain=%s" , tcon->ses->domainName); +if (cifs_addr_is_specified ((struct sockaddr *)(&tcon->ses->server->srcaddr))) { +struct sockaddr_in *saddr4; +struct sockaddr_in6 *saddr6; + saddr4 = (struct sockaddr_in *)&tcon->ses->server->srcaddr; + saddr6 = (struct sockaddr_in6 *)&tcon->ses->server->srcaddr; +if (saddr6->sin6_family ==AF_INET6 ) +seq_printf (s,",srcaddr=%pI6" , + &saddr6->sin6_addr); +else +seq_printf (s,",srcaddr=%pI4" , + &saddr4->sin_addr.s_addr); + } +seq_printf (s,",uid=%d" , cifs_sb->mnt_uid);if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_OVERR_UID )seq_printf (s,",forceuid" );
fs/cifs/cifsfs.h +3 -0
@@ -110,6 +110,9 @@ extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);extern ssize_t cifs_listxattr (struct dentry *,char *,size_t );extern long cifs_ioctl (struct file *filep,unsigned int cmd,unsigned long arg); +struct sockaddr ; +extern bool cifs_addr_is_specified (struct sockaddr * srcaddr); +#ifdef CONFIG_CIFS_EXPERIMENTAL extern const struct export_operations cifs_export_ops;#endif /* EXPERIMENTAL */
fs/cifs/cifsglob.h +1 -0
@@ -157,6 +157,7 @@ struct TCP_Server_Info {struct sockaddr_in sockAddr;struct sockaddr_in6 sockAddr6; } addr; +struct sockaddr_storage srcaddr;/* locally bind to this IP */ wait_queue_head_t response_q;wait_queue_head_t request_q;/* if more than maxmpx to srvr must block*/ struct list_head pending_mid_q;
fs/cifs/connect.c +74 -2
131 lines not on this page · raw message
net/ipv6/addrconf.c +2 -0
@@ -234,6 +234,8 @@ const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;const struct in6_addr in6addr_linklocal_allnodes =IN6ADDR_LINKLOCAL_ALLNODES_INIT ;const struct in6_addr in6addr_linklocal_allrouters =IN6ADDR_LINKLOCAL_ALLROUTERS_INIT ; +EXPORT_SYMBOL (in6addr_any); +/* Check if a valid qdisc is available */ static inline bool addrconf_qdisc_ok (const struct net_device *dev) {