From patchwork Mon Oct 14 17:37: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: 1176562 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="OMjFS5Em"; 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 46sR1k5L1rz9sP6 for ; Tue, 15 Oct 2019 04:51:06 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 16C082744; Mon, 14 Oct 2019 17:49:51 +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 74BE72737 for ; Mon, 14 Oct 2019 17:49:47 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E38568A0 for ; Mon, 14 Oct 2019 17:49:46 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id u20so8332529plq.4 for ; Mon, 14 Oct 2019 10:49:46 -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=taiiT6Vv/WaocKF+EVa6Yo9ugcxj6Dtce2NKTc4Tm/U=; b=OMjFS5EmlSMv2zpezkguS/3dwJiZSwjKkzkLE77OGWPHar3Hzl931YfHPSW539u8Wi JWjBkZNDEVjRQSDQ4dgfWd+48VBYNSwtB5kJ9hqY3gkmSjVcBklq35s4sB4A/JDxYiHm ZG+CAMWSzmmGwWZdmqKaZ8dj3drwNya2HQTdjG+TIAl7PgiV4LCRnUX6dRs2RQiL1x4X Zn6ym5egMrGMolIRnEWdJbEKW0UxrRWs+9J6GbB1Jd14BPPlhBwNvuY0jF9+SmV9X+fy MCz1CvZqsT7OS/rM+PKwouVx6GAOhuxyOKRnE8OuK0s3eiApvi64kA0n7MG2sSf2S0Gr nXyQ== 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=taiiT6Vv/WaocKF+EVa6Yo9ugcxj6Dtce2NKTc4Tm/U=; b=N9//qw9pDfnSzdXrZcNdUY7vYxoA/82Pt6Ia8Lpt98z+0BKZOQXJrhlrzbptXpWieZ 0XZ+yw59uoeX22+5XjIp8KHEdir/SH1pykFLlDtKvU6Hi8qM3W0+JrvovmDYHVx7OKR3 D7sW8QdwwnTQ7SFXrPCAOG3n5nqfpNJow+S7DihUVeuSydkLVUzQu6SllTlqhjd3+ilD 1dp0K91zMziZtIFvOBfJUQtEUqzW41I8Zw4+LLEaXbfUSMs0Z6tL8n/YdLqV06b93j48 iPQoZdvpVkAeWJ+0GbqaLPyPSXdbnE9K4YfbkzLmYnmUbHPfHYR0dS2lDxOZs80Uam9G o1Vg== X-Gm-Message-State: APjAAAUQzi56loKA55RfRkpxdsh14MGEJqO1fhxMxHq1WGCB/lv7Zf7o B9t/A54FWB3gZMa5qqPcxJJAzPba1ck= X-Google-Smtp-Source: APXvYqyxbppdz4MHRBWaNfPCFJHRUrJso43f2zpveOhOb/7MsSrx7bT9Z31qyGdUUVIshPSy1XmOjg== X-Received: by 2002:a17:902:144:: with SMTP id 62mr31346084plb.283.1571075385973; Mon, 14 Oct 2019 10:49:45 -0700 (PDT) Received: from Husky.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id n23sm16849700pff.137.2019.10.14.10.49.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Oct 2019 10:49:44 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Mon, 14 Oct 2019 10:37:42 -0700 Message-Id: <1571074671-31834-3-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571074671-31834-1-git-send-email-yihung.wei@gmail.com> References: <1571074671-31834-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 02/11] 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 4072a7c8f58a..cc80026f2127 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"