From patchwork Tue Apr 13 23:42:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Yanjun X-Patchwork-Id: 12199517 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_12_24,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69963C433B4 for ; Tue, 13 Apr 2021 07:18:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4619E613B2 for ; Tue, 13 Apr 2021 07:18:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239088AbhDMHSl (ORCPT ); Tue, 13 Apr 2021 03:18:41 -0400 Received: from mga05.intel.com ([192.55.52.43]:6927 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237684AbhDMHSj (ORCPT ); Tue, 13 Apr 2021 03:18:39 -0400 IronPort-SDR: 59CQZwUQdQERuRW4E3ohrKV3rov/7amY8mcrd1vH5pje85DLrEOpqwQqWwuaKK0Dd2NAFdtcSn jkyl4gfVxQqA== X-IronPort-AV: E=McAfee;i="6200,9189,9952"; a="279660696" X-IronPort-AV: E=Sophos;i="5.82,218,1613462400"; d="scan'208";a="279660696" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2021 00:18:20 -0700 IronPort-SDR: zlQ6KXpA7Ie1UVz+AlJ4njKjdP2Uid03KUd/n7NqYl6HIRjTxW6uBZIIBJkhjzGktD1Ihq9ySU 0SInBFThCb7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,218,1613462400"; d="scan'208";a="381880531" Received: from unknown (HELO intel-86.bj.intel.com) ([10.238.154.86]) by orsmga003.jf.intel.com with ESMTP; 13 Apr 2021 00:18:17 -0700 From: Zhu Yanjun To: zyjzyj2000@gmail.com, dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org Cc: Yi Zhang Subject: [PATCHv5 for-next 1/1] RDMA/rxe: Disable ipv6 features when ipv6.disable in cmdline Date: Tue, 13 Apr 2021 19:42:52 -0400 Message-Id: <20210413234252.12209-1-yanjun.zhu@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Zhu Yanjun When ipv6.disable=1 is set in cmdline, ipv6 is actually disabled in the stack. As such, the operations of ipv6 in RXE will fail. So ipv6 features in RXE should also be disabled in RXE. Link: https://lore.kernel.org/linux-rdma/880d7b59-4b17-a44f-1a91-88257bfc3aaa@redhat.com/T/#t Fixes: 8700e3e7c4857 ("Soft RoCE driver") Reported-by: Yi Zhang Signed-off-by: Zhu Yanjun --- V4->V5: Clean up signature block and remove error message V3->V4: Check the returned value instead of ipv6 module V2->V3: Remove print message V1->V2: Modify the pr_info messages --- drivers/infiniband/sw/rxe/rxe_net.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index 01662727dca0..984c3ac449bd 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -208,7 +208,13 @@ static struct socket *rxe_setup_udp_tunnel(struct net *net, __be16 port, /* Create UDP socket */ err = udp_sock_create(net, &udp_cfg, &sock); if (err < 0) { - pr_err("failed to create udp socket. err = %d\n", err); + /* If UDP tunnel over ipv6 fails with -EAFNOSUPPORT, the tunnel + * over ipv4 still works. This error message will not pop out. + * If UDP tunnle over ipv4 fails or other errors with ipv6 + * tunnel, this error should pop out. + */ + if (!((err == -EAFNOSUPPORT) && (ipv6))) + pr_err("failed to create udp socket. err = %d\n", err); return ERR_PTR(err); } @@ -620,6 +626,11 @@ static int rxe_net_ipv6_init(void) recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net, htons(ROCE_V2_UDP_DPORT), true); if (IS_ERR(recv_sockets.sk6)) { + /* Though IPv6 is not supported, IPv4 still needs to continue + */ + if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT) + return 0; + recv_sockets.sk6 = NULL; pr_err("Failed to create IPv6 UDP tunnel\n"); return -1;