From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4O0R-0006Ix-7C for qemu-devel@nongnu.org; Thu, 03 Dec 2015 02:08:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4O0N-0004mC-W6 for qemu-devel@nongnu.org; Thu, 03 Dec 2015 02:08:43 -0500 Received: from [59.151.112.132] (port=42181 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4O0N-0004lw-1G for qemu-devel@nongnu.org; Thu, 03 Dec 2015 02:08:39 -0500 References: <1448627251-11186-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> <1448627251-11186-10-git-send-email-zhangchen.fnst@cn.fujitsu.com> <20151201163726.GF26419@work-vm> From: Zhang Chen Message-ID: <565FEADD.70609@cn.fujitsu.com> Date: Thu, 3 Dec 2015 15:10:21 +0800 MIME-Version: 1.0 In-Reply-To: <20151201163726.GF26419@work-vm> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC PATCH 9/9] net/colo-proxy: add packet compare and notify checkpoint List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: Li Zhijian , Gui jianfeng , Jason Wang , "eddie.dong" , qemu devel , Huang peng , Gong lei , Stefan Hajnoczi , jan.kiszka@siemens.com, zhanghailiang Hi,Dave On 12/02/2015 12:37 AM, Dr. David Alan Gilbert wrote: > * Zhang Chen (zhangchen.fnst@cn.fujitsu.com) wrote: >> From: zhangchen >> >> Lookup same connection's primary and secondary packet >> to compare,if same we will send primary packet and >> drop secondary packet,else send all of primary >> packets be queued,drop secondary queue and notify >> colo to do checkpoint >> >> Signed-off-by: zhangchen >> --- >> net/colo-proxy.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 74 insertions(+) >> >> diff --git a/net/colo-proxy.c b/net/colo-proxy.c >> index 5f1852a..847f7f2 100644 >> --- a/net/colo-proxy.c >> +++ b/net/colo-proxy.c >> @@ -70,6 +70,41 @@ static Connection *connection_new(void) >> return connection; >> } >> >> +static void colo_send_primary_packet(void *opaque, void *user_data) >> +{ >> + Packet *pkt = opaque; >> + qemu_net_queue_send(pkt->s->incoming_queue, pkt->sender, 0, >> + (const uint8_t *)pkt->data, pkt->size, NULL); >> +} >> + >> +static void colo_flush_connection(void *opaque, void *user_data) >> +{ >> + Connection *connection = opaque; >> + g_queue_foreach(&connection->primary_list, colo_send_primary_packet, NULL); >> + g_queue_foreach(&connection->secondary_list, packet_destroy, NULL); >> +} >> + >> +static void colo_proxy_notify_checkpoint(void) >> +{ >> + DEBUG("colo_proxy_notify_checkpoint\n"); >> +} >> + >> +static void colo_proxy_do_checkpoint(NetFilterState *nf) >> +{ >> + ColoProxyState *s = FILTER_COLO_PROXY(nf); >> + >> + g_queue_foreach(&s->unprocessed_connections, colo_flush_connection, NULL); >> +} >> + >> +/* >> + * colo failover flag >> + */ >> +static ssize_t colo_has_failover(NetFilterState *nf) >> +{ >> + ColoProxyState *s = FILTER_COLO_PROXY(nf); >> + return s->has_failover; >> +} >> + >> /* Return 0 on success, or return -1 if the pkt is corrpted */ >> static int parse_packet_early(Packet *pkt, Connection_key *key) >> { >> @@ -136,6 +171,45 @@ static void packet_destroy(void *opaque, void *user_data) >> g_slice_free(Packet, pkt); >> } >> >> +/* >> + * The sent IP packets comparison between primary >> + * and secondary >> + * TODO: support ip fragment >> + * return: true means packet same >> + * false means packet different >> + */ >> +static bool colo_packet_compare(Packet *ppkt, Packet *spkt) >> +{ >> + int i; >> + DEBUG("colo_packet_compare lens ppkt %d,spkt %d\n", ppkt->size, >> + spkt->size); >> + DEBUG("primary pkt data=%s, pkt->ip->ipsrc=%x,pkt->ip->ipdst=%x\n", >> + (char *)ppkt->data, ppkt->ip->ip_src, ppkt->ip->ip_dst); >> + DEBUG("seconda pkt data=%s, pkt->ip->ipsrc=%x,pkt->ip->ipdst=%x\n", >> + (char *)spkt->data, spkt->ip->ip_src, spkt->ip->ip_dst); > Is it always IP packets we're comparing at this point? yes,you are right >> + if (ppkt->size == spkt->size) { >> + DEBUG("colo_packet_compare data ppkt\n"); >> + for (i = 0; i < spkt->size; i++) { >> + DEBUG("%x", ((char *)ppkt->data)[i]); >> + DEBUG("|"); >> + } >> + DEBUG("\ncolo_packet_compare data spkt\n"); >> + for (i = 0; i < spkt->size; i++) { >> + DEBUG("%x", ((char *)spkt->data)[i]); >> + DEBUG("|"); >> + } >> + DEBUG("\ncolo_packet_compare data ppkt %s\n", (char *)ppkt->data); >> + DEBUG("colo_packet_compare data spkt %s\n", (char *)spkt->data); > It's probably better to make these a helper debug routine to dump > a packet; I bet you'll wnat to sometimes do it when the sizes > are different. I will dump packet before diff size in next version Thanks for review zhangchen >> + if (!memcmp(ppkt->data, spkt->data, spkt->size)) { >> + return true; >> + } else { >> + return false; >> + } >> + } else { >> + return false; >> + } >> +} >> + >> static Connection *colo_proxy_enqueue_packet(GHashTable *unprocessed_packets, >> Connection_key *key, >> Packet *pkt, packet_type type) >> -- >> 1.9.1 >> >> >> > Dave > > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > > > . >