mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Cyrill Gorcunov" <gorcunov@gmail.com>
To: "Steve French" <smfrench@gmail.com>
Cc: "Steve French" <sfrench@samba.org>, linux-kernel@vger.kernel.org
Subject: Re: [patch 2/2] cifs - cifs_find_tcp_session cleanup
Date: Wed, 7 May 2008 09:48:13 +0400	[thread overview]
Message-ID: <aa79d98a0805062248o3f8bc639n91f6ea89df2f6cd7@mail.gmail.com> (raw)
In-Reply-To: <524f69650805061507h5dab8731odeadb7602e0f38e4@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 274 bytes --]

On Wed, May 7, 2008 at 2:07 AM, Steve French <smfrench@gmail.com> wrote:
> This looks like it would fail in the ipv6 case - because
>  target_ip_addr (the ipv4 address) would be null and it would exit
>  before checking.
>

Steve, could you check an updated version, please

[-- Attachment #2: cifs-cifs_find_tcp_session-fix-cleanup-v2.patch --]
[-- Type: application/octet-stream, Size: 2465 bytes --]

---
From: Cyrill Gorcunov <gorcunov@gmail.com>
Subject: [PATCH] cifs - cifs_find_tcp_session fix/cleanup v2

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

--- a/fs/cifs/connect.c	Sun May 04 00:51:10 2008
+++ a/fs/cifs/connect.c	Wed May 07 08:49:12 2008
@@ -1318,42 +1318,43 @@ cifs_parse_mount_options(char *options, 
 
 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;
 }
 

  parent reply	other threads:[~2008-05-07  5:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080501154830.235254575@gmail.com>
2008-05-01 15:48 ` [patch 1/2] cifs - find_unc cleanup Cyrill Gorcunov
2008-05-06 22:06   ` Steve French
2008-05-01 15:48 ` [patch 2/2] cifs - cifs_find_tcp_session cleanup Cyrill Gorcunov
2008-05-06 22:07   ` Steve French
2008-05-07  4:17     ` Cyrill Gorcunov
2008-05-07  5:48     ` Cyrill Gorcunov [this message]
2008-05-09 18:55       ` Steve French

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aa79d98a0805062248o3f8bc639n91f6ea89df2f6cd7@mail.gmail.com \
    --to=gorcunov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfrench@samba.org \
    --cc=smfrench@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®