From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3nvu-00054i-CG for qemu-devel@nongnu.org; Tue, 01 Dec 2015 11:37:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3nvp-0003PY-N3 for qemu-devel@nongnu.org; Tue, 01 Dec 2015 11:37:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3nvp-0003PP-FQ for qemu-devel@nongnu.org; Tue, 01 Dec 2015 11:37:33 -0500 Date: Tue, 1 Dec 2015 16:37:26 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20151201163726.GF26419@work-vm> References: <1448627251-11186-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> <1448627251-11186-10-git-send-email-zhangchen.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1448627251-11186-10-git-send-email-zhangchen.fnst@cn.fujitsu.com> Content-Transfer-Encoding: quoted-printable 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: Zhang Chen Cc: Li Zhijian , Gui jianfeng , Jason Wang , "eddie.dong" , qemu devel , Huang peng , Gong lei , Stefan Hajnoczi , jan.kiszka@siemens.com, zhanghailiang * Zhang Chen (zhangchen.fnst@cn.fujitsu.com) wrote: > From: zhangchen >=20 > 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 >=20 > Signed-off-by: zhangchen > --- > net/colo-proxy.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 74 insertions(+) >=20 > 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; > } > =20 > +static void colo_send_primary_packet(void *opaque, void *user_data) > +{ > + Packet *pkt =3D 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 =3D opaque; > + g_queue_foreach(&connection->primary_list, colo_send_primary_packe= t, 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 =3D 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 =3D 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 *use= r_data) > g_slice_free(Packet, pkt); > } > =20 > +/* > + * The sent IP packets comparison between primary > + * and secondary > + * TODO=EF=BC=9A 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=3D%s, pkt->ip->ipsrc=3D%x,pkt->ip->ipdst=3D= %x\n", > + (char *)ppkt->data, ppkt->ip->ip_src, ppkt->ip->ip_dst= ); > + DEBUG("seconda pkt data=3D%s, pkt->ip->ipsrc=3D%x,pkt->ip->ipdst=3D= %x\n", > + (char *)spkt->data, spkt->ip->ip_src, spkt->ip->ip_dst= ); Is it always IP packets we're comparing at this point? > + if (ppkt->size =3D=3D spkt->size) { > + DEBUG("colo_packet_compare data ppkt\n"); > + for (i =3D 0; i < spkt->size; i++) { > + DEBUG("%x", ((char *)ppkt->data)[i]); > + DEBUG("|"); > + } > + DEBUG("\ncolo_packet_compare data spkt\n"); > + for (i =3D 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->da= ta); 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. > + if (!memcmp(ppkt->data, spkt->data, spkt->size)) { > + return true; > + } else { > + return false; > + } > + } else { > + return false; > + } > +} > + > static Connection *colo_proxy_enqueue_packet(GHashTable *unprocessed_p= ackets, > Connection_key *key, > Packet *pkt, packet_type typ= e) > --=20 > 1.9.1 >=20 >=20 >=20 Dave -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK