Record packet creation time by QEMU_CLOCK_REALTIME instead of QEMU_CLOCK_HOST. The time difference between `now` and packet `creation_ms` has the possibility of an unexpected negative value and results in wrong comparison after changing the host clock.
Signed-off-by: Derek Su <dere...@qnap.com> --- net/colo-compare.c | 2 +- net/colo.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index c4de86ef34..29d7f986e3 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -621,7 +621,7 @@ static int colo_packet_compare_other(Packet *spkt, Packet *ppkt) static int colo_old_packet_check_one(Packet *pkt, void *user_data) { - int64_t now = qemu_clock_get_ms(QEMU_CLOCK_HOST); + int64_t now = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); uint32_t check_time = *(uint32_t *)user_data; if ((now - pkt->creation_ms) > check_time) { diff --git a/net/colo.c b/net/colo.c index a6c66d829a..0441910169 100644 --- a/net/colo.c +++ b/net/colo.c @@ -164,7 +164,7 @@ Packet *packet_new(const void *data, int size, int vnet_hdr_len) pkt->data = g_memdup(data, size); pkt->size = size; - pkt->creation_ms = qemu_clock_get_ms(QEMU_CLOCK_HOST); + pkt->creation_ms = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); pkt->vnet_hdr_len = vnet_hdr_len; pkt->tcp_seq = 0; pkt->tcp_ack = 0; -- 2.25.1