From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhBAh-0005LN-JU for qemu-devel@nongnu.org; Tue, 06 Sep 2016 03:52:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhBAb-0002y3-Ti for qemu-devel@nongnu.org; Tue, 06 Sep 2016 03:51:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51642) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhBAb-0002xx-LZ for qemu-devel@nongnu.org; Tue, 06 Sep 2016 03:51:49 -0400 References: <1473068248-11146-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> <1473068248-11146-7-git-send-email-zhangchen.fnst@cn.fujitsu.com> From: Jason Wang Message-ID: <19f25bba-845f-98de-f549-b206cffa99ce@redhat.com> Date: Tue, 6 Sep 2016 15:51:40 +0800 MIME-Version: 1.0 In-Reply-To: <1473068248-11146-7-git-send-email-zhangchen.fnst@cn.fujitsu.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V13 06/12] colo-compare: track connection and enqueue packet List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Zhang Chen , qemu devel Cc: Li Zhijian , Wen Congyang , zhanghailiang , "eddie . dong" , "Dr . David Alan Gilbert" On 2016=E5=B9=B409=E6=9C=8805=E6=97=A5 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 > Signed-off-by: Li Zhijian > Signed-off-by: Wen Congyang > --- > 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; > =20 > + /* 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 =3D {{ 0 } }; > Packet *pkt =3D NULL; > + Connection *conn; > =20 > if (mode =3D=3D PRIMARY_IN) { > pkt =3D packet_new(s->pri_rs.buf, s->pri_rs.packet_len); > @@ -110,17 +117,34 @@ static int packet_enqueue(CompareState *s, int mo= de) > pkt =3D NULL; > return -1; > } > - /* TODO: get connection key from pkt */ > + fill_connection_key(pkt, &key); > =20 > - /* > - * TODO: use connection key get conn from > - * connection_track_table > - */ > + conn =3D connection_get(s->connection_track_table, > + &key, > + &s->conn_list); > =20 > - /* > - * 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 =3D true; > + } > + > + 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); > + } else { > + error_report("colo compare primary queue size too big," > + "drop packet"); > + } > + } else { > + if (g_queue_get_length(&conn->secondary_list) < > + MAX_QUEUE_SIZE) { <=3D ? [...]