18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2015 Nicira, Inc. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef OVS_CONNTRACK_H 78c2ecf20Sopenharmony_ci#define OVS_CONNTRACK_H 1 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include "flow.h" 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistruct ovs_conntrack_info; 128c2ecf20Sopenharmony_cistruct ovs_ct_limit_info; 138c2ecf20Sopenharmony_cienum ovs_key_attr; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_NF_CONNTRACK) 168c2ecf20Sopenharmony_ciint ovs_ct_init(struct net *); 178c2ecf20Sopenharmony_civoid ovs_ct_exit(struct net *); 188c2ecf20Sopenharmony_cibool ovs_ct_verify(struct net *, enum ovs_key_attr attr); 198c2ecf20Sopenharmony_ciint ovs_ct_copy_action(struct net *, const struct nlattr *, 208c2ecf20Sopenharmony_ci const struct sw_flow_key *, struct sw_flow_actions **, 218c2ecf20Sopenharmony_ci bool log); 228c2ecf20Sopenharmony_ciint ovs_ct_action_to_attr(const struct ovs_conntrack_info *, struct sk_buff *); 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciint ovs_ct_execute(struct net *, struct sk_buff *, struct sw_flow_key *, 258c2ecf20Sopenharmony_ci const struct ovs_conntrack_info *); 268c2ecf20Sopenharmony_ciint ovs_ct_clear(struct sk_buff *skb, struct sw_flow_key *key); 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_civoid ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key); 298c2ecf20Sopenharmony_ciint ovs_ct_put_key(const struct sw_flow_key *swkey, 308c2ecf20Sopenharmony_ci const struct sw_flow_key *output, struct sk_buff *skb); 318c2ecf20Sopenharmony_civoid ovs_ct_free_action(const struct nlattr *a); 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define CT_SUPPORTED_MASK (OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | \ 348c2ecf20Sopenharmony_ci OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | \ 358c2ecf20Sopenharmony_ci OVS_CS_F_INVALID | OVS_CS_F_TRACKED | \ 368c2ecf20Sopenharmony_ci OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT) 378c2ecf20Sopenharmony_ci#else 388c2ecf20Sopenharmony_ci#include <linux/errno.h> 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistatic inline int ovs_ct_init(struct net *net) { return 0; } 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistatic inline void ovs_ct_exit(struct net *net) { } 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistatic inline bool ovs_ct_verify(struct net *net, int attr) 458c2ecf20Sopenharmony_ci{ 468c2ecf20Sopenharmony_ci return false; 478c2ecf20Sopenharmony_ci} 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistatic inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla, 508c2ecf20Sopenharmony_ci const struct sw_flow_key *key, 518c2ecf20Sopenharmony_ci struct sw_flow_actions **acts, bool log) 528c2ecf20Sopenharmony_ci{ 538c2ecf20Sopenharmony_ci return -ENOTSUPP; 548c2ecf20Sopenharmony_ci} 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistatic inline int ovs_ct_action_to_attr(const struct ovs_conntrack_info *info, 578c2ecf20Sopenharmony_ci struct sk_buff *skb) 588c2ecf20Sopenharmony_ci{ 598c2ecf20Sopenharmony_ci return -ENOTSUPP; 608c2ecf20Sopenharmony_ci} 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistatic inline int ovs_ct_execute(struct net *net, struct sk_buff *skb, 638c2ecf20Sopenharmony_ci struct sw_flow_key *key, 648c2ecf20Sopenharmony_ci const struct ovs_conntrack_info *info) 658c2ecf20Sopenharmony_ci{ 668c2ecf20Sopenharmony_ci kfree_skb(skb); 678c2ecf20Sopenharmony_ci return -ENOTSUPP; 688c2ecf20Sopenharmony_ci} 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistatic inline int ovs_ct_clear(struct sk_buff *skb, 718c2ecf20Sopenharmony_ci struct sw_flow_key *key) 728c2ecf20Sopenharmony_ci{ 738c2ecf20Sopenharmony_ci return -ENOTSUPP; 748c2ecf20Sopenharmony_ci} 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistatic inline void ovs_ct_fill_key(const struct sk_buff *skb, 778c2ecf20Sopenharmony_ci struct sw_flow_key *key) 788c2ecf20Sopenharmony_ci{ 798c2ecf20Sopenharmony_ci key->ct_state = 0; 808c2ecf20Sopenharmony_ci key->ct_zone = 0; 818c2ecf20Sopenharmony_ci key->ct.mark = 0; 828c2ecf20Sopenharmony_ci memset(&key->ct.labels, 0, sizeof(key->ct.labels)); 838c2ecf20Sopenharmony_ci /* Clear 'ct_orig_proto' to mark the non-existence of original 848c2ecf20Sopenharmony_ci * direction key fields. 858c2ecf20Sopenharmony_ci */ 868c2ecf20Sopenharmony_ci key->ct_orig_proto = 0; 878c2ecf20Sopenharmony_ci} 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_cistatic inline int ovs_ct_put_key(const struct sw_flow_key *swkey, 908c2ecf20Sopenharmony_ci const struct sw_flow_key *output, 918c2ecf20Sopenharmony_ci struct sk_buff *skb) 928c2ecf20Sopenharmony_ci{ 938c2ecf20Sopenharmony_ci return 0; 948c2ecf20Sopenharmony_ci} 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_cistatic inline void ovs_ct_free_action(const struct nlattr *a) { } 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define CT_SUPPORTED_MASK 0 998c2ecf20Sopenharmony_ci#endif /* CONFIG_NF_CONNTRACK */ 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_NETFILTER_CONNCOUNT) 1028c2ecf20Sopenharmony_ciextern struct genl_family dp_ct_limit_genl_family; 1038c2ecf20Sopenharmony_ci#endif 1048c2ecf20Sopenharmony_ci#endif /* ovs_conntrack.h */ 105