Skip to content

Commit

Permalink
compat: Detect and use struct nf_conntrack_zone.
Browse files Browse the repository at this point in the history
Rather than relying on version checks, detect the presence of this
structure and use it if available.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
  • Loading branch information
joestringer committed Feb 2, 2016
1 parent 55764d9 commit a692753
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions acinclude.m4
Expand Up @@ -392,6 +392,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
[tmpl_alloc.*conntrack_zone],
[OVS_DEFINE([HAVE_NF_CT_TMPL_ALLOC_TAKES_STRUCT_ZONE])])
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_zones.h],
[nf_ct_zone_init])
OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32])
OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32_max])
Expand Down
Expand Up @@ -3,7 +3,7 @@

#include_next <net/netfilter/nf_conntrack_expect.h>

#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
#ifndef HAVE_NF_CT_ZONE_INIT

#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_zones.h>
Expand All @@ -17,5 +17,5 @@ rpl___nf_ct_expect_find(struct net *net,
}
#define __nf_ct_expect_find rpl___nf_ct_expect_find

#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0) */
#endif /* HAVE_NF_CT_ZONE_INIT */
#endif /* _NF_CONNTRACK_EXPECT_WRAPPER_H */
Expand Up @@ -7,7 +7,7 @@
#include_next <net/netfilter/nf_conntrack_zones.h>
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
#ifndef HAVE_NF_CT_ZONE_INIT

#include <linux/kconfig.h>
#include <linux/types.h>
Expand Down Expand Up @@ -99,5 +99,5 @@ static inline bool nf_ct_zone_equal_any(const struct nf_conn *a,
return nf_ct_zone(a)->id == b->id;
}
#endif /* IS_ENABLED(CONFIG_NF_CONNTRACK) */
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0) */
#endif /* HAVE_NF_CT_ZONE_INIT */
#endif /* _NF_CONNTRACK_ZONES_WRAPPER_H */
4 changes: 2 additions & 2 deletions datapath/linux/compat/nf_conntrack_core.c
@@ -1,6 +1,6 @@
#include <linux/version.h>

#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
#ifndef HAVE_NF_CT_ZONE_INIT

#include <net/netfilter/nf_conntrack_zones.h>

Expand All @@ -10,4 +10,4 @@ const struct nf_conntrack_zone nf_ct_zone_dflt = {
.dir = NF_CT_DEFAULT_ZONE_DIR,
};

#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0) */
#endif /* HAVE_NF_CT_ZONE_INIT */

0 comments on commit a692753

Please sign in to comment.