datapath: Allow matching on conntrack mark
[cascardo/ovs.git] / datapath / conntrack.h
1 /*
2  * Copyright (c) 2015 Nicira, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of version 2 of the GNU General Public
6  * License as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  */
13
14 #ifndef OVS_CONNTRACK_H
15 #define OVS_CONNTRACK_H 1
16
17 #include <linux/version.h>
18 #include "flow.h"
19
20 struct ovs_conntrack_info;
21 enum ovs_key_attr;
22
23 #if IS_ENABLED(CONFIG_NF_CONNTRACK) && LINUX_VERSION_CODE > KERNEL_VERSION(3,9,0)
24 bool ovs_ct_verify(enum ovs_key_attr attr);
25 int ovs_ct_copy_action(struct net *, const struct nlattr *,
26                        const struct sw_flow_key *, struct sw_flow_actions **,
27                        bool log);
28 int ovs_ct_action_to_attr(const struct ovs_conntrack_info *, struct sk_buff *);
29
30 int ovs_ct_execute(struct net *, struct sk_buff *, struct sw_flow_key *,
31                    const struct ovs_conntrack_info *);
32
33 void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key);
34 int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb);
35 void ovs_ct_free_action(const struct nlattr *a);
36 #else
37 #include <linux/errno.h>
38
39 static inline bool ovs_ct_verify(int attr)
40 {
41         return false;
42 }
43
44 static inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla,
45                                      const struct sw_flow_key *key,
46                                      struct sw_flow_actions **acts, bool log)
47 {
48         return -ENOTSUPP;
49 }
50
51 static inline int ovs_ct_action_to_attr(const struct ovs_conntrack_info *info,
52                                         struct sk_buff *skb)
53 {
54         return -ENOTSUPP;
55 }
56
57 static inline int ovs_ct_execute(struct net *net, struct sk_buff *skb,
58                                  struct sw_flow_key *key,
59                                  const struct ovs_conntrack_info *info)
60 {
61         return -ENOTSUPP;
62 }
63
64 static inline void ovs_ct_fill_key(const struct sk_buff *skb,
65                                    struct sw_flow_key *key)
66 {
67         key->ct.state = 0;
68         key->ct.zone = 0;
69         key->ct.mark = 0;
70 }
71
72 static inline int ovs_ct_put_key(const struct sw_flow_key *key,
73                                  struct sk_buff *skb)
74 {
75         return 0;
76 }
77
78 static inline void ovs_ct_free_action(const struct nlattr *a) { }
79 #endif
80 #endif /* ovs_conntrack.h */