From patchwork Thu Dec 3 07:53:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 552056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 388251402EC for ; Thu, 3 Dec 2015 18:54:34 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 4581E10B39; Wed, 2 Dec 2015 23:54:22 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 74CC210B20 for ; Wed, 2 Dec 2015 23:54:21 -0800 (PST) Received: from bar4.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 0BB15161901 for ; Thu, 3 Dec 2015 00:54:21 -0700 (MST) X-ASG-Debug-ID: 1449129260-03dc21603e82f600001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar4.cudamail.com with ESMTP id R2nhvZijNDrYDkrl (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 03 Dec 2015 00:54:20 -0700 (MST) X-Barracuda-Envelope-From: joe@ovn.org X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO relay4-d.mail.gandi.net) (217.70.183.196) by mx3-pf3.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 3 Dec 2015 08:01:08 -0000 Received-SPF: pass (mx3-pf3.cudamail.com: SPF record at ovn.org designates 217.70.183.196 as permitted sender) X-Barracuda-Apparent-Source-IP: 217.70.183.196 X-Barracuda-RBL-IP: 217.70.183.196 Received: from mfilter19-d.gandi.net (mfilter19-d.gandi.net [217.70.178.147]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 93D531720C3; Thu, 3 Dec 2015 08:54:18 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter19-d.gandi.net Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196]) by mfilter19-d.gandi.net (mfilter19-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id it-3S3Ic1H59; Thu, 3 Dec 2015 08:54:17 +0100 (CET) X-Originating-IP: 208.91.1.34 Received: from localhost.localdomain (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id C103117209D; Thu, 3 Dec 2015 08:54:14 +0100 (CET) X-CudaMail-Envelope-Sender: joe@ovn.org From: Joe Stringer To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V3-1202000827 X-CudaMail-DTE: 120315 X-CudaMail-Originating-IP: 217.70.183.196 Date: Wed, 2 Dec 2015 23:53:38 -0800 X-ASG-Orig-Subj: [##CM-V3-1202000827##][PATCHv2 02/20] compat: Backport nf_ct_tmpl_alloc(). Message-Id: <1449129236-5038-3-git-send-email-joe@ovn.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449129236-5038-1-git-send-email-joe@ovn.org> References: <1449129236-5038-1-git-send-email-joe@ovn.org> X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1449129260 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCHv2 02/20] compat: Backport nf_ct_tmpl_alloc(). X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" From: Joe Stringer 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 --- v2: Backport missing nf_ct_tmpl_free(). Fix warning on Linux-4.2. --- acinclude.m4 | 4 ++ datapath/linux/Modules.mk | 1 + .../include/net/netfilter/nf_conntrack_core.h | 44 ++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h diff --git a/acinclude.m4 b/acinclude.m4 index 7c8afaca62a7..a3dd3eb99bbd 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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]) diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk index 63179655cee5..29a90ea1dd8b 100644 --- a/datapath/linux/Modules.mk +++ b/datapath/linux/Modules.mk @@ -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 diff --git a/datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h b/datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h new file mode 100644 index 000000000000..faa219a4ba65 --- /dev/null +++ b/datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h @@ -0,0 +1,44 @@ +#ifndef _NF_CONNTRACK_CORE_WRAPPER_H +#define _NF_CONNTRACK_CORE_WRAPPER_H + +#include_next + +#ifndef HAVE_NF_CT_TMPL_ALLOC_TAKES_STRUCT_ZONE + +#include + +#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 */