Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1657003lqp; Mon, 15 Apr 2024 12:52:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURfYsaTC6w+2F/DvY0pJaLeBnxyfWS6n252cKPZp72AfAaxFymTdwqyN476xEeDfCOgqthI7ucScXSIqEQWL1xPuFRCXdwOdWe0Fq7kA== X-Google-Smtp-Source: AGHT+IGoRrI1YJgvKPfYGQ89ZqPQsxfgo/Ze03aVTDMkeuP9p2TbZL1D2wAKW/tPBRmL6ZoIiFis X-Received: by 2002:a05:6a20:3c8e:b0:1a7:89bd:9e8d with SMTP id b14-20020a056a203c8e00b001a789bd9e8dmr10925275pzj.7.1713210766454; Mon, 15 Apr 2024 12:52:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713210766; cv=pass; d=google.com; s=arc-20160816; b=bVrGxRPp5v5sU1XRdR6/p/XrnhTgtapXmsMSRtrSgKwNfmU5Rc5dgFTcaYIWm0BIMZ I9JX4daNNF+X0ZHA6GJaNWwUn38yFBJure6uzKz2irU/mttHZKfcLDR6/Lnw/w1ubI0M Z04aZKSdedsco6t6QW7le6huC9Dc2q+8sVxerI0T2lIHOZN7nruIEAJjjhsGvDDAUxRY 8NjsaSToFTZDoZpsDnXYyb959Ost4lfhpor0jOg0KEYW1A/kEiE2H3b/ryUVTc475eM6 jr8jSINESYmIB0MMB+4fxpWHpBbjc+VSWT+5l1s4MoSCAMWAexv9OqFQkEMV19TjsDgY IW9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6nVdSjngkWVfZW/klTk1Gam9Kn7Wmte4q8SiCgMDV9w=; fh=uaqw4UYaONZI1vwXmlZ+vlVmGAaApYn8V3wDqNrAb2o=; b=iw/S6W3IVb6d6KLLMzTCeGVS3Ldt1cUBTdaO5mEkiXIK/ByrunWQpAU3uGNlwpeGoJ jeQcFkUK052lNKDNUn6eC2N6e9EiUXAdlVcIyyLM+gd6V+0RmMa3FPscwbHVmEjEbwl2 NfazyPBoKjLArh67rv+k6hUhhsvAT3wyYHcbo9kylTPuRGyZShuwhNa9lhW/CScibbVd OcL5jjXtYvBfetp+HnpFLwVAahYXdUxLuoCONyLDf/vsKi5SwciOQ6wtRUW67/xyPMHz r6A/qYJPPPBTXhuEeS1A4ATLpqiO+t0gyxOZs5kR75zNpcAqSl9HPIqhAUW42kXdf8tz nhhg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uL1Qbw7D; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-2825-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2825-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n5-20020a637205000000b005dc48827a3asi8500124pgc.227.2024.04.15.12.52.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 12:52:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-2825-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uL1Qbw7D; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-2825-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2825-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7396F2812E5 for ; Mon, 15 Apr 2024 19:51:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30F3115CD44; Mon, 15 Apr 2024 19:45:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uL1Qbw7D" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09A16156997; Mon, 15 Apr 2024 19:45:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713210326; cv=none; b=H5PXCkLj+KsmVrBATsPBJpMB0AuINZJku8FPHUaZnvK5waUV6LuXkav5+CTrBhzqYpviF5OeGhxycTRv+IOS3XH4Yk6ecUItPqcWnHDYtJdWLth+KHDGdXqA2FXY2Y/8cZy9uBxXtnLXbS6CIVLT31/YB5UPIgGHvBph4IK08FM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713210326; c=relaxed/simple; bh=u1MIVeEB9jfAKl7VCceRlD6fHf4D2LjW0+JisF5Qw84=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F66ieZmnDgic+dia3BOaKpQUFVhDkot4znxIgNm0tBu/CMcixI2xuIaTu0JP/us80glBdf3dyw6xI7LLEamv1YM6KpOuKAhU9/z5OB9DtXRMbUMnd6OCa2R3oFDBmIxlldeUYZqbUJlmm+cc4Fp8mFeBmjKGiuseQPmt2u7ACAU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uL1Qbw7D; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 498B4C113CC; Mon, 15 Apr 2024 19:45:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713210325; bh=u1MIVeEB9jfAKl7VCceRlD6fHf4D2LjW0+JisF5Qw84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uL1Qbw7D1Ia+IrOBHTci395fidsVWuJjfGeonpHEzyZ3NRvrMEjcArQ+Zcmt8Mndj dnOUpe1dGyejwQNj5FkJ/9HXWovplf8YNvrqvLNLpurnHOA9THB6vChlY8+58tiT7D FPcTDbFIF7q86zljCqIXy8qF73S7Z9beeldMo8IG8jDfwIRAq5GYWMDnXS7yYe81X1 LDsrIRuMKxzmOi4M/7jS+CAGNCP7aBTuQz18u+7cCaD5K8cve4xSVbkVgdIxYRG81S JtXrarU1mVpJCjfcRuvJVq8efITN4x+0HCiQxDIPoTrB4+6xYSqdwseqcyiVndf2cR LUJAQR61G5MDg== From: Lorenzo Bianconi To: linux-nfs@vger.kernel.org Cc: lorenzo.bianconi@redhat.com, chuck.lever@oracle.com, neilb@suse.de, netdev@vger.kernel.org, kuba@kernel.org, jlayton@kernel.org Subject: [PATCH v8 5/6] SUNRPC: add a new svc_find_listener helper Date: Mon, 15 Apr 2024 21:44:38 +0200 Message-ID: <00d60d4fb200e4d9762a03d0b561a61e92c7b071.1713209938.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jeff Layton svc_find_listener will return the transport instance pointer for the endpoint accepting connections/peer traffic from the specified transport class, and matching sockaddr. Signed-off-by: Jeff Layton Signed-off-by: Lorenzo Bianconi --- include/linux/sunrpc/svc_xprt.h | 2 ++ net/sunrpc/svc_xprt.c | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h index 0d9b10dbe07d..0981e35a9fed 100644 --- a/include/linux/sunrpc/svc_xprt.h +++ b/include/linux/sunrpc/svc_xprt.h @@ -150,6 +150,8 @@ void svc_xprt_copy_addrs(struct svc_rqst *rqstp, struct svc_xprt *xprt); void svc_xprt_close(struct svc_xprt *xprt); int svc_port_is_privileged(struct sockaddr *sin); int svc_print_xprts(char *buf, int maxlen); +struct svc_xprt *svc_find_listener(struct svc_serv *serv, const char *xcl_name, + struct net *net, const struct sockaddr *sa); struct svc_xprt *svc_find_xprt(struct svc_serv *serv, const char *xcl_name, struct net *net, const sa_family_t af, const unsigned short port); diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 463fe544ae28..34a3626c56b1 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -1276,6 +1276,40 @@ static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt) return dr; } +/** + * svc_find_listener - find an RPC transport instance + * @serv: pointer to svc_serv to search + * @xcl_name: C string containing transport's class name + * @net: owner net pointer + * @sa: sockaddr containing address + * + * Return the transport instance pointer for the endpoint accepting + * connections/peer traffic from the specified transport class, + * and matching sockaddr. + */ +struct svc_xprt *svc_find_listener(struct svc_serv *serv, const char *xcl_name, + struct net *net, const struct sockaddr *sa) +{ + struct svc_xprt *xprt; + struct svc_xprt *found = NULL; + + spin_lock_bh(&serv->sv_lock); + list_for_each_entry(xprt, &serv->sv_permsocks, xpt_list) { + if (xprt->xpt_net != net) + continue; + if (strcmp(xprt->xpt_class->xcl_name, xcl_name)) + continue; + if (!rpc_cmp_addr_port(sa, (struct sockaddr *)&xprt->xpt_local)) + continue; + found = xprt; + svc_xprt_get(xprt); + break; + } + spin_unlock_bh(&serv->sv_lock); + return found; +} +EXPORT_SYMBOL_GPL(svc_find_listener); + /** * svc_find_xprt - find an RPC transport instance * @serv: pointer to svc_serv to search -- 2.44.0