From nobody Wed Dec 17 21:48:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493119874438524.2316927581317; Tue, 25 Apr 2017 04:31:14 -0700 (PDT) Received: from localhost ([::1]:48590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2ygb-00028K-0R for importer@patchew.org; Tue, 25 Apr 2017 07:31:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2ycI-0006nu-P2 for qemu-devel@nongnu.org; Tue, 25 Apr 2017 07:26:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2ycH-0002It-R8 for qemu-devel@nongnu.org; Tue, 25 Apr 2017 07:26:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d2ycH-0002IZ-Kh for qemu-devel@nongnu.org; Tue, 25 Apr 2017 07:26:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E7BB67EBB; Tue, 25 Apr 2017 11:26:44 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-8-52.pek2.redhat.com [10.72.8.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id D44C684DA2; Tue, 25 Apr 2017 11:26:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9E7BB67EBB Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9E7BB67EBB From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 25 Apr 2017 19:26:07 +0800 Message-Id: <1493119568-15218-8-git-send-email-jasowang@redhat.com> In-Reply-To: <1493119568-15218-1-git-send-email-jasowang@redhat.com> References: <1493119568-15218-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 25 Apr 2017 11:26:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL V2 7/8] COLO-compare: Optimize tcp compare for option field X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: 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 Signed-off-by: Jason Wang --- net/colo-compare.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 9b09cfc..4ab80b1 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -233,7 +233,32 @@ static int colo_packet_compare_tcp(Packet *spkt, Packe= t *ppkt) spkt->ip->ip_sum =3D ppkt->ip->ip_sum; } =20 - if (ptcp->th_sum =3D=3D 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=3D8 | 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) { + ptrdiff_t tcp_offset; + tcp_offset =3D ppkt->transport_header - (uint8_t *)ppkt->data + + (ptcp->th_off * 4); + res =3D colo_packet_compare_common(ppkt, spkt, tcp_offset); + } else if (ptcp->th_sum =3D=3D stcp->th_sum) { res =3D colo_packet_compare_common(ppkt, spkt, ETH_HLEN); } else { res =3D -1; --=20 2.7.4