1 #ifndef _NF_CONNTRACK_LABELS_WRAPPER_H
2 #define _NF_CONNTRACK_LABELS_WRAPPER_H
4 #include <linux/kconfig.h>
5 #include <linux/version.h>
6 #include_next <net/netfilter/nf_conntrack_labels.h>
8 #ifndef HAVE_NF_CONNLABELS_GET
9 #if IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS)
11 #ifndef NF_CT_LABELS_MAX_SIZE
12 #define NF_CT_LABELS_MAX_SIZE ((XT_CONNLABEL_MAXBIT + 1) / BITS_PER_BYTE)
15 /* XXX: This doesn't lock others out from doing the same configuration
17 static inline int nf_connlabels_get(struct net *net, unsigned int n_bits)
21 if (n_bits > (NF_CT_LABELS_MAX_SIZE * BITS_PER_BYTE))
24 words = BITS_TO_LONGS(n_bits);
26 net->ct.labels_used++;
27 if (words > net->ct.label_words)
28 net->ct.label_words = words;
33 static inline void nf_connlabels_put(struct net *net)
35 net->ct.labels_used--;
36 if (net->ct.labels_used == 0)
37 net->ct.label_words = 0;
40 #else /* CONFIG_NF_CONNTRACK_LABELS */
41 static inline int nf_connlabels_get(struct net *net, unsigned int n_bits)
46 static inline void nf_connlabels_put(struct net *net) { }
47 #endif /* CONFIG_NF_CONNTRACK_LABELS */
48 #endif /* HAVE_NF_CONNLABELS_GET */
49 #endif /* _NF_CONNTRACK_LABELS_WRAPPER_H */