aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2008-05-09 14:17:21 -0400
committerSteve French <sfrench@us.ibm.com>2008-05-11 13:45:43 -0400
commit1b20d672188bf80baef60d515a123f556871a5ce (patch)
tree84849ef20b010d86b3fd840ab988eef9bf25e25c
parent5bb7ff795fffc9418e3039cac77b42adcaae1a57 (diff)
[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>
-rw-r--r--fs/cifs/connect.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 791ca5c1a11..6b520aad7af 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1318,42 +1318,43 @@ cifs_parse_mount_options(char *options, const char *devname,
1318 1318
1319static struct cifsSesInfo * 1319static struct cifsSesInfo *
1320cifs_find_tcp_session(struct in_addr *target_ip_addr, 1320cifs_find_tcp_session(struct in_addr *target_ip_addr,
1321 struct in6_addr *target_ip6_addr, 1321 struct in6_addr *target_ip6_addr,
1322 char *userName, struct TCP_Server_Info **psrvTcp) 1322 char *userName, struct TCP_Server_Info **psrvTcp)
1323{ 1323{
1324 struct list_head *tmp; 1324 struct list_head *tmp;
1325 struct cifsSesInfo *ses; 1325 struct cifsSesInfo *ses;
1326
1326 *psrvTcp = NULL; 1327 *psrvTcp = NULL;
1327 read_lock(&GlobalSMBSeslock);
1328 1328
1329 read_lock(&GlobalSMBSeslock);
1329 list_for_each(tmp, &GlobalSMBSessionList) { 1330 list_for_each(tmp, &GlobalSMBSessionList) {
1330 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 1331 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
1331 if (ses->server) { 1332 if (!ses->server)
1332 if ((target_ip_addr && 1333 continue;
1333 (ses->server->addr.sockAddr.sin_addr.s_addr 1334
1334 == target_ip_addr->s_addr)) || (target_ip6_addr 1335 if (target_ip_addr &&
1335 && memcmp(&ses->server->addr.sockAddr6.sin6_addr, 1336 ses->server->addr.sockAddr.sin_addr.s_addr != target_ip_addr->s_addr)
1336 target_ip6_addr, sizeof(*target_ip6_addr)))) { 1337 continue;
1337 /* BB lock server and tcp session and increment 1338 else if (target_ip6_addr &&
1338 use count here?? */ 1339 memcmp(&ses->server->addr.sockAddr6.sin6_addr,
1339 1340 target_ip6_addr, sizeof(*target_ip6_addr)))
1340 /* found a match on the TCP session */ 1341 continue;
1341 *psrvTcp = ses->server; 1342 /* BB lock server and tcp session and increment use count here?? */
1342 1343
1343 /* BB check if reconnection needed */ 1344 /* found a match on the TCP session */
1344 if (strncmp 1345 *psrvTcp = ses->server;
1345 (ses->userName, userName, 1346
1346 MAX_USERNAME_SIZE) == 0){ 1347 /* BB check if reconnection needed */
1347 read_unlock(&GlobalSMBSeslock); 1348 if (strncmp(ses->userName, userName, MAX_USERNAME_SIZE) == 0) {
1348 /* Found exact match on both TCP and 1349 read_unlock(&GlobalSMBSeslock);
1349 SMB sessions */ 1350 /* Found exact match on both TCP and
1350 return ses; 1351 SMB sessions */
1351 } 1352 return ses;
1352 }
1353 } 1353 }
1354 /* else tcp and smb sessions need reconnection */ 1354 /* else tcp and smb sessions need reconnection */
1355 } 1355 }
1356 read_unlock(&GlobalSMBSeslock); 1356 read_unlock(&GlobalSMBSeslock);
1357
1357 return NULL; 1358 return NULL;
1358} 1359}
1359 1360