Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9118757pxu; Mon, 28 Dec 2020 07:06:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9GDtOXXC/UH6GPe3QV05XwcQX1nqXxfMvvtZq+k1VgSYUw2oYcOQRIxBakfP0+VN5BDqP X-Received: by 2002:a17:906:7fcd:: with SMTP id r13mr42703713ejs.242.1609167987520; Mon, 28 Dec 2020 07:06:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167987; cv=none; d=google.com; s=arc-20160816; b=EGe+OsNUxPmLWk2gAZm4zAkj0iGYSd/stFuBuHRm5EVYQ+DiOR44hzj/p/AQqZO8SV e6FhI+umbcuSpZiozTU1HTVnISx0ncqnoVN/JgpMgVpZwf3wRdqnz4P6I3S7Jyjbix8f b/svk9Nh3GOaOviVfWGAgpwm2jjZtuC68sq9J/oaYvk12siHzLXftOU3cFLXPJM7Opxd pwfBjtnNHaadudDEb9kWxnFijlK86TSyhesBJIAsiGm7D3EQ+geI0nUdY+Fj/iIujcsG GTSPEcUu+oOchQSZ1AMP88T8rMSrg9iWzlx40CPiB01KhZNmh0mZMv4kDxX5ycFs6s94 Po6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KrUk8oMxAYa4PcpkjpyLtal7mXXITlL/eWT2UgQnbHo=; b=L6moA284gNh4x3vOmAJZMR9lpwHj0jqLI2sYPBQiqMCC3EyFcV3D/lcgo2aPMgm1zm NbJ7lP7uQn2+G+9xUvInI1ktQK0Ekj9MaJgVNnIV53YMjVe1klqaLxKKUpcf9UoqGCU7 oq3LNs6SZ0QJmkieN/0OEE4ev0nwC2QLcQQM0vQlkC5h0jL75Ibb2aguZMmUwn1vZal2 oeaEdE/O8bCjGqee0pPJDmJABoM1FkI+xMPTMp2ulh/tBGafWOwifSBWE3JCGe1k6qT8 //V6yuzcf6SfuRMqTFkzssFCp7e5Ce9kI3Ij6Rf6pnnixc2YuNAw5tHieAok8hj50jbe ED5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tk4IjCOo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si25295743edi.2.2020.12.28.07.06.04; Mon, 28 Dec 2020 07:06:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tk4IjCOo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439907AbgL1OMi (ORCPT + 99 others); Mon, 28 Dec 2020 09:12:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:46920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439864AbgL1OM0 (ORCPT ); Mon, 28 Dec 2020 09:12:26 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0D216207A9; Mon, 28 Dec 2020 14:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164705; bh=7m2M/trcgLtzCEtgf0iEbytIDkf/I3M5V97+ZX5PsU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tk4IjCOoXKCA/SIrTsVv2dhXOgRJXMDq2v6+RJJ72weqG6zqmZrBkvvxCjwtJpcNh ts7oHoeB1XYQq6OEstICX7AJFyFCi/JgE3J9Yu6ZJmCQ9aSj3FbrFLjYF6MqzHeOuT PRQKW76iNHr1SWcdohO/KlhyHB1Csg7Y0acNi4Vg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 5.10 268/717] SUNRPC: xprt_load_transport() needs to support the netid "rdma6" Date: Mon, 28 Dec 2020 13:44:26 +0100 Message-Id: <20201228125033.852786357@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit d5aa6b22e2258f05317313ecc02efbb988ed6d38 ] According to RFC5666, the correct netid for an IPv6 addressed RDMA transport is "rdma6", which we've supported as a mount option since Linux-4.7. The problem is when we try to load the module "xprtrdma6", that will fail, since there is no modulealias of that name. Fixes: 181342c5ebe8 ("xprtrdma: Add rdma6 option to support NFS/RDMA IPv6") Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- include/linux/sunrpc/xprt.h | 1 + net/sunrpc/xprt.c | 65 +++++++++++++++++++++++++-------- net/sunrpc/xprtrdma/module.c | 1 + net/sunrpc/xprtrdma/transport.c | 1 + net/sunrpc/xprtsock.c | 4 ++ 5 files changed, 56 insertions(+), 16 deletions(-) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index a603d48d2b2cd..3ac5037d1c3da 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -330,6 +330,7 @@ struct xprt_class { struct rpc_xprt * (*setup)(struct xprt_create *); struct module *owner; char name[32]; + const char * netid[]; }; /* diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index f6c17e75f20ed..57f09ea3ef2af 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -151,31 +151,64 @@ out: } EXPORT_SYMBOL_GPL(xprt_unregister_transport); +static void +xprt_class_release(const struct xprt_class *t) +{ + module_put(t->owner); +} + +static const struct xprt_class * +xprt_class_find_by_netid_locked(const char *netid) +{ + const struct xprt_class *t; + unsigned int i; + + list_for_each_entry(t, &xprt_list, list) { + for (i = 0; t->netid[i][0] != '\0'; i++) { + if (strcmp(t->netid[i], netid) != 0) + continue; + if (!try_module_get(t->owner)) + continue; + return t; + } + } + return NULL; +} + +static const struct xprt_class * +xprt_class_find_by_netid(const char *netid) +{ + const struct xprt_class *t; + + spin_lock(&xprt_list_lock); + t = xprt_class_find_by_netid_locked(netid); + if (!t) { + spin_unlock(&xprt_list_lock); + request_module("rpc%s", netid); + spin_lock(&xprt_list_lock); + t = xprt_class_find_by_netid_locked(netid); + } + spin_unlock(&xprt_list_lock); + return t; +} + /** * xprt_load_transport - load a transport implementation - * @transport_name: transport to load + * @netid: transport to load * * Returns: * 0: transport successfully loaded * -ENOENT: transport module not available */ -int xprt_load_transport(const char *transport_name) +int xprt_load_transport(const char *netid) { - struct xprt_class *t; - int result; + const struct xprt_class *t; - result = 0; - spin_lock(&xprt_list_lock); - list_for_each_entry(t, &xprt_list, list) { - if (strcmp(t->name, transport_name) == 0) { - spin_unlock(&xprt_list_lock); - goto out; - } - } - spin_unlock(&xprt_list_lock); - result = request_module("xprt%s", transport_name); -out: - return result; + t = xprt_class_find_by_netid(netid); + if (!t) + return -ENOENT; + xprt_class_release(t); + return 0; } EXPORT_SYMBOL_GPL(xprt_load_transport); diff --git a/net/sunrpc/xprtrdma/module.c b/net/sunrpc/xprtrdma/module.c index 620327c01302c..45c5b41ac8dc9 100644 --- a/net/sunrpc/xprtrdma/module.c +++ b/net/sunrpc/xprtrdma/module.c @@ -24,6 +24,7 @@ MODULE_DESCRIPTION("RPC/RDMA Transport"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_ALIAS("svcrdma"); MODULE_ALIAS("xprtrdma"); +MODULE_ALIAS("rpcrdma6"); static void __exit rpc_rdma_cleanup(void) { diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c index 8915e42240d38..035060c05fd5a 100644 --- a/net/sunrpc/xprtrdma/transport.c +++ b/net/sunrpc/xprtrdma/transport.c @@ -768,6 +768,7 @@ static struct xprt_class xprt_rdma = { .owner = THIS_MODULE, .ident = XPRT_TRANSPORT_RDMA, .setup = xprt_setup_rdma, + .netid = { "rdma", "rdma6", "" }, }; void xprt_rdma_cleanup(void) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 7090bbee0ec59..c93ff70da3f98 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -3059,6 +3059,7 @@ static struct xprt_class xs_local_transport = { .owner = THIS_MODULE, .ident = XPRT_TRANSPORT_LOCAL, .setup = xs_setup_local, + .netid = { "" }, }; static struct xprt_class xs_udp_transport = { @@ -3067,6 +3068,7 @@ static struct xprt_class xs_udp_transport = { .owner = THIS_MODULE, .ident = XPRT_TRANSPORT_UDP, .setup = xs_setup_udp, + .netid = { "udp", "udp6", "" }, }; static struct xprt_class xs_tcp_transport = { @@ -3075,6 +3077,7 @@ static struct xprt_class xs_tcp_transport = { .owner = THIS_MODULE, .ident = XPRT_TRANSPORT_TCP, .setup = xs_setup_tcp, + .netid = { "tcp", "tcp6", "" }, }; static struct xprt_class xs_bc_tcp_transport = { @@ -3083,6 +3086,7 @@ static struct xprt_class xs_bc_tcp_transport = { .owner = THIS_MODULE, .ident = XPRT_TRANSPORT_BC_TCP, .setup = xs_setup_bc_tcp, + .netid = { "" }, }; /** -- 2.27.0