COLO-compare: Optimize tcp compare performance and trace format.
cover COLO-compare: Optimize tcp compare performance and trace format.
In the first patch, we add tcp options support to optimize compare performance. and another patch simplified code and adjust trace print format.
Zhang Chen (2):
COLO-compare: Optimize tcp compare for option field
COLO-compare: Optimize tcp compare trace event
net/colo-compare.c | 54 ++++++++++++++++++++++++++++++++++++++++++------------ net/trace-events | 3 +-- 2 files changed, 43 insertions(+), 14 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/2 COLO-compare: Optimize tcp compare for option field
In this patch we support packet that have tcp options field. Add tcp options field check, If the packet have options field we just skip it and compare tcp payload, Avoid unnecessary checkpoint, optimize performance.
--- net/colo-compare.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
net/colo-compare.c +26 -1
@@ -228,6 +228,7 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) {struct tcphdr *ptcp, *stcp;int res; +int tcp_offset =0 ;trace_colo_compare_main ("compare tcp" );
@@ -248,7 +249,31 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) spkt->ip->ip_sum = ppkt->ip->ip_sum; } -if (ptcp->th_sum == stcp->th_sum) { +/* +* Check tcp header length for tcp option field. +* th_off > 5 means this tcp packet have options field. +* The tcp options maybe always different. +* for example: +* From RFC 7323. +* TCP Timestamps option (TSopt): +* Kind: 8 +* +* Length: 10 bytes +* +* +-------+-------+---------------------+---------------------+ +* |Kind=8 | 10 | TS Value (TSval) |TS Echo Reply (TSecr)| +* +-------+-------+---------------------+---------------------+ +* 1 1 4 4 +* +* In this case the primary guest's timestamp always different with +* the secondary guest's timestamp. COLO just focus on payload, +* so we just need skip this field. +*/ +if (ptcp->th_off >5 ) { + tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data + + (ptcp->th_off *4 ); + 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 ); }else { res =-1 ;
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 1/2] COLO-compare: Optimize tcp compare for option field
Hi Zhang,
Quoted 15 lines · Zhang Chen
In this patch we support packet that have tcp options field. Add tcp options field check, If the packet have options field we just skip it and compare tcp payload, Avoid unnecessary checkpoint, optimize performance.
Signed-off-by Zhang Chen <[email protected]>--- net/colo-compare.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)net/colo-compare.c +0
-0
net/colo-compare.c static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) · line 231
Quoted 4 lines
net/colo-compare.c +1
-0@@ -228,6 +228,7 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) {struct tcphdr *ptcp, *stcp;int res; +int tcp_offset =0 ;
No need to declare here, it can be restricted to the if {} body.
Quoted 19 lines
net/colo-compare.c +11
-1trace_colo_compare_main ("compare tcp" );@@ -248,7 +249,31 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) spkt->ip->ip_sum = ppkt->ip->ip_sum; } -if (ptcp->th_sum == stcp->th_sum) { +/* +* Check tcp header length for tcp option field. +* th_off > 5 means this tcp packet have options field. +* The tcp options maybe always different. +* for example: +* From RFC 7323. +* TCP Timestamps option (TSopt): +* Kind: 8 +* +* Length: 10 bytes +*
net/colo-compare.c static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) · line 272
Quoted 10 lines
net/colo-compare.c +10
-0+* +-------+-------+---------------------+---------------------+ +* |Kind=8 | 10 | TS Value (TSval) |TS Echo Reply (TSecr)| +* +-------+-------+---------------------+---------------------+ +* 1 1 4 4 +* +* In this case the primary guest's timestamp always different with +* the secondary guest's timestamp. COLO just focus on payload, +* so we just need skip this field. +*/ +if (ptcp->th_off >5 ) {
You can declare here.
I'd rather declare tcp_offset as a ptrdiff_t.
Quoted 8 lines
net/colo-compare.c +4
-0+ tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data + + (ptcp->th_off *4 ); + 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 ); }else { res =-1 ;
Re: [Qemu-devel] [PATCH 1/2] COLO-compare: Optimize tcp compare for option field
Quoted 13 lines · Philippe Mathieu-Daudé
Hi Zhang,
Quoted 10 lines · Zhang Chen
In this patch we support packet that have tcp options field. Add tcp options field check, If the packet have options field we just skip it and compare tcp payload, Avoid unnecessary checkpoint, optimize performance.
Signed-off-by Zhang Chen <[email protected]>--- net/colo-compare.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
Quoted 12 lines
net/colo-compare.c static int colo_packet_compare_tcp(Packet *spkt, · line 232
Quoted 10 lines
net/colo-compare.c +1
-0@@ -228,6 +228,7 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) {struct tcphdr *ptcp, *stcp;int res; +int tcp_offset =0 ;No need to declare here, it can be restricted to the if {} body.
OK~
Quoted 34 lines
Quoted 21 lines
net/colo-compare.c +11
-1trace_colo_compare_main ("compare tcp" );@@ -248,7 +249,31 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) spkt->ip->ip_sum = ppkt->ip->ip_sum; } -if (ptcp->th_sum == stcp->th_sum) { +/* +* Check tcp header length for tcp option field. +* th_off > 5 means this tcp packet have options field. +* The tcp options maybe always different. +* for example: +* From RFC 7323. +* TCP Timestamps option (TSopt): +* Kind: 8 +* +* Length: 10 bytes +* net/colo-compare.c static int colo_packet_compare_tcp(Packet *spkt, · line 273
Quoted 10 lines
net/colo-compare.c +10
-0+* +-------+-------+---------------------+---------------------+ +* |Kind=8 | 10 | TS Value (TSval) |TS Echo Reply (TSecr)| +* +-------+-------+---------------------+---------------------+ +* 1 1 4 4 +* +* In this case the primary guest's timestamp always different with +* the secondary guest's timestamp. COLO just focus on payload, +* so we just need skip this field. +*/ +if (ptcp->th_off >5 ) {You can declare here.
Quoted 1 line
I'd rather declare
tcp_offsetas aptrdiff_t.
I got your point, will fix it in next version.
Thanks
Zhang Chen
Quoted 13 lines
Quoted 9 lines
net/colo-compare.c +4
-0+ tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data + + (ptcp->th_off *4 ); + 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 ); }else {res = -1;.
Signature · 2 lines
Thanks Zhang Chen
PATCH 2/2 COLO-compare: Optimize tcp compare trace event
In reply to Zhang ChenOptimize two trace events as one, adjust print format make it easy to read. rename trace_colo_compare_pkt_info_src/dst to trace_colo_compare_tcp_info.
--- net/colo-compare.c | 29 +++++++++++++++++------------ net/trace-events | 3 +-- 2 files changed, 18 insertions(+), 14 deletions(-)
net/colo-compare.c +17 -12
@@ -279,18 +279,23 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) res =-1 ; } -if (res !=0 &&trace_event_get_state (TRACE_COLO_COMPARE_MISCOMPARE )) { -trace_colo_compare_pkt_info_src (inet_ntoa (ppkt->ip->ip_src), -ntohl (stcp->th_seq), -ntohl (stcp->th_ack), - res, stcp->th_flags, - spkt->size); - -trace_colo_compare_pkt_info_dst (inet_ntoa (ppkt->ip->ip_dst), -ntohl (ptcp->th_seq), -ntohl (ptcp->th_ack), - res, ptcp->th_flags, - ppkt->size); +if (res &&trace_event_get_state (TRACE_COLO_COMPARE_MISCOMPARE )) { +char ip_src[20 ], ip_dst[20 ]; + +strcpy (ip_src,inet_ntoa (ppkt->ip->ip_src)); +strcpy (ip_dst,inet_ntoa (ppkt->ip->ip_dst)); + +trace_colo_compare_tcp_info (ip_src, + ip_dst, +ntohl (ptcp->th_seq), +ntohl (stcp->th_seq), +ntohl (ptcp->th_ack), +ntohl (stcp->th_ack), + res, + ptcp->th_flags, + stcp->th_flags, + ppkt->size, + spkt->size);qemu_hexdump ((char *)ppkt->data, stderr,"colo-compare ppkt" , ppkt->size);
net/trace-events +1 -2
@@ -13,8 +13,7 @@ colo_compare_icmp_miscompare(const char *sta, int size) ": %s = %d" colo_compare_ip_info(int psize, const char *sta, const char *stb, int ssize, const char *stc, const char *std) "ppkt size = %d, ip_src = %s, ip_dst = %s, spkt size = %d, ip_src = %s, ip_dst = %s" colo_old_packet_check_found(int64_t old_time) "%" PRId64 colo_compare_miscompare(void) "" -colo_compare_pkt_info_src(const char *src, uint32_t sseq, uint32_t sack, int res, uint32_t sflag, int ssize) "src/dst: %s s: seq/ack=%u/%u res=%d flags=%x spkt_size: %d\n" -colo_compare_pkt_info_dst(const char *dst, uint32_t dseq, uint32_t dack, int res, uint32_t dflag, int dsize) "src/dst: %s d: seq/ack=%u/%u res=%d flags=%x dpkt_size: %d\n" +colo_compare_tcp_info(const char *src, const char *dst, uint32_t pseq, uint32_t sseq, uint32_t pack, uint32_t sack, int res, uint32_t pflag, uint32_t sflag, int psize, int ssize) "src/dst: %s/%s pseq/sseq:%u/%u pack/sack:%u/%u res=%d pflags/sflag:%x/%x psize/ssize:%d/%d \n" # net/filter-rewriter.c colo_filter_rewriter_debug(void) ""
Signature · 1 line
2.7.4