From nobody Sun May 5 01:59:29 2024 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.zohomail.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 1507876674513910.1617774866645; Thu, 12 Oct 2017 23:37:54 -0700 (PDT) Received: from localhost ([::1]:48620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2tbI-0000Yw-Qa for importer@patchew.org; Fri, 13 Oct 2017 02:37:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2tZf-00080j-3V for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:36:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2tZc-0004v4-8z for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:35:59 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:54764 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2tZb-0004sa-Ke for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:35:56 -0400 Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 13 Oct 2017 14:35:45 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 3EAFD47F13B0; Fri, 13 Oct 2017 14:35:45 +0800 (CST) Received: from localhost.localdomain (10.167.226.123) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 13 Oct 2017 14:35:45 +0800 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="29028899" From: Mao Zhongyi To: Date: Fri, 13 Oct 2017 14:32:06 +0800 Message-ID: <20171013063209.15617-2-maozy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171013063209.15617-1-maozy.fnst@cn.fujitsu.com> References: <20171013063209.15617-1-maozy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.123] X-yoursite-MailScanner-ID: 3EAFD47F13B0.A2ED0 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: maozy.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 183.91.158.132 Subject: [Qemu-devel] [PATCH 1/4] colo-compare: Insert packet into the suitable position of packet queue directly 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 , Li Zhijian , 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 Content-Type: text/plain; charset="utf-8" Currently, a packet from pri_dev or sec_dev is fristly pushed at the tail of the primary or secondary packet queue then sorted by the tcp sequence number. Now, this patch use g_queue_insert_sorted to insert the packet directly into the suitable position to avoid ordering all packets each time when a new packet is comming, thereby increasing efficiency. In addition, consolidate the code that add a packet to the list of Connection (primary or secondary) into a separate routine colo_insert_packe= t() since the same chunk of code is called from two place. Cc: Zhang Chen Cc: Li Zhijian Cc: Jason Wang Signed-off-by: Mao Zhongyi Signed-off-by: Zhang Chen --- net/colo-compare.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index b3f35d7..54b6347 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -113,6 +113,26 @@ static gint seq_sorter(Packet *a, Packet *b, gpointer = data) } =20 /* + * Return 1 on success, if return 0 means the + * packet will be dropped + */ +static int colo_insert_packet(GQueue *queue, Packet *pkt) +{ + if (g_queue_get_length(queue) <=3D MAX_QUEUE_SIZE) { + if (pkt->ip->ip_p =3D=3D IPPROTO_TCP) { + g_queue_insert_sorted(queue, + pkt, + (GCompareDataFunc)seq_sorter, + NULL); + } else { + g_queue_push_tail(queue, pkt); + } + return 1; + } + return 0; +} + +/* * Return 0 on success, if return -1 means the pkt * is unsupported(arp and ipv6) and will be sent later */ @@ -149,28 +169,12 @@ static int packet_enqueue(CompareState *s, int mode) } =20 if (mode =3D=3D PRIMARY_IN) { - if (g_queue_get_length(&conn->primary_list) <=3D - MAX_QUEUE_SIZE) { - g_queue_push_tail(&conn->primary_list, pkt); - if (conn->ip_proto =3D=3D IPPROTO_TCP) { - g_queue_sort(&conn->primary_list, - (GCompareDataFunc)seq_sorter, - NULL); - } - } else { + if (!colo_insert_packet(&conn->primary_list, pkt)) { error_report("colo compare primary queue size too big," "drop packet"); } } else { - if (g_queue_get_length(&conn->secondary_list) <=3D - MAX_QUEUE_SIZE) { - g_queue_push_tail(&conn->secondary_list, pkt); - if (conn->ip_proto =3D=3D IPPROTO_TCP) { - g_queue_sort(&conn->secondary_list, - (GCompareDataFunc)seq_sorter, - NULL); - } - } else { + if (!colo_insert_packet(&conn->secondary_list, pkt)) { error_report("colo compare secondary queue size too big," "drop packet"); } --=20 2.9.4 From nobody Sun May 5 01:59:29 2024 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.zohomail.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 1507876673508243.17565183806835; Thu, 12 Oct 2017 23:37:53 -0700 (PDT) Received: from localhost ([::1]:48621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2tbO-0000gN-2q for importer@patchew.org; Fri, 13 Oct 2017 02:37:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2tZf-00080i-2b for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:36:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2tZc-0004vi-W1 for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:35:59 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:34094 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2tZc-0004qA-KZ for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:35:56 -0400 Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 13 Oct 2017 14:35:45 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id E5C5D47F13B1; Fri, 13 Oct 2017 14:35:45 +0800 (CST) Received: from localhost.localdomain (10.167.226.123) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 13 Oct 2017 14:35:45 +0800 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="29028900" From: Mao Zhongyi To: Date: Fri, 13 Oct 2017 14:32:07 +0800 Message-ID: <20171013063209.15617-3-maozy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171013063209.15617-1-maozy.fnst@cn.fujitsu.com> References: <20171013063209.15617-1-maozy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.123] X-yoursite-MailScanner-ID: E5C5D47F13B1.A27CA X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: maozy.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 183.91.158.132 Subject: [Qemu-devel] [PATCH 2/4] colo-compare: compare the packet in a specified Connection 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 , Li Zhijian , 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 Content-Type: text/plain; charset="utf-8" A package from pri_indev or sec_indev only belongs to a particular Connection, so we only need to compare the package in the specified Connection's primary_list and secondary_list, rather than for each the whole Connection list to compare. This is time-consuming and unnecessary. Less checkpoint more efficiency. Cc: Zhang Chen Cc: Li Zhijian Cc: Jason Wang Signed-off-by: Mao Zhongyi --- net/colo-compare.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 54b6347..5d2429b 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -136,7 +136,7 @@ static int colo_insert_packet(GQueue *queue, Packet *pk= t) * Return 0 on success, if return -1 means the pkt * is unsupported(arp and ipv6) and will be sent later */ -static int packet_enqueue(CompareState *s, int mode) +static int packet_enqueue(CompareState *s, int mode, Connection **con) { ConnectionKey key; Packet *pkt =3D NULL; @@ -179,6 +179,7 @@ static int packet_enqueue(CompareState *s, int mode) "drop packet"); } } + con =3D &conn; =20 return 0; } @@ -728,8 +729,9 @@ static void compare_set_vnet_hdr(Object *obj, static void compare_pri_rs_finalize(SocketReadState *pri_rs) { CompareState *s =3D container_of(pri_rs, CompareState, pri_rs); + Connection *conn =3D NULL; =20 - if (packet_enqueue(s, PRIMARY_IN)) { + if (packet_enqueue(s, PRIMARY_IN, &conn)) { trace_colo_compare_main("primary: unsupported packet in"); compare_chr_send(s, pri_rs->buf, @@ -737,19 +739,20 @@ static void compare_pri_rs_finalize(SocketReadState *= pri_rs) pri_rs->vnet_hdr_len); } else { /* compare connection */ - g_queue_foreach(&s->conn_list, colo_compare_connection, s); + colo_compare_connection(conn, s); } } =20 static void compare_sec_rs_finalize(SocketReadState *sec_rs) { CompareState *s =3D container_of(sec_rs, CompareState, sec_rs); + Connection *conn =3D NULL; =20 - if (packet_enqueue(s, SECONDARY_IN)) { + if (packet_enqueue(s, SECONDARY_IN, &conn)) { trace_colo_compare_main("secondary: unsupported packet in"); } else { /* compare connection */ - g_queue_foreach(&s->conn_list, colo_compare_connection, s); + colo_compare_connection(conn, s); } } =20 --=20 2.9.4 From nobody Sun May 5 01:59:29 2024 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.zohomail.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 1507876776521751.5041753271626; Thu, 12 Oct 2017 23:39:36 -0700 (PDT) Received: from localhost ([::1]:48624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2td5-0001zU-HR for importer@patchew.org; Fri, 13 Oct 2017 02:39:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2tZf-00080l-4M for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:36:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2tZd-0004vy-7z for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:35:59 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:54764 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2tZc-0004sa-TO for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:35:57 -0400 Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 13 Oct 2017 14:35:45 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 9C67847F13C1; Fri, 13 Oct 2017 14:35:46 +0800 (CST) Received: from localhost.localdomain (10.167.226.123) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 13 Oct 2017 14:35:46 +0800 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="29028903" From: Mao Zhongyi To: Date: Fri, 13 Oct 2017 14:32:08 +0800 Message-ID: <20171013063209.15617-4-maozy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171013063209.15617-1-maozy.fnst@cn.fujitsu.com> References: <20171013063209.15617-1-maozy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.123] X-yoursite-MailScanner-ID: 9C67847F13C1.A0CB4 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: maozy.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 183.91.158.132 Subject: [Qemu-devel] [PATCH 3/4] colo-compare: Fix comments 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 , Li Zhijian , 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 Content-Type: text/plain; charset="utf-8" Cc: Zhang Chen Cc: Li Zhijian Cc: Jason Wang Signed-off-by: Mao Zhongyi Signed-off-by: Zhang Chen --- net/colo-compare.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 5d2429b..ccdcba2 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -480,7 +480,9 @@ static void colo_old_packet_check(void *opaque) =20 /* * Called from the compare thread on the primary - * for compare connection + * for compare packet with secondary list of the + * specified connection when a new packet was + * queued to it. */ static void colo_compare_connection(void *opaque, void *user_data) { @@ -738,7 +740,7 @@ static void compare_pri_rs_finalize(SocketReadState *pr= i_rs) pri_rs->packet_len, pri_rs->vnet_hdr_len); } else { - /* compare connection */ + /* compare packet in the specified connection */ colo_compare_connection(conn, s); } } @@ -751,7 +753,7 @@ static void compare_sec_rs_finalize(SocketReadState *se= c_rs) if (packet_enqueue(s, SECONDARY_IN, &conn)) { trace_colo_compare_main("secondary: unsupported packet in"); } else { - /* compare connection */ + /* compare packet in the specified connection */ colo_compare_connection(conn, s); } } --=20 2.9.4 From nobody Sun May 5 01:59:29 2024 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.zohomail.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 1507876677982507.17960743545257; Thu, 12 Oct 2017 23:37:57 -0700 (PDT) Received: from localhost ([::1]:48619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2tbH-0000Yk-MV for importer@patchew.org; Fri, 13 Oct 2017 02:37:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2tZf-00080m-5B for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:36:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2tZd-0004wL-Ly for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:35:59 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:47186 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2tZd-0004vF-BI for qemu-devel@nongnu.org; Fri, 13 Oct 2017 02:35:57 -0400 Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 13 Oct 2017 14:35:52 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 3B63647F13AF; Fri, 13 Oct 2017 14:35:47 +0800 (CST) Received: from localhost.localdomain (10.167.226.123) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 13 Oct 2017 14:35:47 +0800 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="29028911" From: Mao Zhongyi To: Date: Fri, 13 Oct 2017 14:32:09 +0800 Message-ID: <20171013063209.15617-5-maozy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171013063209.15617-1-maozy.fnst@cn.fujitsu.com> References: <20171013063209.15617-1-maozy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.123] X-yoursite-MailScanner-ID: 3B63647F13AF.A1E73 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: maozy.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 183.91.158.132 Subject: [Qemu-devel] [PATCH 4/4] colo: Consolidate the duplicate code chunk into a routine 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 , Li Zhijian , 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 Content-Type: text/plain; charset="utf-8" Consolidate the code that extract the ip address(src,dst) and port number(src,dst) of the packet into a separate routine extract_ip_and_port() since the same chunk of code is called from two place. Cc: Zhang Chen Cc: Li Zhijian Cc: Jason Wang Signed-off-by: Mao Zhongyi --- net/colo.c | 18 ++++++++++-------- net/colo.h | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/net/colo.c b/net/colo.c index 28ce7c8..a39d600 100644 --- a/net/colo.c +++ b/net/colo.c @@ -82,6 +82,14 @@ int parse_packet_early(Packet *pkt) return 0; } =20 +void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, Packet *p= kt) +{ + key->src =3D pkt->ip->ip_src; + key->dst =3D pkt->ip->ip_dst; + key->src_port =3D ntohs(tmp_ports >> 16); + key->dst_port =3D ntohs(tmp_ports & 0xffff); +} + void fill_connection_key(Packet *pkt, ConnectionKey *key) { uint32_t tmp_ports; @@ -97,17 +105,11 @@ void fill_connection_key(Packet *pkt, ConnectionKey *k= ey) case IPPROTO_SCTP: case IPPROTO_UDPLITE: tmp_ports =3D *(uint32_t *)(pkt->transport_header); - key->src =3D pkt->ip->ip_src; - key->dst =3D pkt->ip->ip_dst; - key->src_port =3D ntohs(tmp_ports & 0xffff); - key->dst_port =3D ntohs(tmp_ports >> 16); + extract_ip_and_port(tmp_ports, key, pkt); break; case IPPROTO_AH: tmp_ports =3D *(uint32_t *)(pkt->transport_header + 4); - key->src =3D pkt->ip->ip_src; - key->dst =3D pkt->ip->ip_dst; - key->src_port =3D ntohs(tmp_ports & 0xffff); - key->dst_port =3D ntohs(tmp_ports >> 16); + extract_ip_and_port(tmp_ports, key, pkt); break; default: break; diff --git a/net/colo.h b/net/colo.h index caedb0d..0658e86 100644 --- a/net/colo.h +++ b/net/colo.h @@ -76,6 +76,7 @@ typedef struct Connection { uint32_t connection_key_hash(const void *opaque); int connection_key_equal(const void *opaque1, const void *opaque2); int parse_packet_early(Packet *pkt); +void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, Packet *p= kt); void fill_connection_key(Packet *pkt, ConnectionKey *key); void reverse_connection_key(ConnectionKey *key); Connection *connection_new(ConnectionKey *key); --=20 2.9.4