summaryrefslogtreecommitdiff
path: root/datapath
diff options
context:
space:
mode:
Diffstat (limited to 'datapath')
-rw-r--r--datapath/conntrack.c2
-rw-r--r--datapath/linux/compat/include/net/netfilter/nf_conntrack_labels.h25
2 files changed, 18 insertions, 9 deletions
diff --git a/datapath/conntrack.c b/datapath/conntrack.c
index c24aa8c16..f30a3b736 100644
--- a/datapath/conntrack.c
+++ b/datapath/conntrack.c
@@ -1403,7 +1403,7 @@ void ovs_ct_init(struct net *net)
unsigned int n_bits = sizeof(struct ovs_key_ct_labels) * BITS_PER_BYTE;
struct ovs_net *ovs_net = net_generic(net, ovs_net_id);
- if (nf_connlabels_get(net, n_bits)) {
+ if (nf_connlabels_get(net, n_bits - 1)) {
ovs_net->xt_label = false;
OVS_NLERR(true, "Failed to set connlabel length");
} else {
diff --git a/datapath/linux/compat/include/net/netfilter/nf_conntrack_labels.h b/datapath/linux/compat/include/net/netfilter/nf_conntrack_labels.h
index a594a0fee..31507c45f 100644
--- a/datapath/linux/compat/include/net/netfilter/nf_conntrack_labels.h
+++ b/datapath/linux/compat/include/net/netfilter/nf_conntrack_labels.h
@@ -5,7 +5,7 @@
#include <linux/version.h>
#include_next <net/netfilter/nf_conntrack_labels.h>
-#ifndef HAVE_NF_CONNLABELS_GET
+#ifndef HAVE_NF_CONNLABELS_GET_TAKES_BIT
#if IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS)
#ifndef NF_CT_LABELS_MAX_SIZE
@@ -14,36 +14,45 @@
/* 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)
+static inline int rpl_nf_connlabels_get(struct net *net, unsigned int bits)
{
+#ifndef HAVE_NF_CONNLABELS_GET
size_t words;
- if (n_bits > (NF_CT_LABELS_MAX_SIZE * BITS_PER_BYTE))
+ words = BIT_WORD(bits) + 1;
+ if (words > NF_CT_LABELS_MAX_SIZE / sizeof(long))
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;
+#else
+ return nf_connlabels_get(net, bits + 1);
+#endif /* HAVE_NF_CONNLABELS_GET */
}
+#define nf_connlabels_get rpl_nf_connlabels_get
-static inline void nf_connlabels_put(struct net *net)
+static inline void rpl_nf_connlabels_put(struct net *net)
{
+#ifndef HAVE_NF_CONNLABELS_GET
net->ct.labels_used--;
if (net->ct.labels_used == 0)
net->ct.label_words = 0;
+#else
+ nf_connlabels_put(net);
+#endif /* HAVE_NF_CONNLABELS_GET */
}
+#define nf_connlabels_put rpl_nf_connlabels_put
#else /* CONFIG_NF_CONNTRACK_LABELS */
-static inline int nf_connlabels_get(struct net *net, unsigned int n_bits)
+static inline int nf_connlabels_get(struct net *net, unsigned int bits)
{
return -ERANGE;
}
static inline void nf_connlabels_put(struct net *net) { }
#endif /* CONFIG_NF_CONNTRACK_LABELS */
-#endif /* HAVE_NF_CONNLABELS_GET */
+#endif /* HAVE_NF_CONNLABELS_GET_TAKES_BIT */
#endif /* _NF_CONNTRACK_LABELS_WRAPPER_H */