2 * COarse-grain LOck-stepping Virtual Machines for Non-stop Service (COLO)
3 * (a.k.a. Fault Tolerance or Continuous Replication)
5 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
6 * Copyright (c) 2016 FUJITSU LIMITED
7 * Copyright (c) 2016 Intel Corporation
9 * Author: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
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.
18 #include "qemu/jhash.h"
19 #include "qemu/timer.h"
22 #define HASHTABLE_MAX_SIZE 16384
25 #define IPPROTO_DCCP 33
29 #define IPPROTO_SCTP 132
32 #ifndef IPPROTO_UDPLITE
33 #define IPPROTO_UDPLITE 136
36 typedef struct Packet
{
39 uint8_t *network_header
;
42 uint8_t *transport_header
;
44 /* Time of packet creation, in wall clock ms */
46 /* Get vnet_hdr_len from filter */
47 uint32_t vnet_hdr_len
;
48 uint32_t tcp_seq
; /* sequence number */
49 uint32_t tcp_ack
; /* acknowledgement number */
50 /* the sequence number of the last byte of the packet */
52 uint8_t header_size
; /* the header length */
53 uint16_t payload_size
; /* the payload length */
54 /* record the payload offset(the length that has been compared) */
56 uint8_t flags
; /* Flags(aka Control bits) */
59 typedef struct ConnectionKey
{
60 /* (src, dst) must be grouped, in the same way than in IP header */
66 } QEMU_PACKED ConnectionKey
;
68 typedef struct Connection
{
69 /* connection primary send queue: element type: Packet */
71 /* connection secondary send queue: element type: Packet */
72 GQueue secondary_list
;
73 /* flag to enqueue unprocessed_connections */
76 /* record the sequence number that has been compared */
78 /* the maximum of acknowledgement number in primary_list queue */
80 /* the maximum of acknowledgement number in secondary_list queue */
82 /* offset = secondary_seq - primary_seq */
85 int tcp_state
; /* TCP FSM state */
86 uint32_t fin_ack_seq
; /* the seq of 'fin=1,ack=1' */
89 uint32_t connection_key_hash(const void *opaque
);
90 int connection_key_equal(const void *opaque1
, const void *opaque2
);
91 int parse_packet_early(Packet
*pkt
);
92 void extract_ip_and_port(uint32_t tmp_ports
, ConnectionKey
*key
, Packet
*pkt
);
93 void fill_connection_key(Packet
*pkt
, ConnectionKey
*key
);
94 void reverse_connection_key(ConnectionKey
*key
);
95 Connection
*connection_new(ConnectionKey
*key
);
96 void connection_destroy(void *opaque
);
97 Connection
*connection_get(GHashTable
*connection_track_table
,
100 bool connection_has_tracked(GHashTable
*connection_track_table
,
102 void connection_hashtable_reset(GHashTable
*connection_track_table
);
103 Packet
*packet_new(const void *data
, int size
, int vnet_hdr_len
);
104 Packet
*packet_new_nocopy(void *data
, int size
, int vnet_hdr_len
);
105 void packet_destroy(void *opaque
, void *user_data
);
106 void packet_destroy_partial(void *opaque
, void *user_data
);
108 #endif /* NET_COLO_H */