From patchwork Sat Jun 18 13:51:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 12886396 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3431CCA482 for ; Sat, 18 Jun 2022 13:52:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234073AbiFRNwl (ORCPT ); Sat, 18 Jun 2022 09:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233887AbiFRNwb (ORCPT ); Sat, 18 Jun 2022 09:52:31 -0400 Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0E481DA48 for ; Sat, 18 Jun 2022 06:52:30 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 080FA13D5; Sat, 18 Jun 2022 09:52:14 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id EC7551002D3; Sat, 18 Jun 2022 09:52:13 -0400 (EDT) From: James Simmons To: Eric Biggers , Andreas Dilger , NeilBrown Cc: linux-fscrypt@vger.kernel.org, James Simmons Subject: [PATCH 05/28] lnet: improve compat code for IPV6_V6ONLY sock opt Date: Sat, 18 Jun 2022 09:51:47 -0400 Message-Id: <1655560330-30743-6-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655560330-30743-1-git-send-email-jsimmons@infradead.org> References: <1655560330-30743-1-git-send-email-jsimmons@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org From: Mr NeilBrown Since linux 5.9 (v5.8-rc4-1952-ga7b75c5a8c41) it has been possible to pass a "sockptr" to ->setsockopt() which can provide a kernel address. WC-bug-id: https://jira.whamcloud.com/browse/LU-14195 Lustre-commit: 6d111ff0dde182bfb ("LU-14195 lnet: improve compat code for IPV6_V6ONLY sock opt") Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/43559 Reviewed-by: James Simmons Reviewed-by: Arshad Hussain Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- net/lnet/lnet/lib-socket.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/net/lnet/lnet/lib-socket.c b/net/lnet/lnet/lib-socket.c index 7bb8d5c..3a99cb6 100644 --- a/net/lnet/lnet/lib-socket.c +++ b/net/lnet/lnet/lib-socket.c @@ -237,18 +237,12 @@ int choose_ipv4_src(u32 *ret, int interface, u32 dst_ipaddr, struct net *ns) * This is the default, but it can be overridden so we * force it back. */ - /* From v5.7-rc6-2614-g5a892ff2facb when - * kernel_setsockopt() was removed until - * sockptr_t (above) there is no clean way to - * pass kernel address to setsockopt. We could - * use get_fs()/set_fs(), but in this particular - * situation there is an easier way. It depends - * on the fact that at least for these few - * kernels a NULL address to ipv6_setsockopt() - * is treated like the address of a zero. + /* sockptr_t was introduced around + * v5.8-rc4-1952-ga7b75c5a8c41 and allows a + * kernel address to be passed to ->setsockopt */ - if (ipv6_only_sock(sock->sk) && !val) { - void *optval = NULL; + if (ipv6_only_sock(sock->sk)) { + sockptr_t optval = KERNEL_SOCKPTR(&val); sock->ops->setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,