From: Jason Wang <jasowang@redhat.com>
To: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>,
qemu devel <qemu-devel@nongnu.org>
Cc: Li Zhijian <lizhijian@cn.fujitsu.com>,
Wen Congyang <wency@cn.fujitsu.com>,
zhanghailiang <zhang.zhanghailiang@huawei.com>,
"eddie . dong" <eddie.dong@intel.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH V13 06/12] colo-compare: track connection and enqueue packet
Date: Tue, 6 Sep 2016 15:51:40 +0800 [thread overview]
Message-ID: <19f25bba-845f-98de-f549-b206cffa99ce@redhat.com> (raw)
In-Reply-To: <1473068248-11146-7-git-send-email-zhangchen.fnst@cn.fujitsu.com>
On 2016年09月05日 17:37, Zhang Chen wrote:
> In this patch we use kernel jhash table to track
> connection, and then enqueue net packet like this:
>
> + CompareState ++
> | |
> +---------------+ +---------------+ +---------------+
> |conn list +--->conn +--------->conn |
> +---------------+ +---------------+ +---------------+
> | | | | | |
> +---------------+ +---v----+ +---v----+ +---v----+ +---v----+
> |primary | |secondary |primary | |secondary
> |packet | |packet + |packet | |packet +
> +--------+ +--------+ +--------+ +--------+
> | | | |
> +---v----+ +---v----+ +---v----+ +---v----+
> |primary | |secondary |primary | |secondary
> |packet | |packet + |packet | |packet +
> +--------+ +--------+ +--------+ +--------+
> | | | |
> +---v----+ +---v----+ +---v----+ +---v----+
> |primary | |secondary |primary | |secondary
> |packet | |packet + |packet | |packet +
> +--------+ +--------+ +--------+ +--------+
>
> We use conn_list to record connection info.
> When we want to enqueue a packet, firstly get the
> connection from connection_track_table. then push
> the packet to g_queue(pri/sec) in it's own conn.
>
> Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
> net/colo-compare.c | 51 ++++++++++++++++++++-----
> net/colo.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> net/colo.h | 27 ++++++++++++++
> 3 files changed, 176 insertions(+), 10 deletions(-)
>
> diff --git a/net/colo-compare.c b/net/colo-compare.c
> index d642ad4..42fc354 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -70,6 +70,11 @@ typedef struct CompareState {
> SocketReadState pri_rs;
> SocketReadState sec_rs;
>
> + /* connection list: the connections belonged to this NIC could be found
> + * in this list.
> + * element type: Connection
> + */
> + GQueue conn_list;
> /* hashtable to save connection */
> GHashTable *connection_track_table;
> } CompareState;
> @@ -97,7 +102,9 @@ static int compare_chr_send(CharDriverState *out,
> */
> static int packet_enqueue(CompareState *s, int mode)
> {
> + ConnectionKey key = {{ 0 } };
> Packet *pkt = NULL;
> + Connection *conn;
>
> if (mode == PRIMARY_IN) {
> pkt = packet_new(s->pri_rs.buf, s->pri_rs.packet_len);
> @@ -110,17 +117,34 @@ static int packet_enqueue(CompareState *s, int mode)
> pkt = NULL;
> return -1;
> }
> - /* TODO: get connection key from pkt */
> + fill_connection_key(pkt, &key);
>
> - /*
> - * TODO: use connection key get conn from
> - * connection_track_table
> - */
> + conn = connection_get(s->connection_track_table,
> + &key,
> + &s->conn_list);
>
> - /*
> - * TODO: insert pkt to it's conn->primary_list
> - * or conn->secondary_list
> - */
> + if (!conn->processing) {
> + g_queue_push_tail(&s->conn_list, conn);
> + conn->processing = true;
> + }
> +
> + if (mode == PRIMARY_IN) {
> + if (g_queue_get_length(&conn->primary_list) <=
> + MAX_QUEUE_SIZE) {
> + g_queue_push_tail(&conn->primary_list, pkt);
> + } else {
> + error_report("colo compare primary queue size too big,"
> + "drop packet");
> + }
> + } else {
> + if (g_queue_get_length(&conn->secondary_list) <
> + MAX_QUEUE_SIZE) {
<= ?
[...]
next prev parent reply other threads:[~2016-09-06 7:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-05 9:37 [Qemu-devel] [PATCH V13 00/12] Introduce COLO-Proxy Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 01/12] docs: Add documentation for COLO-proxy Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 02/12] qemu-char: Add qemu_chr_add_handlers_full() for GMaincontext Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 03/12] colo-compare: introduce colo compare initialization Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 04/12] net/colo.c: add colo.c to define and handle packet Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 05/12] Jhash: add linux kernel jhashtable in qemu Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 06/12] colo-compare: track connection and enqueue packet Zhang Chen
2016-09-06 7:51 ` Jason Wang [this message]
2016-09-06 7:55 ` Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 07/12] colo-compare: introduce packet comparison thread Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 08/12] colo-compare: add TCP, UDP, ICMP packet comparison Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 09/12] filter-rewriter: introduce filter-rewriter initialization Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 10/12] filter-rewriter: track connection and parse packet Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 11/12] filter-rewriter: rewrite tcp packet to keep secondary connection Zhang Chen
2016-09-05 9:37 ` [Qemu-devel] [PATCH V13 12/12] MAINTAINERS: add maintainer for COLO-proxy Zhang Chen
2016-09-05 10:25 ` [Qemu-devel] [PATCH V13 00/12] Introduce COLO-Proxy no-reply
2016-09-05 10:35 ` no-reply
2016-09-06 8:02 ` Jason Wang
2016-09-07 1:16 ` 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=19f25bba-845f-98de-f549-b206cffa99ce@redhat.com \
--to=jasowang@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eddie.dong@intel.com \
--cc=lizhijian@cn.fujitsu.com \
--cc=qemu-devel@nongnu.org \
--cc=wency@cn.fujitsu.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).