From patchwork Sat Nov 7 19:59:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 541362 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 B3DCC1402C6 for ; Sun, 8 Nov 2015 07:00:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nicira_com.20150623.gappssmtp.com header.i=@nicira_com.20150623.gappssmtp.com header.b=htjd6ElW; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id A537A109E7; Sat, 7 Nov 2015 12:00:19 -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 89CB1109D7 for ; Sat, 7 Nov 2015 12:00:18 -0800 (PST) Received: from bar3.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 1CED6162F83 for ; Sat, 7 Nov 2015 13:00:18 -0700 (MST) X-ASG-Debug-ID: 1446926417-03dd7b490b1f0d0001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar3.cudamail.com with ESMTP id LVvSYV3ae6IaOhAP (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 07 Nov 2015 13:00:17 -0700 (MST) X-Barracuda-Envelope-From: joestringer@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mail-pa0-f53.google.com) (209.85.220.53) by mx3-pf3.cudamail.com with ESMTPS (RC4-SHA encrypted); 7 Nov 2015 20:10:25 -0000 Received-SPF: unknown (mx3-pf3.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.53 Received: by pasz6 with SMTP id z6so160769064pas.2 for ; Sat, 07 Nov 2015 12:00:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nicira_com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=rfvckSQxQXIPWZxwQHzjGp148VfPV1D2ChVJ6Zb4uJY=; b=htjd6ElWFuwSebWqhuYLiHLvftlyM4DSI7eNrDPq0IcyZxspfiMaZYXUNofs/zWtum L2cbl7Ir+EBtpezluOt5m3LA5V3yV0AKW/hxDFvh03B8SKdY2jdlBbaSOChFxzxt+2lz zw06RZKsGJNidq25SxkjRuPywChVmZHQMObyUHRLdP6L+kN+ncnt/SpsN5VideNvFzq0 9lQ0+dcxI4LK/j7rAkCGEucNnyfGMYK2V4UUakn7v0LMuMfV+ZfnL2JdnuHGC5YgY1es XQD3owl4oJs6Ke3Wfu7ctAgfoR8+RRWr/OSmIlvOgBNIwLRZDJLgxkDPgCvDRqtvaGyT NTDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=rfvckSQxQXIPWZxwQHzjGp148VfPV1D2ChVJ6Zb4uJY=; b=NQqyC4cfYj1+Z6bHgVpn8vE9TQLgIMDk3cQOQYCgql9bZtsDbD7s/ICQFM2hx7cEuT +LHO8WluOqADA0jO87XBVDriNZWIrcNzPunI5rG64lPihsm5/XBd2f8heATUETZoacXR zGGI2L8ZJONZQGpZmPuQBODrdOgkfsLt+E0t/PEULnHehqpnn0ZITpY6K1okO9k0Z+td V3khJVfQS7atUrEofI2id/gh1fax7AYIgsLBwaACcqayvq9ngJJ7FTZ/YZnj3eDcM4ws 9KgwlJ3089txOpgX4fIVE5cyaZHg5DCZjiL6bnTXRmnap54YXtzFpP+uyiiw8k+xksmb ub5Q== X-Gm-Message-State: ALoCoQlHivFwdlX/KwhJM5whNAqZMrbz1x9EiqGNXlHz619Hrmhry9jbzK2tsLjmcy09oZG8gG/Z X-Received: by 10.68.179.228 with SMTP id dj4mr27737422pbc.112.1446926416417; Sat, 07 Nov 2015 12:00:16 -0800 (PST) Received: from localhost.localdomain ([208.91.2.4]) by smtp.gmail.com with ESMTPSA id nu5sm7312219pbb.65.2015.11.07.12.00.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 07 Nov 2015 12:00:15 -0800 (PST) X-CudaMail-Envelope-Sender: joestringer@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.2.4 From: Joe Stringer To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V3-1106015550 X-CudaMail-DTE: 110715 X-CudaMail-Originating-IP: 209.85.220.53 Date: Sat, 7 Nov 2015 11:59:41 -0800 X-ASG-Orig-Subj: [##CM-V3-1106015550##][PATCH 03/23] compat: Backport nf_connlabels_{get, put}(). Message-Id: <1446926401-55723-4-git-send-email-joestringer@nicira.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446926401-55723-1-git-send-email-joestringer@nicira.com> References: <1446926401-55723-1-git-send-email-joestringer@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1446926417 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] [PATCH 03/23] 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" 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 db5af0f7f65f..ac1870fc0fb7 100644 --- a/datapath/linux/Modules.mk +++ b/datapath/linux/Modules.mk @@ -94,6 +94,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 */