Merge tag 'drm-intel-next-fixes-2016-05-25' of git://anongit.freedesktop.org/drm...
[deliverable/linux.git] / include / net / netfilter / nf_conntrack_labels.h
CommitLineData
c539f017
FW
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
d2bf2f34
FW
10#define NF_CT_LABELS_MAX_SIZE ((XT_CONNLABEL_MAXBIT + 1) / BITS_PER_BYTE)
11
c539f017
FW
12struct nf_conn_labels {
13 u8 words;
14 unsigned long bits[];
15};
16
17static inline struct nf_conn_labels *nf_ct_labels_find(const struct nf_conn *ct)
18{
19#ifdef CONFIG_NF_CONNTRACK_LABELS
20 return nf_ct_ext_find(ct, NF_CT_EXT_LABELS);
21#else
22 return NULL;
23#endif
24}
25
26static inline struct nf_conn_labels *nf_ct_labels_ext_add(struct nf_conn *ct)
27{
28#ifdef CONFIG_NF_CONNTRACK_LABELS
29 struct nf_conn_labels *cl_ext;
30 struct net *net = nf_ct_net(ct);
31 u8 words;
32
33 words = ACCESS_ONCE(net->ct.label_words);
d2bf2f34 34 if (words == 0)
c539f017
FW
35 return NULL;
36
37 cl_ext = nf_ct_ext_add_length(ct, NF_CT_EXT_LABELS,
38 words * sizeof(long), GFP_ATOMIC);
39 if (cl_ext != NULL)
40 cl_ext->words = words;
41
42 return cl_ext;
43#else
44 return NULL;
45#endif
46}
47
c539f017
FW
48int nf_connlabel_set(struct nf_conn *ct, u16 bit);
49
9b21f6a9
FW
50int nf_connlabels_replace(struct nf_conn *ct,
51 const u32 *data, const u32 *mask, unsigned int words);
52
c539f017 53#ifdef CONFIG_NF_CONNTRACK_LABELS
5f69b8f5
G
54int nf_conntrack_labels_init(void);
55void nf_conntrack_labels_fini(void);
adff6c65 56int nf_connlabels_get(struct net *net, unsigned int bit);
86ca02e7 57void nf_connlabels_put(struct net *net);
c539f017 58#else
5f69b8f5
G
59static inline int nf_conntrack_labels_init(void) { return 0; }
60static inline void nf_conntrack_labels_fini(void) {}
adff6c65 61static inline int nf_connlabels_get(struct net *net, unsigned int bit) { return 0; }
86ca02e7 62static inline void nf_connlabels_put(struct net *net) {}
c539f017 63#endif
This page took 0.179195 seconds and 5 git commands to generate.