From patchwork Mon Jan 21 20:45:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 2014041 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3661540E35 for ; Mon, 21 Jan 2013 20:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932081Ab3AUUrz (ORCPT ); Mon, 21 Jan 2013 15:47:55 -0500 Received: from mail.candelatech.com ([208.74.158.172]:39899 "EHLO ns3.lanforge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932080Ab3AUUrz (ORCPT ); Mon, 21 Jan 2013 15:47:55 -0500 Received: from fs3.candelatech.com (firewall.candelatech.com [70.89.124.249]) by ns3.lanforge.com (8.14.2/8.14.2) with ESMTP id r0LKkDwv022791 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 21 Jan 2013 12:46:14 -0800 From: greearb@candelatech.com To: linux-nfs@vger.kernel.org Cc: Ben Greear Subject: [RFC 06/13] nfs: Use srcaddr in nfs_match_client. Date: Mon, 21 Jan 2013 12:45:52 -0800 Message-Id: <1358801159-18829-7-git-send-email-greearb@candelatech.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1358801159-18829-1-git-send-email-greearb@candelatech.com> References: <1358801159-18829-1-git-send-email-greearb@candelatech.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Ben Greear For bound clients, we have to make sure we do not re-use a client that is bound differently. Signed-off-by: Ben Greear --- fs/nfs/client.c | 10 ++++++++++ fs/nfs/internal.h | 2 ++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 809fd1e..e5230fe 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -408,6 +408,9 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) { const struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr; + const struct sockaddr *sa; + sa = (const struct sockaddr *)&clp->srcaddr; + /* Don't match clients that failed to initialise properly */ if (clp->cl_cons_state < 0) continue; @@ -425,6 +428,13 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat if (!nfs_sockaddr_cmp(sap, clap)) continue; + /* Check to make sure local-IP bindings match, + * but just the IP-addr. + */ + if (data->srcaddr && + !nfs_sockaddr_match_ipaddr(data->srcaddr, sa)) + continue; + atomic_inc(&clp->cl_count); return clp; } diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 11c5ac7..dbb2ee7 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -89,7 +89,9 @@ struct nfs_client_initdata { unsigned long init_flags; const char *hostname; const struct sockaddr *addr; + const struct sockaddr *srcaddr; size_t addrlen; + size_t srcaddrlen; struct nfs_subversion *nfs_mod; int proto; u32 minorversion;