From patchwork Thu Dec 3 07:53:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 552057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 6F3061402EC for ; Thu, 3 Dec 2015 18:54:41 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 8BE5A10B4F; Wed, 2 Dec 2015 23:54:24 -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 02EC810B46 for ; Wed, 2 Dec 2015 23:54:23 -0800 (PST) Received: from bar3.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 84BFE161901 for ; Thu, 3 Dec 2015 00:54:22 -0700 (MST) X-ASG-Debug-ID: 1449129262-03dd7b0fbd76d160001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar3.cudamail.com with ESMTP id 2EmG0XAxYC5JQF4a (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 03 Dec 2015 00:54:22 -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:10 -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 mfilter21-d.gandi.net (mfilter21-d.gandi.net [217.70.178.149]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 61E9017209A; Thu, 3 Dec 2015 08:54:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter21-d.gandi.net Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196]) by mfilter21-d.gandi.net (mfilter21-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id bvEPu-_s9pc1; Thu, 3 Dec 2015 08:54:19 +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 8C7AF1720A1; Thu, 3 Dec 2015 08:54:17 +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-1202000828 X-CudaMail-DTE: 120315 X-CudaMail-Originating-IP: 217.70.183.196 Date: Wed, 2 Dec 2015 23:53:39 -0800 X-ASG-Orig-Subj: [##CM-V3-1202000828##][PATCHv2 03/20] compat: Backport nf_connlabels_{get, put}(). Message-Id: <1449129236-5038-4-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: 1449129262 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 03/20] compat: Backport nf_connlabels_{get, put}(). 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 This is a partial backport of Linux commit 86ca02e77408 "netfilter: connlabels: Export setting connlabel length". Signed-off-by: Joe Stringer --- datapath/linux/Modules.mk | 1 + .../include/net/netfilter/nf_conntrack_labels.h | 41 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 datapath/linux/compat/include/net/netfilter/nf_conntrack_labels.h diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk index 29a90ea1dd8b..02bab71c1861 100644 --- a/datapath/linux/Modules.mk +++ b/datapath/linux/Modules.mk @@ -93,6 +93,7 @@ openvswitch_headers += \ 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_labels.h \ linux/compat/include/net/netfilter/nf_conntrack_zones.h \ linux/compat/include/net/sctp/checksum.h EXTRA_DIST += linux/compat/build-aux/export-check-whitelist diff --git a/datapath/linux/compat/include/net/netfilter/nf_conntrack_labels.h b/datapath/linux/compat/include/net/netfilter/nf_conntrack_labels.h new file mode 100644 index 000000000000..e49a289c5388 --- /dev/null +++ b/datapath/linux/compat/include/net/netfilter/nf_conntrack_labels.h @@ -0,0 +1,41 @@ +#ifndef _NF_CONNTRACK_LABELS_WRAPPER_H +#define _NF_CONNTRACK_LABELS_WRAPPER_H + +#include +#include +#include_next + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0) && \ + IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) + +#ifndef NF_CT_LABELS_MAX_SIZE +#define NF_CT_LABELS_MAX_SIZE ((XT_CONNLABEL_MAXBIT + 1) / BITS_PER_BYTE) +#endif + +/* XXX: This doesn't lock others out from doing the same configuration + * simultaneously. */ +static inline int nf_connlabels_get(struct net *net, unsigned int n_bits) +{ + size_t words; + + if (n_bits > (NF_CT_LABELS_MAX_SIZE * BITS_PER_BYTE)) + return -ERANGE; + + words = BITS_TO_LONGS(n_bits); + + net->ct.labels_used++; + if (words > net->ct.label_words) + net->ct.label_words = words; + + return 0; +} + +static inline void nf_connlabels_put(struct net *net) +{ + net->ct.labels_used--; + if (net->ct.labels_used == 0) + net->ct.label_words = 0; +} + +#endif +#endif /* _NF_CONNTRACK_LABELS_WRAPPER_H */