mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-12 16:58:53 +00:00
[CIFS] cifs_find_tcp_session cleanup
This patch cleans up cifs_find_tcp_session so it become less indented. Also the error of skipping IPv6 matched addresses fixed. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
5bb7ff795f
commit
1b20d67218
@ -1318,42 +1318,43 @@ cifs_parse_mount_options(char *options, const char *devname,
|
|||||||
|
|
||||||
static struct cifsSesInfo *
|
static struct cifsSesInfo *
|
||||||
cifs_find_tcp_session(struct in_addr *target_ip_addr,
|
cifs_find_tcp_session(struct in_addr *target_ip_addr,
|
||||||
struct in6_addr *target_ip6_addr,
|
struct in6_addr *target_ip6_addr,
|
||||||
char *userName, struct TCP_Server_Info **psrvTcp)
|
char *userName, struct TCP_Server_Info **psrvTcp)
|
||||||
{
|
{
|
||||||
struct list_head *tmp;
|
struct list_head *tmp;
|
||||||
struct cifsSesInfo *ses;
|
struct cifsSesInfo *ses;
|
||||||
*psrvTcp = NULL;
|
|
||||||
read_lock(&GlobalSMBSeslock);
|
|
||||||
|
|
||||||
|
*psrvTcp = NULL;
|
||||||
|
|
||||||
|
read_lock(&GlobalSMBSeslock);
|
||||||
list_for_each(tmp, &GlobalSMBSessionList) {
|
list_for_each(tmp, &GlobalSMBSessionList) {
|
||||||
ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
|
ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
|
||||||
if (ses->server) {
|
if (!ses->server)
|
||||||
if ((target_ip_addr &&
|
continue;
|
||||||
(ses->server->addr.sockAddr.sin_addr.s_addr
|
|
||||||
== target_ip_addr->s_addr)) || (target_ip6_addr
|
|
||||||
&& memcmp(&ses->server->addr.sockAddr6.sin6_addr,
|
|
||||||
target_ip6_addr, sizeof(*target_ip6_addr)))) {
|
|
||||||
/* BB lock server and tcp session and increment
|
|
||||||
use count here?? */
|
|
||||||
|
|
||||||
/* found a match on the TCP session */
|
if (target_ip_addr &&
|
||||||
*psrvTcp = ses->server;
|
ses->server->addr.sockAddr.sin_addr.s_addr != target_ip_addr->s_addr)
|
||||||
|
continue;
|
||||||
|
else if (target_ip6_addr &&
|
||||||
|
memcmp(&ses->server->addr.sockAddr6.sin6_addr,
|
||||||
|
target_ip6_addr, sizeof(*target_ip6_addr)))
|
||||||
|
continue;
|
||||||
|
/* BB lock server and tcp session and increment use count here?? */
|
||||||
|
|
||||||
/* BB check if reconnection needed */
|
/* found a match on the TCP session */
|
||||||
if (strncmp
|
*psrvTcp = ses->server;
|
||||||
(ses->userName, userName,
|
|
||||||
MAX_USERNAME_SIZE) == 0){
|
/* BB check if reconnection needed */
|
||||||
read_unlock(&GlobalSMBSeslock);
|
if (strncmp(ses->userName, userName, MAX_USERNAME_SIZE) == 0) {
|
||||||
/* Found exact match on both TCP and
|
read_unlock(&GlobalSMBSeslock);
|
||||||
SMB sessions */
|
/* Found exact match on both TCP and
|
||||||
return ses;
|
SMB sessions */
|
||||||
}
|
return ses;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* else tcp and smb sessions need reconnection */
|
/* else tcp and smb sessions need reconnection */
|
||||||
}
|
}
|
||||||
read_unlock(&GlobalSMBSeslock);
|
read_unlock(&GlobalSMBSeslock);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user