conntrack.h 2.6 KB

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