From patchwork Tue Oct 15 17:27:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 1177247 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BstBtEcj"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46t2kZ35tvz9sP4 for ; Wed, 16 Oct 2019 04:40:06 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3DE34EBC; Tue, 15 Oct 2019 17:39:21 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 06B84EB8 for ; Tue, 15 Oct 2019 17:39:20 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9AA346C5 for ; Tue, 15 Oct 2019 17:39:19 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id b128so12952102pfa.1 for ; Tue, 15 Oct 2019 10:39:19 -0700 (PDT) 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; bh=h/PwRTmw5pn3GOxN5e6qVO56WLPreKSphSwiDpOF2pU=; b=BstBtEcjOwOkxuQx8Lqv5gRv+QzVDq7v+rZI7gylNbvgCL42fPcP5gazSlZtnugQb8 jjIlPPrj17my/wBY8/aacYtvIaxJfE73CnXe2KFqEBLp9HwXy2ST67VineLS/IOwDy+a DfPMrEiN+6Ep9k6iVZdTiHlgA3zX2UPYjIBVOaOPlqbXfBTOTkgSAY3ZK7r6dlUl71Pq O+bl2eEekeAqYosm1X98LDtON8xmECLYjoxrxdTEYKXN0jQXjUM46kwzu77/8pCll8XK Qiikj0xLYDX+M3CYI6SFNhc23ZeMHEPLT9MvBr373xTVO/kH05E4fVgBn9hwuIKgAcB9 HItw== 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; bh=h/PwRTmw5pn3GOxN5e6qVO56WLPreKSphSwiDpOF2pU=; b=iYURzIhbgHzs+ss1YIvJEVuV9JXpa4/PLR0ieqCAuNdauheRimg9XvO3dPZITtoGLY ZBkCuJkCz8yKnJ4ithAFze1VzMO3qJZ35ObtCg6XYiF1uf22hW6R4ch4Eb4mNh8uzX/p cY39Trx0m/Tlbdmq7PdclRm0Txw1ipUW6aMHGnkEwLEzh8aH/AEYbNti819GfG8wi+Oa bKsI3C1LXQHRb1/OSYLyx9e1RbS01KtzXArcUyvbI8oCsPopvb4spQ4E2VUoe+PTpWyP UXOXUTgIq2nqC73eQQBwYF9Nm3ZKniwTFePMHZsUvknW986izGJXToMuzN2h/C0R+Wgl X2ZA== X-Gm-Message-State: APjAAAU3USsDDqtzGBYcgYVb6kqHg/xVukHsneJt+osK1kFUGwhPXilu eValy/VXl4/Dn+O0X2yF0/wwT3OK8kw= X-Google-Smtp-Source: APXvYqxpeeLtyZr8Dj1aFFg4Mg4tikML6Zvj+Hcl2lGK4wcISrq8RNiVNqSVq/JWb9UQJqdzbicZiQ== X-Received: by 2002:aa7:9295:: with SMTP id j21mr39295583pfa.87.1571161158790; Tue, 15 Oct 2019 10:39:18 -0700 (PDT) Received: from Husky.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id q204sm25590311pfc.11.2019.10.15.10.39.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Oct 2019 10:39:17 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Tue, 15 Oct 2019 10:27:42 -0700 Message-Id: <1571160473-46132-2-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> References: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Arnd Bergmann Subject: [ovs-dev] [PATCH v2 01/12] datapath: Fix linking without CONFIG_NF_CONNTRACK_LABELS X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Arnd Bergmann upstream commit: commit a277d516de5f498c91d91189717ef7e01102ad27 Author: Arnd Bergmann Date: Fri Nov 2 16:36:55 2018 +0100 openvswitch: fix linking without CONFIG_NF_CONNTRACK_LABELS When CONFIG_CC_OPTIMIZE_FOR_DEBUGGING is enabled, the compiler fails to optimize out a dead code path, which leads to a link failure: net/openvswitch/conntrack.o: In function `ovs_ct_set_labels': conntrack.c:(.text+0x2e60): undefined reference to `nf_connlabels_replace' In this configuration, we can take a shortcut, and completely remove the contrack label code. This may also help the regular optimization. Signed-off-by: Arnd Bergmann Signed-off-by: David S. Miller Signed-off-by: Yi-Hung Wei Reviewed-by: Yifeng Sun --- datapath/conntrack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/datapath/conntrack.c b/datapath/conntrack.c index c6d523758ff1..e328afe1ad15 100644 --- a/datapath/conntrack.c +++ b/datapath/conntrack.c @@ -1263,7 +1263,8 @@ static int ovs_ct_commit(struct net *net, struct sw_flow_key *key, &info->labels.mask); if (err) return err; - } else if (labels_nonzero(&info->labels.mask)) { + } else if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) && + labels_nonzero(&info->labels.mask)) { err = ovs_ct_set_labels(ct, key, &info->labels.value, &info->labels.mask); if (err) From patchwork Tue Oct 15 17:27:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 1177248 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cPChJE2/"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46t2lF6KQkz9sP4 for ; Wed, 16 Oct 2019 04:40:41 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D2FAEEC6; Tue, 15 Oct 2019 17:39:23 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 7306EEC1 for ; Tue, 15 Oct 2019 17:39:21 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 19B7E6C5 for ; Tue, 15 Oct 2019 17:39:21 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id q12so12924836pff.9 for ; Tue, 15 Oct 2019 10:39:21 -0700 (PDT) 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; bh=minFp8ybfyNhctz2c33xijxxSSdpl5KvPVobJ3Vn2cU=; b=cPChJE2/2pBilQU5KUYtiKsZb5yT+wr2jsBocCArlyCKNvp+UCO+6Y6pN1RBjE+KCH kEcYWlhQpZp1c8YzytkDx8dGDCUVT8HfWNnJn+xjMzvkLc20Nq42dEc7K+YMaVqvFCfv pQZdyolVzq5nNlAdrqMkyvkUHiDWT6I8GBqIkVrcCjMNUVrtMcQaYY4gZWgqCPT/tcL8 q09KYGlhmG8g0p4+yUNN/pa5FfwB+La/Vvll3839VrJrg4W6SOij2JUDZbDW0SEERh1q hIGTT098ojDVlBtBdzhzdXZuOeT7wmG8+2OrCmhgULsbQSn1Wcdhz8nesj8S/leYvybQ AaBw== 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; bh=minFp8ybfyNhctz2c33xijxxSSdpl5KvPVobJ3Vn2cU=; b=jBQn5pNR2AXmyWoy0+evhoSgH8q1xUo1Rwbu+HNX4XCmEskp6Qnj7xLh7+gM+7Fp+I VSIjiqJ0LmX6+qX7D+BvS5zNkceDrj2BjXVXJG49ke/h0PzOii2nd4/P7yTf6qjPHTEn 8xRGRa9jerDJAPlFT7RpQi1NcLKTLRFACXA3quR5axjHNQrHlVB7QtjAIUk9d3zfYiYm mGj3GoKEVP/LL+YJDE9XVcnj5d24taoIF1Rco1aJW/H4kTOjykdFkWbvwgAI2aKhSzJr XIuqUs1qB1vzAspxwBgMnHDt2LtBKJUSihE+iqOF5HKA5PsY14wbm9jVhKYxKX7Qf3Kt YDdA== X-Gm-Message-State: APjAAAV3R7Lu+7VcN5Feqamy9T6lF7FutA4Z+QaEtXMJFJnZ4yor6jvh p2kcJaf9VUQ52lIReSevgR0OlLf/GoM= X-Google-Smtp-Source: APXvYqxuxDHrvlTtoaOq5JGkix4XIyxe+lmslfpRylOIyrwXyNpnrtNYlbxMOHOt+G5c4cCST8XCTw== X-Received: by 2002:aa7:8e4b:: with SMTP id d11mr8295729pfr.79.1571161160247; Tue, 15 Oct 2019 10:39:20 -0700 (PDT) Received: from Husky.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id q204sm25590311pfc.11.2019.10.15.10.39.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Oct 2019 10:39:19 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Tue, 15 Oct 2019 10:27:43 -0700 Message-Id: <1571160473-46132-3-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> References: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 02/12] datapath: Replace nf_ct_invert_tuplepr() with nf_ct_invert_tuple() X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org After upstream net-next commit 303e0c558959 ("netfilter: conntrack: avoid unneeded nf_conntrack_l4proto lookups") nf_ct_invert_tuplepr() is no longer available in the kernel. Ideally, we should be in sync with upstream kernel by calling nf_ct_invert_tuple() directly in conntrack.c. However, nf_ct_invert_tuple() has different function signature in older kernel, and it would be hard to replace that in the compat layer. Thus, we use rpl_nf_ct_invert_tuple() in conntrack.c and maintain compatibility in the compat layer so that ovs kernel module runs smoothly in both new and old kernel. Signed-off-by: Yi-Hung Wei Reviewed-by: Yifeng Sun --- acinclude.m4 | 2 ++ datapath/conntrack.c | 2 +- .../linux/compat/include/net/netfilter/nf_conntrack_core.h | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index b3e5f94690c8..3f63cef86696 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -697,6 +697,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ [nf_ct_set]) OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h], [nf_ct_is_untracked]) + OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h], + [nf_ct_invert_tuplepr]) OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_zones.h], [nf_ct_zone_init]) OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_l3proto.h], diff --git a/datapath/conntrack.c b/datapath/conntrack.c index e328afe1ad15..afdd65b4cb7c 100644 --- a/datapath/conntrack.c +++ b/datapath/conntrack.c @@ -668,7 +668,7 @@ ovs_ct_find_existing(struct net *net, const struct nf_conntrack_zone *zone, if (natted) { struct nf_conntrack_tuple inverse; - if (!nf_ct_invert_tuplepr(&inverse, &tuple)) { + if (!rpl_nf_ct_invert_tuple(&inverse, &tuple)) { pr_debug("ovs_ct_find_existing: Inversion failed!\n"); return NULL; } diff --git a/datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h b/datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h index 10158011fd4d..ad52bc9412d8 100644 --- a/datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h +++ b/datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h @@ -113,4 +113,18 @@ rpl_nf_conntrack_in(struct sk_buff *skb, const struct nf_hook_state *state) #define nf_conntrack_in rpl_nf_conntrack_in #endif /* HAVE_NF_CONNTRACK_IN_TAKES_NF_HOOK_STATE */ +#ifdef HAVE_NF_CT_INVERT_TUPLEPR +static inline bool rpl_nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, + const struct nf_conntrack_tuple *orig) +{ + return nf_ct_invert_tuplepr(inverse, orig); +} +#else +static inline bool rpl_nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, + const struct nf_conntrack_tuple *orig) +{ + return nf_ct_invert_tuple(inverse, orig); +} +#endif /* HAVE_NF_CT_INVERT_TUPLEPR */ + #endif /* _NF_CONNTRACK_CORE_WRAPPER_H */ From patchwork Tue Oct 15 17:27:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 1177249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TVSh1sjs"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46t2lt0PsXz9sP4 for ; Wed, 16 Oct 2019 04:41:14 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7AE8AED3; Tue, 15 Oct 2019 17:39:24 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 06A1EEC1 for ; Tue, 15 Oct 2019 17:39:23 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id A327B6C5 for ; Tue, 15 Oct 2019 17:39:22 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id q21so12907972pfn.11 for ; Tue, 15 Oct 2019 10:39:22 -0700 (PDT) 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; bh=iiy8aOA1fq8K72xjGR2lZoft3PbgCSQ5WguPpqEI+SE=; b=TVSh1sjsapSlrHIQN9lRlvW6N2kC9p3qK3X2fNHlX/kr4VAobxU5gHvNhvIXrrOKBr uJxK7agzD7TxXJ+QvjVJ7Iqvf2kYnZW/QFzFeHp0EC5GbsWg5TjXGS6HyKebnDFalFfb zMRPLdDFYhO0w+7GEEspeETX+qUXQfHLFXpTHqZGa4PSM10c0tAXK/8mWSEsFh+N7y6I g4j8GpPh9IMhMiiFdIxsk/bYThDhKL+UFajnh3zrjKi0qs/s1Coxa0+MkMKs9t+wLZr4 fpqh4ajvPWs8bGdQJOOWTTpjUQpx3bSlo+CorXvx2XDVddkXTJcmkNFlkXaqeduZt09U WILA== 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; bh=iiy8aOA1fq8K72xjGR2lZoft3PbgCSQ5WguPpqEI+SE=; b=sNxjMZ0o1yqDLB8Tnpz6d3yiBAUIz6+PW+rGOgITyUaIsQXWFq2V0HhMTiOT7l3NIU v+4XdiMIAnEpdtrnZJdy9eSvi7W8oiqV/YFTBKkiymyttlcKodVQwqKbWnXQHx/I/TSH 5AzoXYmGWm43ulig4t0jH5KSoxR21tLxgUZKVbYrZ6tEwvsm6Ugs8MyRdOpF2L5XS2at 3VbMZRA0dif4fDCgLXvnt9OjfEdrc4yfK2fyjN/x8RLGtjT2tQUQO8mb0JIsaAoJR9mE i9KcV/YlLcIsBrU5/q13Rsf0xRrbbCdt0pYFvwKMpCUMYjwtnkegx/7n3cUHt35p7uvU WHdw== X-Gm-Message-State: APjAAAW+DOB3VdAxKEH5q/TdNC9Q9c0v+SeNz7l0DUrIjMFoHPmsb+jS ccn4PHkQkt8hBiE7HXNp57yqqjE7Rm8= X-Google-Smtp-Source: APXvYqxuVcqeqU3Fi4b5AlXrBKQlMZJDxZbGKaO2NChtwwPiZH/xyzimRKaVkG/lYjsUcMF/MNR9dA== X-Received: by 2002:a65:6492:: with SMTP id e18mr40456146pgv.111.1571161161675; Tue, 15 Oct 2019 10:39:21 -0700 (PDT) Received: from Husky.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id q204sm25590311pfc.11.2019.10.15.10.39.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Oct 2019 10:39:20 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Tue, 15 Oct 2019 10:27:44 -0700 Message-Id: <1571160473-46132-4-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> References: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 03/12] datapath: Detect upstream nf_nat change X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org The following two upstream commits merge nf_nat_ipv4 and nf_nat_ipv6 into nf_nat core, and move some header files around. To handle these modifications, this patch detects the upstream changes, uses the header files and config symbols properly. Ideally, we should replace CONFIG_NF_NAT_IPV4 and CONFIG_NF_NAT_IPV6 with CONFIG_NF_NAT and CONFIG_IPV6. In order to keep backward compatibility, we keep the checking of CONFIG_NF_NAT_IPV4/6 as is for the old kernel, and replace them with marco for the new kernel. upstream commits: 3bf195ae6037 ("netfilter: nat: merge nf_nat_ipv4,6 into nat core") d2c5c103b133 ("netfilter: nat: remove nf_nat_l3proto.h and nf_nat_core.h") Signed-off-by: Yi-Hung Wei Reviewed-by: Yifeng Sun --- acinclude.m4 | 2 ++ datapath/conntrack.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 3f63cef86696..417a4504b135 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -713,6 +713,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_nat.h], [nf_ct_nat_ext_add]) OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_nat.h], [nf_nat_alloc_null_binding]) OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_nat.h], [nf_nat_range2]) + OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_nat.h], [nf_nat_packet], + [OVS_DEFINE([HAVE_UPSTREAM_NF_NAT])]) OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_seqadj.h], [nf_ct_seq_adjust]) OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_count.h], [nf_conncount_gc_list], [OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_count.h], diff --git a/datapath/conntrack.c b/datapath/conntrack.c index afdd65b4cb7c..291d4f4723d9 100644 --- a/datapath/conntrack.c +++ b/datapath/conntrack.c @@ -35,10 +35,21 @@ #include #ifdef CONFIG_NF_NAT_NEEDED +/* Starting from upstream commit 3bf195ae6037 ("netfilter: nat: merge + * nf_nat_ipv4,6 into nat core") in kernel 5.1. nf_nat_ipv4,6 are merged + * into nf_nat. In order to keep backward compatibility, we keep the config + * checking as is for the old kernel, and replace them with marco for the + * new kernel. */ +#ifdef HAVE_UPSTREAM_NF_NAT +#include +#define CONFIG_NF_NAT_IPV4 CONFIG_NF_NAT +#define CONFIG_NF_NAT_IPV6 CONFIG_IPV6 +#else #include #include #include -#endif +#endif /* HAVE_UPSTREAM_NF_NAT */ +#endif /* CONFIG_NF_NAT_NEEDED */ #include "datapath.h" #include "conntrack.h" From patchwork Tue Oct 15 17:27:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 1177250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dF6mhplT"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46t2mc4Q9Sz9sPF for ; Wed, 16 Oct 2019 04:41:52 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4F900EE1; Tue, 15 Oct 2019 17:39:26 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 83D80ED6 for ; Tue, 15 Oct 2019 17:39:24 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3A5586C5 for ; Tue, 15 Oct 2019 17:39:24 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id p12so3233205pgn.6 for ; Tue, 15 Oct 2019 10:39:24 -0700 (PDT) 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; bh=F8YjLLu7jH97iIH9j91rMUHNw4EW7mCrXDKWY8urhIg=; b=dF6mhplTtBI+gXsfYMmT12Q1fwIsBwpZyluJdDAqtUqEeoWEcENMHZlwljnp25YcRG FGoT26aFo8zaIAryJ1iJpG2fHMvmlYRZljaLy8sWkDpMJZvwtrwORigvKCTXnScqDGx/ /kzkkO7VD7aw7aibLq8bqe+4oddyyVHkDA7W88aKKhfcM4UOBPFGzS2XPY/g+C2hwBw6 gFBrfoXy+uyJzoqK0yINRvRwaWQX+TUZJiLUhzK0EKMZQTYEI5cCX8jz/ScrafeD1TmZ hSGb5aPNc0L3qT2Um6KVLvEY3S95D5l9foULAHtUGLVaiM/JEZKMq2cILmQjJpOJxOMf oKGA== 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; bh=F8YjLLu7jH97iIH9j91rMUHNw4EW7mCrXDKWY8urhIg=; b=dVxMU8DsKB/Q01rbiQIVz30jvcfTniowsP+GXk0Kb9XaRNyPoGZqiGpz/87qkRIzaf H9hkmsdi8EybS41yDIUIGEyWgmE/GpbDZQE8JbIhafqDQbwbiq0T3JNxeDqKLGKJHAk2 UUqiZs5dinAYvi13x2WomT3ZPO/ZedFeeE7j998RfggAWpUzWSp7WNuBuqRskLx3h+MC D0fsH13F5D70PRZshf0t5Dze3yq9nYxWClAL/T8TRPezsZuP6Zp7H+wbmSKYzBMcZURl aiIbXIzBeZNcULbIFxnT/wwSXDzDmZW9kUP1fUL3dPRWC+OBFdLaPga1lUhi1rRNPXTb aEQQ== X-Gm-Message-State: APjAAAVVmflx2sjK5mH/ZYcWxvoC/eXAOHSZnSxqh97nRImkLhWvFSAA Ujfg8mvt+C1owffyzoMhRObdP7tA0bs= X-Google-Smtp-Source: APXvYqzWIWLycUmg+GGMnyubdfCRh/WUoWg7K0bLvCgC9+DnnWA4EYToQiyuACiGYBlgoeCIf25SHA== X-Received: by 2002:a63:2d43:: with SMTP id t64mr39592499pgt.428.1571161163306; Tue, 15 Oct 2019 10:39:23 -0700 (PDT) Received: from Husky.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id q204sm25590311pfc.11.2019.10.15.10.39.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Oct 2019 10:39:22 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Tue, 15 Oct 2019 10:27:45 -0700 Message-Id: <1571160473-46132-5-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> References: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Flavio Leitner Subject: [ovs-dev] [PATCH v2 04/12] datapath: add seqadj extension when NAT is used. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Flavio Leitner upstream patch: commit fa7e428c6b7ed3281610511a2b2ec716d9894be8 Author: Flavio Leitner Date: Mon Mar 25 15:58:31 2019 -0300 openvswitch: add seqadj extension when NAT is used. When the conntrack is initialized, there is no helper attached yet so the nat info initialization (nf_nat_setup_info) skips adding the seqadj ext. A helper is attached later when the conntrack is not confirmed but is going to be committed. In this case, if NAT is needed then adds the seqadj ext as well. Fixes: 16ec3d4fbb96 ("openvswitch: Fix cached ct with helper.") Signed-off-by: Flavio Leitner Acked-by: Pravin B Shelar Signed-off-by: David S. Miller Signed-off-by: Yi-Hung Wei Reviewed-by: Yifeng Sun --- datapath/conntrack.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/datapath/conntrack.c b/datapath/conntrack.c index 291d4f4723d9..1b345a03e704 100644 --- a/datapath/conntrack.c +++ b/datapath/conntrack.c @@ -1063,6 +1063,12 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, GFP_ATOMIC); if (err) return err; + + /* helper installed, add seqadj if NAT is required */ + if (info->nat && !nfct_seqadj(ct)) { + if (!nfct_seqadj_ext_add(ct)) + return -EINVAL; + } } /* Call the helper only if: From patchwork Tue Oct 15 17:27:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 1177251 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="afuqkd/O"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46t2nF0vNBz9sP4 for ; Wed, 16 Oct 2019 04:42:25 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E34C3EE4; Tue, 15 Oct 2019 17:39:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id E3A50EE3 for ; Tue, 15 Oct 2019 17:39:27 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id EF69E6C5 for ; Tue, 15 Oct 2019 17:39:25 +0000 (UTC) Received: by mail-pf1-f170.google.com with SMTP id q12so12924969pff.9 for ; Tue, 15 Oct 2019 10:39:25 -0700 (PDT) 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; bh=rWM7+FQuQmGQI7VIZUf0W474tKn57Qbeb8WObB3KIng=; b=afuqkd/ON6nIDLYL7a0FcgdzrlWxA8O8q/zYjELj0OW9fFLqdL/Tn7EeRE10HT9y1I n6iUayZvkMGgoo6voaD/cOKsJvPI38TWr3jNgwesi7s/LHDZNUauCpE33p66CU37YD/1 Mlj1NfrW2KMZ7r3Ohtx4Vtj+J/5DWL4mk4sL+bDhy56+B42K/Md0syskHViItIdiJ1JZ 8qJOPqSbZABiMNZDe4l7Fz+JRKpKn2LM+YNpBbba0JLH7qyyWee22Up99FE67j/Q9vIs ssXrB/9gt95IBbP3WQArZV2N2mqBcQTg0ymmIjqZ0gmmlR8xIpk2tKIpIBM1UPwUH5LU VlHA== 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; bh=rWM7+FQuQmGQI7VIZUf0W474tKn57Qbeb8WObB3KIng=; b=Z1apdNTjpLtNFUJugmlwWl1hIBKDUUhMcTMAWsJnid3kbfPx3QNtfnpJa+cJw8ESno CQgH8E/t4SE1aX7KhxZ/Fo9OghrhGRxxFLAmDdwqGEjckqYWYELzDbQDBd5OGzw+7ZZS QmZqKEuFEdPPNGV8yPbiyM+J/8FGwLPxHbVUgVTYmsOBhCSDpOFtVuqz1q8rXWgSfObB yKwlO4xsibVuZU1K6C3rbDKjJdsRoRcugQSu8OBbjX4HkCToQF18lHJbr0U1Cx6BZMvg Jiq88V4cpipDkWvdC0JJTYsZ3QarXUKMhpx1XwgxqmeYMEn5HPTeLaa+s4nbBIlEuvsG nclA== X-Gm-Message-State: APjAAAWep97WvUYxZ/grSBNgOSKmSVDB6cHf4dtSHEkn0/5Tnhs2Z+0A K/VJc2TUIa6IP4lqsR6DrieXu+ugSDk= X-Google-Smtp-Source: APXvYqwkMcfuy23xevNoBJsksDEGb/0AL8wqKCC03VgQdxm6Q+016iLeuJ8BSuvdbEQxxPYnXDxj1g== X-Received: by 2002:a63:e056:: with SMTP id n22mr38998560pgj.73.1571161164854; Tue, 15 Oct 2019 10:39:24 -0700 (PDT) Received: from Husky.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id q204sm25590311pfc.11.2019.10.15.10.39.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Oct 2019 10:39:23 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Tue, 15 Oct 2019 10:27:46 -0700 Message-Id: <1571160473-46132-6-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> References: <1571160473-46132-1-git-send-email-yihung.wei@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 05/12] datapath: Handle NF_NAT_NEEDED replacement X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Starting from the following upstream commit, NF_NAT_NEEDED is replaced by IS_ENABLED(CONFIG_NF_NAT) in the upstream kernel. This patch makes some changes so that our in tree ovs kernel module is compatible to both old and new kernels. Upstream commit: commit 4806e975729f99c7908d1688a143f1e16d464e6c Author: Florian Westphal Date: Wed Mar 27 09:22:26 2019 +0100 netfilter: replace NF_NAT_NEEDED with IS_ENABLED(CONFIG_NF_NAT) NF_NAT_NEEDED is true whenever nat support for either ipv4 or ipv6 is enabled. Now that the af-specific nat configuration switches have been removed, IS_ENABLED(CONFIG_NF_NAT) has the same effect. Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Yi-Hung Wei Reviewed-by: Yifeng Sun --- acinclude.m4 | 1 + datapath/conntrack.c | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 417a4504b135..3b65a47db55b 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -676,6 +676,7 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netfilter.h], [nf_hook_ops], [owner], [OVS_DEFINE([HAVE_NF_HOOKS_OPS_OWNER])]) OVS_GREP_IFELSE([$KSRC/include/linux/netfilter.h], [NFPROTO_INET]) + OVS_GREP_IFELSE([$KSRC/include/linux/netfilter.h], [CONFIG_NF_NAT_NEEDED]) OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netfilter_ipv6.h], [nf_ipv6_ops], diff --git a/datapath/conntrack.c b/datapath/conntrack.c index 1b345a03e704..010f9af5ffd2 100644 --- a/datapath/conntrack.c +++ b/datapath/conntrack.c @@ -34,7 +34,16 @@ #include #include -#ifdef CONFIG_NF_NAT_NEEDED +/* Upstream commit 4806e975729f ("netfilter: replace NF_NAT_NEEDED with + * IS_ENABLED(CONFIG_NF_NAT)") replaces the config checking on NF_NAT_NEEDED + * with CONFIG_NF_NAT. We will replace the checking on NF_NAT_NEEDED for the + * newer kernel with the marco in order to keep backward compatiblity. + */ +#ifndef HAVE_CONFIG_NF_NAT_NEEDED +#define CONFIG_NF_NAT_NEEDED CONFIG_NF_NAT +#endif + +#if