0001
0002
0003
0004
0005
0006 #ifndef OVS_CONNTRACK_H
0007 #define OVS_CONNTRACK_H 1
0008
0009 #include "flow.h"
0010
0011 struct ovs_conntrack_info;
0012 struct ovs_ct_limit_info;
0013 enum ovs_key_attr;
0014
0015 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
0016 int ovs_ct_init(struct net *);
0017 void ovs_ct_exit(struct net *);
0018 bool ovs_ct_verify(struct net *, enum ovs_key_attr attr);
0019 int ovs_ct_copy_action(struct net *, const struct nlattr *,
0020 const struct sw_flow_key *, struct sw_flow_actions **,
0021 bool log);
0022 int ovs_ct_action_to_attr(const struct ovs_conntrack_info *, struct sk_buff *);
0023
0024 int ovs_ct_execute(struct net *, struct sk_buff *, struct sw_flow_key *,
0025 const struct ovs_conntrack_info *);
0026 int ovs_ct_clear(struct sk_buff *skb, struct sw_flow_key *key);
0027
0028 void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key,
0029 bool post_ct);
0030 int ovs_ct_put_key(const struct sw_flow_key *swkey,
0031 const struct sw_flow_key *output, struct sk_buff *skb);
0032 void ovs_ct_free_action(const struct nlattr *a);
0033
0034 #define CT_SUPPORTED_MASK (OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | \
0035 OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | \
0036 OVS_CS_F_INVALID | OVS_CS_F_TRACKED | \
0037 OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
0038 #else
0039 #include <linux/errno.h>
0040
0041 static inline int ovs_ct_init(struct net *net) { return 0; }
0042
0043 static inline void ovs_ct_exit(struct net *net) { }
0044
0045 static inline bool ovs_ct_verify(struct net *net, int attr)
0046 {
0047 return false;
0048 }
0049
0050 static inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla,
0051 const struct sw_flow_key *key,
0052 struct sw_flow_actions **acts, bool log)
0053 {
0054 return -ENOTSUPP;
0055 }
0056
0057 static inline int ovs_ct_action_to_attr(const struct ovs_conntrack_info *info,
0058 struct sk_buff *skb)
0059 {
0060 return -ENOTSUPP;
0061 }
0062
0063 static inline int ovs_ct_execute(struct net *net, struct sk_buff *skb,
0064 struct sw_flow_key *key,
0065 const struct ovs_conntrack_info *info)
0066 {
0067 kfree_skb(skb);
0068 return -ENOTSUPP;
0069 }
0070
0071 static inline int ovs_ct_clear(struct sk_buff *skb,
0072 struct sw_flow_key *key)
0073 {
0074 return -ENOTSUPP;
0075 }
0076
0077 static inline void ovs_ct_fill_key(const struct sk_buff *skb,
0078 struct sw_flow_key *key,
0079 bool post_ct)
0080 {
0081 key->ct_state = 0;
0082 key->ct_zone = 0;
0083 key->ct.mark = 0;
0084 memset(&key->ct.labels, 0, sizeof(key->ct.labels));
0085
0086
0087
0088 key->ct_orig_proto = 0;
0089 }
0090
0091 static inline int ovs_ct_put_key(const struct sw_flow_key *swkey,
0092 const struct sw_flow_key *output,
0093 struct sk_buff *skb)
0094 {
0095 return 0;
0096 }
0097
0098 static inline void ovs_ct_free_action(const struct nlattr *a) { }
0099
0100 #define CT_SUPPORTED_MASK 0
0101 #endif
0102
0103 #if IS_ENABLED(CONFIG_NETFILTER_CONNCOUNT)
0104 extern struct genl_family dp_ct_limit_genl_family;
0105 #endif
0106 #endif