|
From: | Zhang Chen |
Subject: | Re: [Qemu-devel] [PATCH V4 10/12] net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare |
Date: | Mon, 15 May 2017 16:04:35 +0800 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
On 05/15/2017 12:11 PM, Jason Wang wrote:
On 2017年05月12日 09:41, Zhang Chen wrote:COLO-Proxy just focus on packet payload, So we skip vnet header. Signed-off-by: Zhang Chen <address@hidden> --- net/colo-compare.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index cb0b04e..bf565f3 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -188,6 +188,8 @@ static int packet_enqueue(CompareState *s, int mode) */static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset){ + int offset_all; + if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20]; @@ -201,9 +203,12 @@ static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)sec_ip_src, sec_ip_dst); } + offset_all = ppkt->vnet_hdr_len + offset;How about just keep using offset by increasing it with vnet_hdr_len?
OK, I will fix it in next version. Thanks Zhang Chen
Thanks+ if (ppkt->size == spkt->size) { - return memcmp(ppkt->data + offset, spkt->data + offset, - spkt->size - offset); + return memcmp(ppkt->data + offset_all, + spkt->data + offset_all, + spkt->size - offset_all); } else { trace_colo_compare_main("Net packet size are not the same"); return -1;@@ -261,8 +266,9 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)*/ if (ptcp->th_off > 5) { ptrdiff_t tcp_offset; + tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data - + (ptcp->th_off * 4); + + (ptcp->th_off * 4) - ppkt->vnet_hdr_len; res = colo_packet_compare_common(ppkt, spkt, tcp_offset); } else if (ptcp->th_sum == stcp->th_sum) { res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN);.
-- Thanks Zhang Chen
[Prev in Thread] | Current Thread | [Next in Thread] |