Linux Kernel iMX6
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.1 KiB

openvswitch: Add conntrack action Expose the kernel connection tracker via OVS. Userspace components can make use of the CT action to populate the connection state (ct_state) field for a flow. This state can be subsequently matched. Exposed connection states are OVS_CS_F_*: - NEW (0x01) - Beginning of a new connection. - ESTABLISHED (0x02) - Part of an existing connection. - RELATED (0x04) - Related to an established connection. - INVALID (0x20) - Could not track the connection for this packet. - REPLY_DIR (0x40) - This packet is in the reply direction for the flow. - TRACKED (0x80) - This packet has been sent through conntrack. When the CT action is executed by itself, it will send the packet through the connection tracker and populate the ct_state field with one or more of the connection state flags above. The CT action will always set the TRACKED bit. When the COMMIT flag is passed to the conntrack action, this specifies that information about the connection should be stored. This allows subsequent packets for the same (or related) connections to be correlated with this connection. Sending subsequent packets for the connection through conntrack allows the connection tracker to consider the packets as ESTABLISHED, RELATED, and/or REPLY_DIR. The CT action may optionally take a zone to track the flow within. This allows connections with the same 5-tuple to be kept logically separate from connections in other zones. If the zone is specified, then the "ct_zone" match field will be subsequently populated with the zone id. IP fragments are handled by transparently assembling them as part of the CT action. The maximum received unit (MRU) size is tracked so that refragmentation can occur during output. IP frag handling contributed by Andy Zhou. Based on original design by Justin Pettit. Signed-off-by: Joe Stringer <joestringer@nicira.com> Signed-off-by: Justin Pettit <jpettit@nicira.com> Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Thomas Graf <tgraf@suug.ch> Acked-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
5 years ago
  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 defined(CONFIG_OPENVSWITCH_CONNTRACK)
  19. bool ovs_ct_verify(enum ovs_key_attr attr);
  20. int ovs_ct_copy_action(struct net *, const struct nlattr *,
  21. const struct sw_flow_key *, struct sw_flow_actions **,
  22. bool log);
  23. int ovs_ct_action_to_attr(const struct ovs_conntrack_info *, struct sk_buff *);
  24. int ovs_ct_execute(struct net *, struct sk_buff *, struct sw_flow_key *,
  25. const struct ovs_conntrack_info *);
  26. void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key);
  27. int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb);
  28. void ovs_ct_free_action(const struct nlattr *a);
  29. #else
  30. #include <linux/errno.h>
  31. static inline bool ovs_ct_verify(int attr)
  32. {
  33. return false;
  34. }
  35. static inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla,
  36. const struct sw_flow_key *key,
  37. struct sw_flow_actions **acts, bool log)
  38. {
  39. return -ENOTSUPP;
  40. }
  41. static inline int ovs_ct_action_to_attr(const struct ovs_conntrack_info *info,
  42. struct sk_buff *skb)
  43. {
  44. return -ENOTSUPP;
  45. }
  46. static inline int ovs_ct_execute(struct net *net, struct sk_buff *skb,
  47. struct sw_flow_key *key,
  48. const struct ovs_conntrack_info *info)
  49. {
  50. return -ENOTSUPP;
  51. }
  52. static inline void ovs_ct_fill_key(const struct sk_buff *skb,
  53. struct sw_flow_key *key)
  54. {
  55. key->ct.state = 0;
  56. key->ct.zone = 0;
  57. }
  58. static inline int ovs_ct_put_key(const struct sw_flow_key *key,
  59. struct sk_buff *skb)
  60. {
  61. return 0;
  62. }
  63. static inline void ovs_ct_free_action(const struct nlattr *a) { }
  64. #endif
  65. #endif /* ovs_conntrack.h */