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"