Skip to content

Commit

Permalink
[CIFS] cifs_find_tcp_session cleanup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Cyrill Gorcunov authored and Steve French committed May 11, 2008
1 parent 5bb7ff7 commit 1b20d67
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1318,42 +1318,43 @@ cifs_parse_mount_options(char *options, const char *devname,

static struct cifsSesInfo *
cifs_find_tcp_session(struct in_addr *target_ip_addr,
struct in6_addr *target_ip6_addr,
char *userName, struct TCP_Server_Info **psrvTcp)
struct in6_addr *target_ip6_addr,
char *userName, struct TCP_Server_Info **psrvTcp)
{
struct list_head *tmp;
struct cifsSesInfo *ses;

*psrvTcp = NULL;
read_lock(&GlobalSMBSeslock);

read_lock(&GlobalSMBSeslock);
list_for_each(tmp, &GlobalSMBSessionList) {
ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
if (ses->server) {
if ((target_ip_addr &&
(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 */
*psrvTcp = ses->server;

/* BB check if reconnection needed */
if (strncmp
(ses->userName, userName,
MAX_USERNAME_SIZE) == 0){
read_unlock(&GlobalSMBSeslock);
/* Found exact match on both TCP and
SMB sessions */
return ses;
}
}
if (!ses->server)
continue;

if (target_ip_addr &&
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?? */

/* found a match on the TCP session */
*psrvTcp = ses->server;

/* BB check if reconnection needed */
if (strncmp(ses->userName, userName, MAX_USERNAME_SIZE) == 0) {
read_unlock(&GlobalSMBSeslock);
/* Found exact match on both TCP and
SMB sessions */
return ses;
}
/* else tcp and smb sessions need reconnection */
}
read_unlock(&GlobalSMBSeslock);

return NULL;
}

Expand Down

0 comments on commit 1b20d67

Please sign in to comment.