conntrack.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 *key, struct sk_buff *skb);
  30. void ovs_ct_free_action(const struct nlattr *a);
  31. #define CT_SUPPORTED_MASK (OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | \
  32. OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | \
  33. OVS_CS_F_INVALID | OVS_CS_F_TRACKED)
  34. #else
  35. #include <linux/errno.h>
  36. static inline void ovs_ct_init(struct net *net) { }
  37. static inline void ovs_ct_exit(struct net *net) { }
  38. static inline bool ovs_ct_verify(struct net *net, int attr)
  39. {
  40. return false;
  41. }
  42. static inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla,
  43. const struct sw_flow_key *key,
  44. struct sw_flow_actions **acts, bool log)
  45. {
  46. return -ENOTSUPP;
  47. }
  48. static inline int ovs_ct_action_to_attr(const struct ovs_conntrack_info *info,
  49. struct sk_buff *skb)
  50. {
  51. return -ENOTSUPP;
  52. }
  53. static inline int ovs_ct_execute(struct net *net, struct sk_buff *skb,
  54. struct sw_flow_key *key,
  55. const struct ovs_conntrack_info *info)
  56. {
  57. kfree_skb(skb);
  58. return -ENOTSUPP;
  59. }
  60. static inline void ovs_ct_fill_key(const struct sk_buff *skb,
  61. struct sw_flow_key *key)
  62. {
  63. key->ct.state = 0;
  64. key->ct.zone = 0;
  65. key->ct.mark = 0;
  66. memset(&key->ct.labels, 0, sizeof(key->ct.labels));
  67. }
  68. static inline int ovs_ct_put_key(const struct sw_flow_key *key,
  69. struct sk_buff *skb)
  70. {
  71. return 0;
  72. }
  73. static inline void ovs_ct_free_action(const struct nlattr *a) { }
  74. #define CT_SUPPORTED_MASK 0
  75. #endif /* CONFIG_NF_CONNTRACK */
  76. #endif /* ovs_conntrack.h */