1 #include <linux/types.h>
2 #include <net/net_namespace.h>
3 #include <linux/netfilter/nf_conntrack_common.h>
4 #include <linux/netfilter/nf_conntrack_tuple_common.h>
5 #include <net/netfilter/nf_conntrack.h>
6 #include <net/netfilter/nf_conntrack_extend.h>
8 #include <uapi/linux/netfilter/xt_connlabel.h>
10 struct nf_conn_labels {
15 static inline struct nf_conn_labels *nf_ct_labels_find(const struct nf_conn *ct)
17 #ifdef CONFIG_NF_CONNTRACK_LABELS
18 return nf_ct_ext_find(ct, NF_CT_EXT_LABELS);
24 static inline struct nf_conn_labels *nf_ct_labels_ext_add(struct nf_conn *ct)
26 #ifdef CONFIG_NF_CONNTRACK_LABELS
27 struct nf_conn_labels *cl_ext;
28 struct net *net = nf_ct_net(ct);
31 words = ACCESS_ONCE(net->ct.label_words);
32 if (words == 0 || WARN_ON_ONCE(words > 8))
35 cl_ext = nf_ct_ext_add_length(ct, NF_CT_EXT_LABELS,
36 words * sizeof(long), GFP_ATOMIC);
38 cl_ext->words = words;
46 bool nf_connlabel_match(const struct nf_conn *ct, u16 bit);
47 int nf_connlabel_set(struct nf_conn *ct, u16 bit);
49 int nf_connlabels_replace(struct nf_conn *ct,
50 const u32 *data, const u32 *mask, unsigned int words);
52 #ifdef CONFIG_NF_CONNTRACK_LABELS
53 int nf_conntrack_labels_init(void);
54 void nf_conntrack_labels_fini(void);
56 static inline int nf_conntrack_labels_init(void) { return 0; }
57 static inline void nf_conntrack_labels_fini(void) {}