[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>

authored by Cyrill Gorcunov and committed by Steve French 1b20d672 5bb7ff79

+25 -24
+25 -24
fs/cifs/connect.c
··· 1318 1319 static struct cifsSesInfo * 1320 cifs_find_tcp_session(struct in_addr *target_ip_addr, 1321 - struct in6_addr *target_ip6_addr, 1322 - char *userName, struct TCP_Server_Info **psrvTcp) 1323 { 1324 struct list_head *tmp; 1325 struct cifsSesInfo *ses; 1326 - *psrvTcp = NULL; 1327 - read_lock(&GlobalSMBSeslock); 1328 1329 list_for_each(tmp, &GlobalSMBSessionList) { 1330 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 1331 - if (ses->server) { 1332 - if ((target_ip_addr && 1333 - (ses->server->addr.sockAddr.sin_addr.s_addr 1334 - == target_ip_addr->s_addr)) || (target_ip6_addr 1335 - && memcmp(&ses->server->addr.sockAddr6.sin6_addr, 1336 - target_ip6_addr, sizeof(*target_ip6_addr)))) { 1337 - /* BB lock server and tcp session and increment 1338 - use count here?? */ 1339 1340 - /* found a match on the TCP session */ 1341 - *psrvTcp = ses->server; 1342 1343 - /* BB check if reconnection needed */ 1344 - if (strncmp 1345 - (ses->userName, userName, 1346 - MAX_USERNAME_SIZE) == 0){ 1347 - read_unlock(&GlobalSMBSeslock); 1348 - /* Found exact match on both TCP and 1349 - SMB sessions */ 1350 - return ses; 1351 - } 1352 - } 1353 } 1354 /* else tcp and smb sessions need reconnection */ 1355 } 1356 read_unlock(&GlobalSMBSeslock); 1357 return NULL; 1358 } 1359
··· 1318 1319 static struct cifsSesInfo * 1320 cifs_find_tcp_session(struct in_addr *target_ip_addr, 1321 + struct in6_addr *target_ip6_addr, 1322 + char *userName, struct TCP_Server_Info **psrvTcp) 1323 { 1324 struct list_head *tmp; 1325 struct cifsSesInfo *ses; 1326 1327 + *psrvTcp = NULL; 1328 + 1329 + read_lock(&GlobalSMBSeslock); 1330 list_for_each(tmp, &GlobalSMBSessionList) { 1331 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 1332 + if (!ses->server) 1333 + continue; 1334 1335 + if (target_ip_addr && 1336 + ses->server->addr.sockAddr.sin_addr.s_addr != target_ip_addr->s_addr) 1337 + continue; 1338 + else if (target_ip6_addr && 1339 + memcmp(&ses->server->addr.sockAddr6.sin6_addr, 1340 + target_ip6_addr, sizeof(*target_ip6_addr))) 1341 + continue; 1342 + /* BB lock server and tcp session and increment use count here?? */ 1343 1344 + /* found a match on the TCP session */ 1345 + *psrvTcp = ses->server; 1346 + 1347 + /* BB check if reconnection needed */ 1348 + if (strncmp(ses->userName, userName, MAX_USERNAME_SIZE) == 0) { 1349 + read_unlock(&GlobalSMBSeslock); 1350 + /* Found exact match on both TCP and 1351 + SMB sessions */ 1352 + return ses; 1353 } 1354 /* else tcp and smb sessions need reconnection */ 1355 } 1356 read_unlock(&GlobalSMBSeslock); 1357 + 1358 return NULL; 1359 } 1360