162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2015 Nicira, Inc. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef OVS_CONNTRACK_H 762306a36Sopenharmony_ci#define OVS_CONNTRACK_H 1 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include "flow.h" 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_cistruct ovs_conntrack_info; 1262306a36Sopenharmony_cistruct ovs_ct_limit_info; 1362306a36Sopenharmony_cienum ovs_key_attr; 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_NF_CONNTRACK) 1662306a36Sopenharmony_ciint ovs_ct_init(struct net *); 1762306a36Sopenharmony_civoid ovs_ct_exit(struct net *); 1862306a36Sopenharmony_cibool ovs_ct_verify(struct net *, enum ovs_key_attr attr); 1962306a36Sopenharmony_ciint ovs_ct_copy_action(struct net *, const struct nlattr *, 2062306a36Sopenharmony_ci const struct sw_flow_key *, struct sw_flow_actions **, 2162306a36Sopenharmony_ci bool log); 2262306a36Sopenharmony_ciint ovs_ct_action_to_attr(const struct ovs_conntrack_info *, struct sk_buff *); 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ciint ovs_ct_execute(struct net *, struct sk_buff *, struct sw_flow_key *, 2562306a36Sopenharmony_ci const struct ovs_conntrack_info *); 2662306a36Sopenharmony_ciint ovs_ct_clear(struct sk_buff *skb, struct sw_flow_key *key); 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_civoid ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key, 2962306a36Sopenharmony_ci bool post_ct); 3062306a36Sopenharmony_ciint ovs_ct_put_key(const struct sw_flow_key *swkey, 3162306a36Sopenharmony_ci const struct sw_flow_key *output, struct sk_buff *skb); 3262306a36Sopenharmony_civoid ovs_ct_free_action(const struct nlattr *a); 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#define CT_SUPPORTED_MASK (OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | \ 3562306a36Sopenharmony_ci OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | \ 3662306a36Sopenharmony_ci OVS_CS_F_INVALID | OVS_CS_F_TRACKED | \ 3762306a36Sopenharmony_ci OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT) 3862306a36Sopenharmony_ci#else 3962306a36Sopenharmony_ci#include <linux/errno.h> 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_cistatic inline int ovs_ct_init(struct net *net) { return 0; } 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_cistatic inline void ovs_ct_exit(struct net *net) { } 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_cistatic inline bool ovs_ct_verify(struct net *net, int attr) 4662306a36Sopenharmony_ci{ 4762306a36Sopenharmony_ci return false; 4862306a36Sopenharmony_ci} 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_cistatic inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla, 5162306a36Sopenharmony_ci const struct sw_flow_key *key, 5262306a36Sopenharmony_ci struct sw_flow_actions **acts, bool log) 5362306a36Sopenharmony_ci{ 5462306a36Sopenharmony_ci return -ENOTSUPP; 5562306a36Sopenharmony_ci} 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_cistatic inline int ovs_ct_action_to_attr(const struct ovs_conntrack_info *info, 5862306a36Sopenharmony_ci struct sk_buff *skb) 5962306a36Sopenharmony_ci{ 6062306a36Sopenharmony_ci return -ENOTSUPP; 6162306a36Sopenharmony_ci} 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_cistatic inline int ovs_ct_execute(struct net *net, struct sk_buff *skb, 6462306a36Sopenharmony_ci struct sw_flow_key *key, 6562306a36Sopenharmony_ci const struct ovs_conntrack_info *info) 6662306a36Sopenharmony_ci{ 6762306a36Sopenharmony_ci kfree_skb(skb); 6862306a36Sopenharmony_ci return -ENOTSUPP; 6962306a36Sopenharmony_ci} 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_cistatic inline int ovs_ct_clear(struct sk_buff *skb, 7262306a36Sopenharmony_ci struct sw_flow_key *key) 7362306a36Sopenharmony_ci{ 7462306a36Sopenharmony_ci return -ENOTSUPP; 7562306a36Sopenharmony_ci} 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_cistatic inline void ovs_ct_fill_key(const struct sk_buff *skb, 7862306a36Sopenharmony_ci struct sw_flow_key *key, 7962306a36Sopenharmony_ci bool post_ct) 8062306a36Sopenharmony_ci{ 8162306a36Sopenharmony_ci key->ct_state = 0; 8262306a36Sopenharmony_ci key->ct_zone = 0; 8362306a36Sopenharmony_ci key->ct.mark = 0; 8462306a36Sopenharmony_ci memset(&key->ct.labels, 0, sizeof(key->ct.labels)); 8562306a36Sopenharmony_ci /* Clear 'ct_orig_proto' to mark the non-existence of original 8662306a36Sopenharmony_ci * direction key fields. 8762306a36Sopenharmony_ci */ 8862306a36Sopenharmony_ci key->ct_orig_proto = 0; 8962306a36Sopenharmony_ci} 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_cistatic inline int ovs_ct_put_key(const struct sw_flow_key *swkey, 9262306a36Sopenharmony_ci const struct sw_flow_key *output, 9362306a36Sopenharmony_ci struct sk_buff *skb) 9462306a36Sopenharmony_ci{ 9562306a36Sopenharmony_ci return 0; 9662306a36Sopenharmony_ci} 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_cistatic inline void ovs_ct_free_action(const struct nlattr *a) { } 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#define CT_SUPPORTED_MASK 0 10162306a36Sopenharmony_ci#endif /* CONFIG_NF_CONNTRACK */ 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_NETFILTER_CONNCOUNT) 10462306a36Sopenharmony_ciextern struct genl_family dp_ct_limit_genl_family; 10562306a36Sopenharmony_ci#endif 10662306a36Sopenharmony_ci#endif /* ovs_conntrack.h */ 107