conntrack.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. enum ovs_key_attr;
  18. #if IS_ENABLED(CONFIG_NF_CONNTRACK)
  19. void ovs_ct_init(struct net *);
  20. void ovs_ct_exit(struct net *);
  21. bool ovs_ct_verify(struct net *, enum ovs_key_attr attr);
  22. int ovs_ct_copy_action(struct net *, const struct nlattr *,
  23. const struct sw_flow_key *, struct sw_flow_actions **,
  24. bool log);
  25. int ovs_ct_action_to_attr(const struct ovs_conntrack_info *, struct sk_buff *);
  26. int ovs_ct_execute(struct net *, struct sk_buff *, struct sw_flow_key *,
  27. const struct ovs_conntrack_info *);
  28. void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key);
  29. int ovs_ct_put_key(const struct sw_flow_key *swkey,
  30. const struct sw_flow_key *output, struct sk_buff *skb);
  31. void ovs_ct_free_action(const struct nlattr *a);
  32. #define CT_SUPPORTED_MASK (OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | \
  33. OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | \
  34. OVS_CS_F_INVALID | OVS_CS_F_TRACKED | \
  35. OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
  36. #else
  37. #include <linux/errno.h>
  38. static inline void ovs_ct_init(struct net *net) { }
  39. static inline void ovs_ct_exit(struct net *net) { }
  40. static inline bool ovs_ct_verify(struct net *net, int attr)
  41. {
  42. return false;
  43. }
  44. static inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla,
  45. const struct sw_flow_key *key,
  46. struct sw_flow_actions **acts, bool log)
  47. {
  48. return -ENOTSUPP;
  49. }
  50. static inline int ovs_ct_action_to_attr(const struct ovs_conntrack_info *info,
  51. struct sk_buff *skb)
  52. {
  53. return -ENOTSUPP;
  54. }
  55. static inline int ovs_ct_execute(struct net *net, struct sk_buff *skb,
  56. struct sw_flow_key *key,
  57. const struct ovs_conntrack_info *info)
  58. {
  59. kfree_skb(skb);
  60. return -ENOTSUPP;
  61. }
  62. static inline void ovs_ct_fill_key(const struct sk_buff *skb,
  63. struct sw_flow_key *key)
  64. {
  65. key->ct_state = 0;
  66. key->ct_zone = 0;
  67. key->ct.mark = 0;
  68. memset(&key->ct.labels, 0, sizeof(key->ct.labels));
  69. /* Clear 'ct_orig_proto' to mark the non-existence of original
  70. * direction key fields.
  71. */
  72. key->ct_orig_proto = 0;
  73. }
  74. static inline int ovs_ct_put_key(const struct sw_flow_key *swkey,
  75. const struct sw_flow_key *output,
  76. struct sk_buff *skb)
  77. {
  78. return 0;
  79. }
  80. static inline void ovs_ct_free_action(const struct nlattr *a) { }
  81. #define CT_SUPPORTED_MASK 0
  82. #endif /* CONFIG_NF_CONNTRACK */
  83. #endif /* ovs_conntrack.h */