conntrack.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) 2015 Nicira, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of version 2 of the GNU General Public
  6. * License as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. */
  13. #ifndef OVS_CONNTRACK_H
  14. #define OVS_CONNTRACK_H 1
  15. #include "flow.h"
  16. struct ovs_conntrack_info;
  17. struct ovs_ct_limit_info;
  18. enum ovs_key_attr;
  19. #if IS_ENABLED(CONFIG_NF_CONNTRACK)
  20. int ovs_ct_init(struct net *);
  21. void ovs_ct_exit(struct net *);
  22. bool ovs_ct_verify(struct net *, enum ovs_key_attr attr);
  23. int ovs_ct_copy_action(struct net *, const struct nlattr *,
  24. const struct sw_flow_key *, struct sw_flow_actions **,
  25. bool log);
  26. int ovs_ct_action_to_attr(const struct ovs_conntrack_info *, struct sk_buff *);
  27. int ovs_ct_execute(struct net *, struct sk_buff *, struct sw_flow_key *,
  28. const struct ovs_conntrack_info *);
  29. int ovs_ct_clear(struct sk_buff *skb, struct sw_flow_key *key);
  30. void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key);
  31. int ovs_ct_put_key(const struct sw_flow_key *swkey,
  32. const struct sw_flow_key *output, struct sk_buff *skb);
  33. void ovs_ct_free_action(const struct nlattr *a);
  34. #define CT_SUPPORTED_MASK (OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | \
  35. OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | \
  36. OVS_CS_F_INVALID | OVS_CS_F_TRACKED | \
  37. OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
  38. #else
  39. #include <linux/errno.h>
  40. static inline int ovs_ct_init(struct net *net) { return 0; }
  41. static inline void ovs_ct_exit(struct net *net) { }
  42. static inline bool ovs_ct_verify(struct net *net, int attr)
  43. {
  44. return false;
  45. }
  46. static inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla,
  47. const struct sw_flow_key *key,
  48. struct sw_flow_actions **acts, bool log)
  49. {
  50. return -ENOTSUPP;
  51. }
  52. static inline int ovs_ct_action_to_attr(const struct ovs_conntrack_info *info,
  53. struct sk_buff *skb)
  54. {
  55. return -ENOTSUPP;
  56. }
  57. static inline int ovs_ct_execute(struct net *net, struct sk_buff *skb,
  58. struct sw_flow_key *key,
  59. const struct ovs_conntrack_info *info)
  60. {
  61. kfree_skb(skb);
  62. return -ENOTSUPP;
  63. }
  64. static inline int ovs_ct_clear(struct sk_buff *skb,
  65. struct sw_flow_key *key)
  66. {
  67. return -ENOTSUPP;
  68. }
  69. static inline void ovs_ct_fill_key(const struct sk_buff *skb,
  70. struct sw_flow_key *key)
  71. {
  72. key->ct_state = 0;
  73. key->ct_zone = 0;
  74. key->ct.mark = 0;
  75. memset(&key->ct.labels, 0, sizeof(key->ct.labels));
  76. /* Clear 'ct_orig_proto' to mark the non-existence of original
  77. * direction key fields.
  78. */
  79. key->ct_orig_proto = 0;
  80. }
  81. static inline int ovs_ct_put_key(const struct sw_flow_key *swkey,
  82. const struct sw_flow_key *output,
  83. struct sk_buff *skb)
  84. {
  85. return 0;
  86. }
  87. static inline void ovs_ct_free_action(const struct nlattr *a) { }
  88. #define CT_SUPPORTED_MASK 0
  89. #endif /* CONFIG_NF_CONNTRACK */
  90. #if IS_ENABLED(CONFIG_NETFILTER_CONNCOUNT)
  91. extern struct genl_family dp_ct_limit_genl_family;
  92. #endif
  93. #endif /* ovs_conntrack.h */