]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/net/netfilter/nf_conntrack_labels.h
0fd4989de8360dc9f3c00855334dd30b03b1233b
[mirror_ubuntu-artful-kernel.git] / include / net / netfilter / nf_conntrack_labels.h
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>
7
8 #include <uapi/linux/netfilter/xt_connlabel.h>
9
10 #define NF_CT_LABELS_MAX_SIZE ((XT_CONNLABEL_MAXBIT + 1) / BITS_PER_BYTE)
11
12 struct nf_conn_labels {
13 unsigned long bits[NF_CT_LABELS_MAX_SIZE / sizeof(long)];
14 };
15
16 static inline struct nf_conn_labels *nf_ct_labels_find(const struct nf_conn *ct)
17 {
18 #ifdef CONFIG_NF_CONNTRACK_LABELS
19 return nf_ct_ext_find(ct, NF_CT_EXT_LABELS);
20 #else
21 return NULL;
22 #endif
23 }
24
25 static inline struct nf_conn_labels *nf_ct_labels_ext_add(struct nf_conn *ct)
26 {
27 #ifdef CONFIG_NF_CONNTRACK_LABELS
28 struct net *net = nf_ct_net(ct);
29
30 if (net->ct.labels_used == 0)
31 return NULL;
32
33 return nf_ct_ext_add_length(ct, NF_CT_EXT_LABELS,
34 sizeof(struct nf_conn_labels), GFP_ATOMIC);
35 #else
36 return NULL;
37 #endif
38 }
39
40 int nf_connlabel_set(struct nf_conn *ct, u16 bit);
41
42 int nf_connlabels_replace(struct nf_conn *ct,
43 const u32 *data, const u32 *mask, unsigned int words);
44
45 #ifdef CONFIG_NF_CONNTRACK_LABELS
46 int nf_conntrack_labels_init(void);
47 void nf_conntrack_labels_fini(void);
48 int nf_connlabels_get(struct net *net, unsigned int bit);
49 void nf_connlabels_put(struct net *net);
50 #else
51 static inline int nf_conntrack_labels_init(void) { return 0; }
52 static inline void nf_conntrack_labels_fini(void) {}
53 static inline int nf_connlabels_get(struct net *net, unsigned int bit) { return 0; }
54 static inline void nf_connlabels_put(struct net *net) {}
55 #endif