2
0

colo.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * COarse-grain LOck-stepping Virtual Machines for Non-stop Service (COLO)
  3. * (a.k.a. Fault Tolerance or Continuous Replication)
  4. *
  5. * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
  6. * Copyright (c) 2016 FUJITSU LIMITED
  7. * Copyright (c) 2016 Intel Corporation
  8. *
  9. * Author: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
  10. *
  11. * This work is licensed under the terms of the GNU GPL, version 2 or
  12. * later. See the COPYING file in the top-level directory.
  13. */
  14. #ifndef QEMU_COLO_PROXY_H
  15. #define QEMU_COLO_PROXY_H
  16. #include "slirp/slirp.h"
  17. #include "qemu/jhash.h"
  18. #include "qemu/timer.h"
  19. #define HASHTABLE_MAX_SIZE 16384
  20. #ifndef IPPROTO_DCCP
  21. #define IPPROTO_DCCP 33
  22. #endif
  23. #ifndef IPPROTO_SCTP
  24. #define IPPROTO_SCTP 132
  25. #endif
  26. #ifndef IPPROTO_UDPLITE
  27. #define IPPROTO_UDPLITE 136
  28. #endif
  29. typedef struct Packet {
  30. void *data;
  31. union {
  32. uint8_t *network_header;
  33. struct ip *ip;
  34. };
  35. uint8_t *transport_header;
  36. int size;
  37. /* Time of packet creation, in wall clock ms */
  38. int64_t creation_ms;
  39. } Packet;
  40. typedef struct ConnectionKey {
  41. /* (src, dst) must be grouped, in the same way than in IP header */
  42. struct in_addr src;
  43. struct in_addr dst;
  44. uint16_t src_port;
  45. uint16_t dst_port;
  46. uint8_t ip_proto;
  47. } QEMU_PACKED ConnectionKey;
  48. typedef struct Connection {
  49. /* connection primary send queue: element type: Packet */
  50. GQueue primary_list;
  51. /* connection secondary send queue: element type: Packet */
  52. GQueue secondary_list;
  53. /* flag to enqueue unprocessed_connections */
  54. bool processing;
  55. uint8_t ip_proto;
  56. /* offset = secondary_seq - primary_seq */
  57. tcp_seq offset;
  58. /*
  59. * we use this flag update offset func
  60. * run once in independent tcp connection
  61. */
  62. int syn_flag;
  63. } Connection;
  64. uint32_t connection_key_hash(const void *opaque);
  65. int connection_key_equal(const void *opaque1, const void *opaque2);
  66. int parse_packet_early(Packet *pkt);
  67. void fill_connection_key(Packet *pkt, ConnectionKey *key);
  68. void reverse_connection_key(ConnectionKey *key);
  69. Connection *connection_new(ConnectionKey *key);
  70. void connection_destroy(void *opaque);
  71. Connection *connection_get(GHashTable *connection_track_table,
  72. ConnectionKey *key,
  73. GQueue *conn_list);
  74. void connection_hashtable_reset(GHashTable *connection_track_table);
  75. Packet *packet_new(const void *data, int size);
  76. void packet_destroy(void *opaque, void *user_data);
  77. #endif /* QEMU_COLO_PROXY_H */