[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:
Cyrill Gorcunov 2008-05-09 18:17:21 +00:00 committed by Steve French
parent 5bb7ff795f
commit 1b20d67218

View File

@ -1323,37 +1323,38 @@ cifs_find_tcp_session(struct in_addr *target_ip_addr,
{ {
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 if (target_ip_addr &&
&& memcmp(&ses->server->addr.sockAddr6.sin6_addr, ses->server->addr.sockAddr.sin_addr.s_addr != target_ip_addr->s_addr)
target_ip6_addr, sizeof(*target_ip6_addr)))) { continue;
/* BB lock server and tcp session and increment else if (target_ip6_addr &&
use count here?? */ 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 */ /* found a match on the TCP session */
*psrvTcp = ses->server; *psrvTcp = ses->server;
/* BB check if reconnection needed */ /* BB check if reconnection needed */
if (strncmp if (strncmp(ses->userName, userName, MAX_USERNAME_SIZE) == 0) {
(ses->userName, userName,
MAX_USERNAME_SIZE) == 0){
read_unlock(&GlobalSMBSeslock); read_unlock(&GlobalSMBSeslock);
/* Found exact match on both TCP and /* Found exact match on both TCP and
SMB sessions */ SMB sessions */
return ses; 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;
} }