2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

compat: Backport nf_ct_tmpl_alloc().

Loosely based upon Linux commit 0838aa7fcfcd "netfilter: fix netns
dependencies with conntrack templates" and commit 5e8018fc6142
"netfilter: nf_conntrack: add efficient mark to zone mapping".

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
This commit is contained in:
Joe Stringer
2015-12-02 23:53:38 -08:00
committed by Joe Stringer
parent 420c9726b6
commit 057772cf24
3 changed files with 49 additions and 0 deletions

View File

@@ -376,6 +376,10 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
OVS_GREP_IFELSE([$KSRC/include/linux/netfilter.h], [nf_hookfn.*nf_hook_ops],
[OVS_DEFINE([HAVE_NF_HOOKFN_ARG_OPS])])
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/linux/random.h], [prandom_u32])
OVS_GREP_IFELSE([$KSRC/include/net/rtnetlink.h], [get_link_net])

View File

@@ -91,6 +91,7 @@ openvswitch_headers += \
linux/compat/include/net/sock.h \
linux/compat/include/net/stt.h \
linux/compat/include/net/vxlan.h \
linux/compat/include/net/netfilter/nf_conntrack_core.h \
linux/compat/include/net/netfilter/nf_conntrack_expect.h \
linux/compat/include/net/netfilter/nf_conntrack_zones.h \
linux/compat/include/net/sctp/checksum.h

View File

@@ -0,0 +1,44 @@
#ifndef _NF_CONNTRACK_CORE_WRAPPER_H
#define _NF_CONNTRACK_CORE_WRAPPER_H
#include_next <net/netfilter/nf_conntrack_core.h>
#ifndef HAVE_NF_CT_TMPL_ALLOC_TAKES_STRUCT_ZONE
#include <net/netfilter/nf_conntrack_zones.h>
#define nf_ct_tmpl_alloc rpl_nf_ct_tmpl_alloc
/* Released via destroy_conntrack() */
static inline struct nf_conn *
nf_ct_tmpl_alloc(struct net *net, const struct nf_conntrack_zone *zone,
gfp_t flags)
{
struct nf_conn *tmpl;
tmpl = kzalloc(sizeof(*tmpl), flags);
if (tmpl == NULL)
return NULL;
tmpl->status = IPS_TEMPLATE;
write_pnet(&tmpl->ct_net, net);
if (nf_ct_zone_add(tmpl, flags, zone) < 0)
goto out_free;
atomic_set(&tmpl->ct_general.use, 0);
return tmpl;
out_free:
kfree(tmpl);
return NULL;
}
static void rpl_nf_ct_tmpl_free(struct nf_conn *tmpl)
{
nf_ct_ext_destroy(tmpl);
nf_ct_ext_free(tmpl);
kfree(tmpl);
}
#define nf_ct_tmpl_free rpl_nf_ct_tmpl_free
#endif /* HAVE_NF_CT_TMPL_ALLOC */
#endif /* _NF_CONNTRACK_CORE_WRAPPER_H */