conntrack.h 2.8 KB

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