^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2015 Nicira, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef OVS_CONNTRACK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define OVS_CONNTRACK_H 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "flow.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct ovs_conntrack_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct ovs_ct_limit_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) enum ovs_key_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #if IS_ENABLED(CONFIG_NF_CONNTRACK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) int ovs_ct_init(struct net *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) void ovs_ct_exit(struct net *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) bool ovs_ct_verify(struct net *, enum ovs_key_attr attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) int ovs_ct_copy_action(struct net *, const struct nlattr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) const struct sw_flow_key *, struct sw_flow_actions **,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) bool log);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) int ovs_ct_action_to_attr(const struct ovs_conntrack_info *, struct sk_buff *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) int ovs_ct_execute(struct net *, struct sk_buff *, struct sw_flow_key *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) const struct ovs_conntrack_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) int ovs_ct_clear(struct sk_buff *skb, struct sw_flow_key *key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int ovs_ct_put_key(const struct sw_flow_key *swkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) const struct sw_flow_key *output, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) void ovs_ct_free_action(const struct nlattr *a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define CT_SUPPORTED_MASK (OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) OVS_CS_F_INVALID | OVS_CS_F_TRACKED | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static inline int ovs_ct_init(struct net *net) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static inline void ovs_ct_exit(struct net *net) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static inline bool ovs_ct_verify(struct net *net, int attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) const struct sw_flow_key *key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct sw_flow_actions **acts, bool log)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static inline int ovs_ct_action_to_attr(const struct ovs_conntrack_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static inline int ovs_ct_execute(struct net *net, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct sw_flow_key *key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) const struct ovs_conntrack_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static inline int ovs_ct_clear(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct sw_flow_key *key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static inline void ovs_ct_fill_key(const struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct sw_flow_key *key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) key->ct_state = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) key->ct_zone = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) key->ct.mark = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) memset(&key->ct.labels, 0, sizeof(key->ct.labels));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* Clear 'ct_orig_proto' to mark the non-existence of original
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * direction key fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) key->ct_orig_proto = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) static inline int ovs_ct_put_key(const struct sw_flow_key *swkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) const struct sw_flow_key *output,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) static inline void ovs_ct_free_action(const struct nlattr *a) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define CT_SUPPORTED_MASK 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #endif /* CONFIG_NF_CONNTRACK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #if IS_ENABLED(CONFIG_NETFILTER_CONNCOUNT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) extern struct genl_family dp_ct_limit_genl_family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #endif /* ovs_conntrack.h */