From patchwork Fri Jan 15 07:30:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 12021783 X-Patchwork-Delegate: kuba@kernel.org 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 BA6FAC433DB for ; Fri, 15 Jan 2021 07:31:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74E37221FF for ; Fri, 15 Jan 2021 07:31:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731410AbhAOHbI (ORCPT ); Fri, 15 Jan 2021 02:31:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727470AbhAOHbI (ORCPT ); Fri, 15 Jan 2021 02:31:08 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4262C0613C1 for ; Thu, 14 Jan 2021 23:30:27 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id g3so4271859plp.2 for ; Thu, 14 Jan 2021 23:30:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Z7HSJSeBLeJa8F3YnHkBDKj2RIYYIjzsXg9wxk8bDWo=; b=W7GMYTwhKVtMPPAO0mgY0h3bToFgAoVEDe8CZBSU71YmuBxr05DCVooz4Ob2V7KGOc pULe6CPTqznLD2kb4WOFihU0gPR+Yr5eSLefgNPDmaN2qc2H1Lr7FkPZmrnXjPNGhEKD In8Za0Ic1YDVsQsXyZSzJMrHOhQFWLWVo9EnGMhDefvTZcwxZTqwkLfqC8+QG2nKjEZ9 2SLBxxFsPBPOE19x1JEpwSdGolYYDpJXEIrrGscde7VjerO07Lf+NmeQ/l5F1KcPByFz r/FjOx5Lc7BAekoTVgSyIxKhSf5sOmrZORku6rLPCJby2YbKo5DlgundtZYYKo6kXvR/ /mCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Z7HSJSeBLeJa8F3YnHkBDKj2RIYYIjzsXg9wxk8bDWo=; b=R7SgFi5ebPe6rjOYx2Olsi0PIEo3FDkmediIiMOVR3S+qaQGK+itzIgcVdOxXDTLeQ fJ3MZTajCuGpGXCS0ekdh0lEF+fzoMFoSznnpbtAqWS0VYemU6mRMPEGr/VHir2Ucrqj ZiaSTXmPttibih/EbQPoJ/wISDGrSpbfTXXch2yoHnTst08ZqCTt1J7B2md4BKUHBHA4 CN8A1noZYHEw8nXbbZKGhYshd7IkS5d6iv19WC6B6zF/wKC4EgOAD01MitXoIlvo3WMC iSII/+iz/pMn1Q4p86dfiiT+C+ZkQI+Y7xqkN+/nFAxfO8p9fLAQV1YTl/R7rGyerFcZ 6+yg== X-Gm-Message-State: AOAM531A/jXvtr454vA+bK+h3d96uZoie7XPhsy1qrPX1/ANApydi63w SVVEwgnqpAx0aO1FJWeHPL3hgW9BRiBbZg== X-Google-Smtp-Source: ABdhPJytpKO1vACPgBvM6WTz+1/t+dfUzx1wqMEHPANm2plbpsmp6OOVKzkyRUt7Rlr627sr3GTg8Q== X-Received: by 2002:a17:902:ea0f:b029:de:5fd5:abb9 with SMTP id s15-20020a170902ea0fb02900de5fd5abb9mr5785667plg.46.1610695827045; Thu, 14 Jan 2021 23:30:27 -0800 (PST) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id p9sm7274200pjb.3.2021.01.14.23.30.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jan 2021 23:30:26 -0800 (PST) From: Xin Long To: network dev Cc: davem@davemloft.net, Jakub Kicinski , pabeni@redhat.com, Willem de Bruijn , Martin Varghese Subject: [PATCHv2 net-next 1/2] udp: call udp_encap_enable for v6 sockets when enabling encap Date: Fri, 15 Jan 2021 15:30:08 +0800 Message-Id: X-Mailer: git-send-email 2.1.0 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When enabling encap for a ipv6 socket without udp_encap_needed_key increased, UDP GRO won't work for v4 mapped v6 address packets as sk will be NULL in udp4_gro_receive(). This patch is to enable it by increasing udp_encap_needed_key for v6 sockets in udp_tunnel_encap_enable(), and correspondingly decrease udp_encap_needed_key in udpv6_destroy_sock(). v1->v2: - add udp_encap_disable() and export it. Signed-off-by: Xin Long --- include/net/udp.h | 1 + include/net/udp_tunnel.h | 3 +-- net/ipv4/udp.c | 6 ++++++ net/ipv6/udp.c | 4 +++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/net/udp.h b/include/net/udp.h index 877832b..1e7b6cd 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -467,6 +467,7 @@ void udp_init(void); DECLARE_STATIC_KEY_FALSE(udp_encap_needed_key); void udp_encap_enable(void); +void udp_encap_disable(void); #if IS_ENABLED(CONFIG_IPV6) DECLARE_STATIC_KEY_FALSE(udpv6_encap_needed_key); void udpv6_encap_enable(void); diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h index 282d10e..afc7ce7 100644 --- a/include/net/udp_tunnel.h +++ b/include/net/udp_tunnel.h @@ -181,9 +181,8 @@ static inline void udp_tunnel_encap_enable(struct socket *sock) #if IS_ENABLED(CONFIG_IPV6) if (sock->sk->sk_family == PF_INET6) ipv6_stub->udpv6_encap_enable(); - else #endif - udp_encap_enable(); + udp_encap_enable(); } #define UDP_TUNNEL_NIC_MAX_TABLES 4 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 7103b0a..28bfe60 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -596,6 +596,12 @@ void udp_encap_enable(void) } EXPORT_SYMBOL(udp_encap_enable); +void udp_encap_disable(void) +{ + static_branch_dec(&udp_encap_needed_key); +} +EXPORT_SYMBOL(udp_encap_disable); + /* Handler for tunnels with arbitrary destination ports: no socket lookup, go * through error handlers in encapsulations looking for a match. */ diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index b9f3dfd..d754292 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1608,8 +1608,10 @@ void udpv6_destroy_sock(struct sock *sk) if (encap_destroy) encap_destroy(sk); } - if (up->encap_enabled) + if (up->encap_enabled) { static_branch_dec(&udpv6_encap_needed_key); + udp_encap_disable(); + } } inet6_destroy_sock(sk); From patchwork Fri Jan 15 07:30:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 12021785 X-Patchwork-Delegate: kuba@kernel.org 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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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 A1CFAC433DB for ; Fri, 15 Jan 2021 07:31:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 588B7221FF for ; Fri, 15 Jan 2021 07:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731553AbhAOHbU (ORCPT ); Fri, 15 Jan 2021 02:31:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731488AbhAOHbQ (ORCPT ); Fri, 15 Jan 2021 02:31:16 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7E9EC061575 for ; Thu, 14 Jan 2021 23:30:36 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id 11so4946801pfu.4 for ; Thu, 14 Jan 2021 23:30:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=3IFC3iYq1PLDeBWUAx5gWx/qqJGJPyT/FaRL0p5firA=; b=N4lVwaxKzraP11CRG9HwatJQly/YSigWwWCRM0UXFETgTIut4ga3QnHGeChotrFbwR yB9dfDaeqWQ7vqA/uwzX161jpB6zOvzkKzQfO+ag0j+8oO5zjicdnPXznfi57Mqt5JDZ zEokzQu66d5FvI9D5TmDn2+wveiWk/HSLreeXWyMueoqoOvMfOCKZ8SKAVScThE84cCE p3dJe1uRJG1606F1QmGGhrhlHq8mNcQ+mIaiQakIgZQBL7qLWXepKf9oR8jNOLifv2By KWn1RDjb1vW1EFoL+O2SwLHqaZ9zSuNQiFAKy1zi+ZtyfxqerrLN8CgfWsLy3eF4jm98 D3sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=3IFC3iYq1PLDeBWUAx5gWx/qqJGJPyT/FaRL0p5firA=; b=LFV1fjJ32Hv9Vngm7MuFXK1cT7zK1uES/U9v/IYv2I2UN3mafAsbJcU+RATFMS9UCj c+f4tsgZ6xDGg+C/KgeS9Fd4a61Z0tn0OXSFv1p2puCIERO6p2deXLrhb0B/AJJkZX+v 1JWAoS1b5SiWs4nAMmDG9NJ7EinJxIR3KAXx7xx6NZcD7eANXTA1AAnxu3MsIDY/xKkU 5I+nE5AEvmNpRrmgB1SKsxLGNEMKdbJzhKBI0cQhtRHnlj8ieoXdWW+t7O2vqzrg+B/1 xuOWbffkzLrOmU2SUdopIflAx4xu/OacnzxBZGhUNiB6sv+vT5R4qrNA0gHC7ZS2TxFV WbHw== X-Gm-Message-State: AOAM530QettiXEGY2f0vqGbmzHI+ARWEKwpm5t9DJAhHZAJCa+XQudoz Jp83YX1XvFE7TEgXI+nYyObwF6eJp80hkQ== X-Google-Smtp-Source: ABdhPJxi/8LQ3OoEhrpgYiqDZJdib/zg3VeyJhKbhxqMFq/JxD3qoAyiiq1m7Qz6eaO/rM8nOc4Iaw== X-Received: by 2002:a63:78ca:: with SMTP id t193mr11446854pgc.391.1610695836041; Thu, 14 Jan 2021 23:30:36 -0800 (PST) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id z7sm7423214pfq.193.2021.01.14.23.30.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jan 2021 23:30:35 -0800 (PST) From: Xin Long To: network dev Cc: davem@davemloft.net, Jakub Kicinski , pabeni@redhat.com, Willem de Bruijn , Martin Varghese Subject: [PATCHv2 net-next 2/2] Revert "bareudp: Fixed bareudp receive handling" Date: Fri, 15 Jan 2021 15:30:09 +0800 Message-Id: <1984207281c8f03b61968731487cd436dba40b80.1610695758.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org As udp_encap_enable() is already called in udp_tunnel_encap_enable() since the last patch, and we don't need it any more. So remove it by reverting commit 81f954a44567567c7d74a97b1db78fb43afc253d. --- drivers/net/bareudp.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c index 0965d13..57dfaf4 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -240,12 +240,6 @@ static int bareudp_socket_create(struct bareudp_dev *bareudp, __be16 port) tunnel_cfg.encap_destroy = NULL; setup_udp_tunnel_sock(bareudp->net, sock, &tunnel_cfg); - /* As the setup_udp_tunnel_sock does not call udp_encap_enable if the - * socket type is v6 an explicit call to udp_encap_enable is needed. - */ - if (sock->sk->sk_family == AF_INET6) - udp_encap_enable(); - rcu_assign_pointer(bareudp->sock, sock); return 0; }