[ovs-dev,02/11] datapath: Detect upstream nf_nat change
diff mbox series

Message ID 1571074671-31834-3-git-send-email-yihung.wei@gmail.com
State New
Headers show
Series
  • Backport upstream conntrack related patches
Related show

Commit Message

Yi-Hung Wei Oct. 14, 2019, 5:37 p.m. UTC
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 <yihung.wei@gmail.com>
---
 acinclude.m4         |  2 ++
 datapath/conntrack.c | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

Comments

Yifeng Sun Oct. 14, 2019, 11:35 p.m. UTC | #1
LGTM, thanks.

Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>

On Mon, Oct 14, 2019 at 10:51 AM Yi-Hung Wei <yihung.wei@gmail.com> wrote:
>
> 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 <yihung.wei@gmail.com>
> ---
>  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 <net/ipv6_frag.h>
>
>  #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 <net/netfilter/nf_nat.h>
> +#define CONFIG_NF_NAT_IPV4 CONFIG_NF_NAT
> +#define CONFIG_NF_NAT_IPV6 CONFIG_IPV6
> +#else
>  #include <linux/netfilter/nf_nat.h>
>  #include <net/netfilter/nf_nat_core.h>
>  #include <net/netfilter/nf_nat_l3proto.h>
> -#endif
> +#endif /* HAVE_UPSTREAM_NF_NAT */
> +#endif /* CONFIG_NF_NAT_NEEDED */
>
>  #include "datapath.h"
>  #include "conntrack.h"
> --
> 2.7.4
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Patch
diff mbox series

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 <net/ipv6_frag.h>
 
 #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 <net/netfilter/nf_nat.h>
+#define CONFIG_NF_NAT_IPV4 CONFIG_NF_NAT
+#define CONFIG_NF_NAT_IPV6 CONFIG_IPV6
+#else
 #include <linux/netfilter/nf_nat.h>
 #include <net/netfilter/nf_nat_core.h>
 #include <net/netfilter/nf_nat_l3proto.h>
-#endif
+#endif /* HAVE_UPSTREAM_NF_NAT */
+#endif /* CONFIG_NF_NAT_NEEDED */
 
 #include "datapath.h"
 #include "conntrack.h"