conntrack.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #else
  32. #include <linux/errno.h>
  33. static inline void ovs_ct_init(struct net *net) { }
  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. return -ENOTSUPP;
  55. }
  56. static inline void ovs_ct_fill_key(const struct sk_buff *skb,
  57. struct sw_flow_key *key)
  58. {
  59. key->ct.state = 0;
  60. key->ct.zone = 0;
  61. key->ct.mark = 0;
  62. memset(&key->ct.label, 0, sizeof(key->ct.label));
  63. }
  64. static inline int ovs_ct_put_key(const struct sw_flow_key *key,
  65. struct sk_buff *skb)
  66. {
  67. return 0;
  68. }
  69. static inline void ovs_ct_free_action(const struct nlattr *a) { }
  70. #endif /* CONFIG_NF_CONNTRACK */
  71. #endif /* ovs_conntrack.h */