qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Cc: Li Zhijian <lizhijian@cn.fujitsu.com>,
	Gui jianfeng <guijianfeng@cn.fujitsu.com>,
	Jason Wang <jasowang@redhat.com>,
	"eddie.dong" <eddie.dong@intel.com>,
	qemu devel <qemu-devel@nongnu.org>,
	Huang peng <peter.huangpeng@huawei.com>,
	Gong lei <arei.gonglei@huawei.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	jan.kiszka@siemens.com,
	zhanghailiang <zhang.zhanghailiang@huawei.com>
Subject: Re: [Qemu-devel] [RFC PATCH 9/9] net/colo-proxy: add packet compare and notify checkpoint
Date: Tue, 1 Dec 2015 16:37:26 +0000	[thread overview]
Message-ID: <20151201163726.GF26419@work-vm> (raw)
In-Reply-To: <1448627251-11186-10-git-send-email-zhangchen.fnst@cn.fujitsu.com>

* Zhang Chen (zhangchen.fnst@cn.fujitsu.com) wrote:
> From: zhangchen <zhangchen.fnst@cn.fujitsu.com>
> 
> 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 <zhangchen.fnst@cn.fujitsu.com>
> ---
>  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?

> +    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.

> +        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

  reply	other threads:[~2015-12-01 16:37 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-27 12:27 [Qemu-devel] [RFC PATCH 0/9] Add colo-proxy based on netfilter Zhang Chen
2015-11-27 12:27 ` [Qemu-devel] [RFC PATCH 1/9] Init colo-proxy object " Zhang Chen
2015-11-30  2:50   ` Wen Congyang
2015-11-30  5:38     ` Zhang Chen
2015-11-27 12:27 ` [Qemu-devel] [RFC PATCH 2/9] jhash: add linux kernel jhashtable in qemu Zhang Chen
2015-12-01 11:23   ` Dr. David Alan Gilbert
2015-12-03  3:40     ` Zhang Chen
2015-11-27 12:27 ` [Qemu-devel] [RFC PATCH 3/9] colo-proxy: add colo-proxy framework Zhang Chen
2015-11-28  2:46   ` Hailiang Zhang
2015-11-30  2:25     ` Zhang Chen
2015-11-30  3:10   ` Wen Congyang
2015-11-30  5:44     ` Zhang Chen
2015-11-27 12:27 ` [Qemu-devel] [RFC PATCH 4/9] colo-proxy: add colo-proxy setup work Zhang Chen
2015-11-28  3:02   ` Hailiang Zhang
2015-11-30  2:35     ` Zhang Chen
2015-12-01 15:35   ` Dr. David Alan Gilbert
2015-12-03  3:49     ` Zhang Chen
2015-11-27 12:27 ` [Qemu-devel] [RFC PATCH 5/9] net/colo-proxy: add colo packet handler Zhang Chen
2015-11-28  3:17   ` Hailiang Zhang
2015-11-30  5:37     ` Zhang Chen
2015-11-27 12:27 ` [Qemu-devel] [RFC PATCH 6/9] net/colo-proxy: add packet forward function Zhang Chen
2015-12-01 15:50   ` Dr. David Alan Gilbert
2015-12-03  6:17     ` Zhang Chen
2015-11-27 12:27 ` [Qemu-devel] [RFC PATCH 7/9] net/colo-proxy: add packet enqueue and handle function Zhang Chen
2015-12-01 16:12   ` Dr. David Alan Gilbert
2015-12-03  6:35     ` Zhang Chen
2015-12-03  9:09       ` Dr. David Alan Gilbert
2015-12-04  3:21         ` Zhang Chen
2015-12-04  9:14           ` Dr. David Alan Gilbert
2015-11-27 12:27 ` [Qemu-devel] [RFC PATCH 8/9] net/colo-proxy: enqueue primary and secondary packet Zhang Chen
2015-11-27 12:27 ` [Qemu-devel] [RFC PATCH 9/9] net/colo-proxy: add packet compare and notify checkpoint Zhang Chen
2015-12-01 16:37   ` Dr. David Alan Gilbert [this message]
2015-12-03  7:10     ` Zhang Chen
2015-12-01 16:44 ` [Qemu-devel] [RFC PATCH 0/9] Add colo-proxy based on netfilter Dr. David Alan Gilbert
2015-12-03  7:33   ` Zhang Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151201163726.GF26419@work-vm \
    --to=dgilbert@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=eddie.dong@intel.com \
    --cc=guijianfeng@cn.fujitsu.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jasowang@redhat.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=zhang.zhanghailiang@huawei.com \
    --cc=zhangchen.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).