From patchwork Fri Jul 21 23:46:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 792409 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=) 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 3xDnVp0g0dz9s7m for ; Sat, 22 Jul 2017 09:47:14 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B75FABE5; Fri, 21 Jul 2017 23:46:27 +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 E0981BD4 for ; Fri, 21 Jul 2017 23:46:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 163F217E for ; Fri, 21 Jul 2017 23:46:25 +0000 (UTC) Received: from mfilter11-d.gandi.net (mfilter11-d.gandi.net [217.70.178.131]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id DAF69172095; Sat, 22 Jul 2017 01:46:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter11-d.gandi.net Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196]) by mfilter11-d.gandi.net (mfilter11-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 2sl1VaJt6yZp; Sat, 22 Jul 2017 01:46:22 +0200 (CEST) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 4A97D17209C; Sat, 22 Jul 2017 01:46:20 +0200 (CEST) From: Joe Stringer To: dev@openvswitch.org Date: Fri, 21 Jul 2017 16:46:04 -0700 Message-Id: <20170721234614.2800-2-joe@ovn.org> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170721234614.2800-1-joe@ovn.org> References: <20170721234614.2800-1-joe@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW 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 01/11] datapath: introduce nf_conntrack_helper_put function 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 From: Greg Rose Upstream commit: commit d91fc59cd77c719f33eda65c194ad8f95a055190 Author: Liping Zhang Date: Sun May 7 22:01:55 2017 +0800 netfilter: introduce nf_conntrack_helper_put helper function And convert module_put invocation to nf_conntrack_helper_put, this is prepared for the followup patch, which will add a refcnt for cthelper, so we can reject the deleting request when cthelper is in use. Signed-off-by: Liping Zhang Signed-off-by: Pablo Neira Ayuso Applied with additional use of HAVE_NF_CONNTRACK_HELPER_PUT compatibility flag defined in acinclude.m4. Signed-off-by: Greg Rose Signed-off-by: Joe Stringer --- v2: Shift compat symbol definitions to patch which uses it. Add nf_conntrack_helper.h compat header to define the new function. --- acinclude.m4 | 2 ++ datapath/conntrack.c | 4 ++-- datapath/linux/Modules.mk | 1 + .../linux/compat/include/net/netfilter/nf_conntrack_helper.h | 12 ++++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 datapath/linux/compat/include/net/netfilter/nf_conntrack_helper.h diff --git a/acinclude.m4 b/acinclude.m4 index e7affc514811..62a91e650a4a 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -748,6 +748,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ [OVS_DEFINE([HAVE_DEFRAG_ENABLE_TAKES_NET])]) OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [family_list], [OVS_DEFINE([HAVE_GENL_FAMILY_LIST])]) + OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_helper.h], + [nf_conntrack_helper_put]) if cmp -s datapath/linux/kcompat.h.new \ datapath/linux/kcompat.h >/dev/null 2>&1; then diff --git a/datapath/conntrack.c b/datapath/conntrack.c index bf28fc071929..01f54bf048c6 100644 --- a/datapath/conntrack.c +++ b/datapath/conntrack.c @@ -1164,7 +1164,7 @@ static int ovs_ct_add_helper(struct ovs_conntrack_info *info, const char *name, help = nf_ct_helper_ext_add(info->ct, helper, GFP_KERNEL); if (!help) { - module_put(helper->me); + nf_conntrack_helper_put(helper); return -ENOMEM; } @@ -1634,7 +1634,7 @@ void ovs_ct_free_action(const struct nlattr *a) static void __ovs_ct_free_action(struct ovs_conntrack_info *ct_info) { if (ct_info->helper) - module_put(ct_info->helper->me); + nf_conntrack_helper_put(ct_info->helper); if (ct_info->ct) nf_ct_tmpl_free(ct_info->ct); } diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk index 985ffed4557a..eec9f2338d98 100644 --- a/datapath/linux/Modules.mk +++ b/datapath/linux/Modules.mk @@ -95,6 +95,7 @@ openvswitch_headers += \ linux/compat/include/net/netfilter/nf_conntrack.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_helper.h \ linux/compat/include/net/netfilter/nf_conntrack_labels.h \ linux/compat/include/net/netfilter/nf_conntrack_seqadj.h \ linux/compat/include/net/netfilter/nf_conntrack_zones.h \ diff --git a/datapath/linux/compat/include/net/netfilter/nf_conntrack_helper.h b/datapath/linux/compat/include/net/netfilter/nf_conntrack_helper.h new file mode 100644 index 000000000000..19c35cd95f6f --- /dev/null +++ b/datapath/linux/compat/include/net/netfilter/nf_conntrack_helper.h @@ -0,0 +1,12 @@ +#ifndef _NF_CONNTRACK_HELPER_WRAPPER_H +#define _NF_CONNTRACK_HELPER_WRAPPER_H + +#include_next + +#ifndef HAVE_NF_CONNTRACK_HELPER_PUT +static inline void nf_conntrack_helper_put(struct nf_conntrack_helper *helper) { + module_put(helper->me); +} +#endif + +#endif /* _NF_CONNTRACK_HELPER_WRAPPER_H */