From nobody Sun May 5 12:00:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14926705271623.308456748017761; Wed, 19 Apr 2017 23:42:07 -0700 (PDT) Received: from localhost ([::1]:51908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15n3-0006ul-2U for importer@patchew.org; Thu, 20 Apr 2017 02:42:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15k0-0004UC-4H for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d15jz-0005UF-5Q for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:56 -0400 Received: from [59.151.112.132] (port=35327 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15jx-0005TG-M1 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:55 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Apr 2017 14:38:50 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id B13E647E6342; Thu, 20 Apr 2017 14:38:47 +0800 (CST) Received: from localhost.localdomain (10.167.226.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 20 Apr 2017 14:38:46 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="17962609" From: Zhang Chen To: qemu devel , Jason Wang Date: Thu, 20 Apr 2017 14:39:01 +0800 Message-ID: <1492670346-18004-2-git-send-email-zhangchen.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> References: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.56] X-yoursite-MailScanner-ID: B13E647E6342.ABB6D X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: zhangchen.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH V2 1/6] net/filter-mirror.c: Add filter-mirror and filter-redirector vnet support. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Zhijian , bian naimeng , "eddie . dong" , zhanghailiang , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In this patch, we change the send packet format from struct {int size; const uint8_t buf[];} to {int size; int vnet_hdr_len; con= st uint8_t buf[];}. make other module(like colo-compare) know how to parse net packet correctly. Signed-off-by: Zhang Chen --- net/filter-mirror.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/net/filter-mirror.c b/net/filter-mirror.c index 72fa7c2..5b4d616 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -23,6 +23,7 @@ #include "sysemu/char.h" #include "qemu/iov.h" #include "qemu/sockets.h" +#include "hw/virtio/virtio-net.h" =20 #define FILTER_MIRROR(obj) \ OBJECT_CHECK(MirrorState, (obj), TYPE_FILTER_MIRROR) @@ -43,12 +44,15 @@ typedef struct MirrorState { SocketReadState rs; } MirrorState; =20 -static int filter_mirror_send(CharBackend *chr_out, +static int filter_mirror_send(MirrorState *s, const struct iovec *iov, int iovcnt) { + NetFilterState *nf =3D NETFILTER(s); + VirtIONet *n =3D qemu_get_nic_opaque(nf->netdev->peer); int ret =3D 0; ssize_t size =3D 0; + ssize_t vnet_hdr_len; uint32_t len =3D 0; char *buf; =20 @@ -58,14 +62,25 @@ static int filter_mirror_send(CharBackend *chr_out, } =20 len =3D htonl(size); - ret =3D qemu_chr_fe_write_all(chr_out, (uint8_t *)&len, sizeof(len)); + ret =3D qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len= )); + if (ret !=3D sizeof(len)) { + goto err; + } + + /* + * We send vnet header len make other module(like colo-compare) + * know how to parse net packet correctly. + */ + vnet_hdr_len =3D n->guest_hdr_len; + len =3D htonl(vnet_hdr_len); + ret =3D qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len= )); if (ret !=3D sizeof(len)) { goto err; } =20 buf =3D g_malloc(size); iov_to_buf(iov, iovcnt, 0, buf, size); - ret =3D qemu_chr_fe_write_all(chr_out, (uint8_t *)buf, size); + ret =3D qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size); g_free(buf); if (ret !=3D size) { goto err; @@ -141,7 +156,7 @@ static ssize_t filter_mirror_receive_iov(NetFilterState= *nf, MirrorState *s =3D FILTER_MIRROR(nf); int ret; =20 - ret =3D filter_mirror_send(&s->chr_out, iov, iovcnt); + ret =3D filter_mirror_send(s, iov, iovcnt); if (ret) { error_report("filter_mirror_send failed(%s)", strerror(-ret)); } @@ -164,7 +179,7 @@ static ssize_t filter_redirector_receive_iov(NetFilterS= tate *nf, int ret; =20 if (qemu_chr_fe_get_driver(&s->chr_out)) { - ret =3D filter_mirror_send(&s->chr_out, iov, iovcnt); + ret =3D filter_mirror_send(s, iov, iovcnt); if (ret) { error_report("filter_mirror_send failed(%s)", strerror(-ret)); } --=20 2.7.4 From nobody Sun May 5 12:00:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492670435116156.96682062188927; Wed, 19 Apr 2017 23:40:35 -0700 (PDT) Received: from localhost ([::1]:51898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15lZ-0005dU-M6 for importer@patchew.org; Thu, 20 Apr 2017 02:40:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15jz-0004U9-5F for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d15jw-0005T6-1b for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:55 -0400 Received: from [59.151.112.132] (port=59779 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15jv-0005Sl-3y for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:51 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Apr 2017 14:38:50 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 0FE9B47E6344; Thu, 20 Apr 2017 14:38:49 +0800 (CST) Received: from localhost.localdomain (10.167.226.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 20 Apr 2017 14:38:48 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="17962608" From: Zhang Chen To: qemu devel , Jason Wang Date: Thu, 20 Apr 2017 14:39:02 +0800 Message-ID: <1492670346-18004-3-git-send-email-zhangchen.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> References: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.56] X-yoursite-MailScanner-ID: 0FE9B47E6344.AC8FC X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: zhangchen.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH V2 2/6] net/net.c: Add vnet header length to SocketReadState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Zhijian , bian naimeng , "eddie . dong" , zhanghailiang , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Address Jason Wang's comments add vnet header length to SocketReadState. So we change net_fill_rstate() to read struct {int size; int vnet_hdr_len; const uint8_t buf[];}. Signed-off-by: Zhang Chen --- include/net/net.h | 4 +++- net/net.c | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 99b28d5..1204fe5 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -111,9 +111,11 @@ typedef struct NICState { } NICState; =20 struct SocketReadState { - int state; /* 0 =3D getting length, 1 =3D getting data */ + /* 0 =3D getting length, 1 =3D getting vnet header length, 2 =3D getti= ng data */ + int state; uint32_t index; uint32_t packet_len; + uint32_t vnet_hdr_len; uint8_t buf[NET_BUFSIZE]; SocketReadStateFinalize *finalize; }; diff --git a/net/net.c b/net/net.c index 0ac3b9e..d467452 100644 --- a/net/net.c +++ b/net/net.c @@ -1621,8 +1621,12 @@ int net_fill_rstate(SocketReadState *rs, const uint8= _t *buf, int size) unsigned int l; =20 while (size > 0) { - /* reassemble a packet from the network */ - switch (rs->state) { /* 0 =3D getting length, 1 =3D getting data */ + /* Reassemble a packet from the network. + * 0 =3D getting length. + * 1 =3D getting vnet header length. + * 2 =3D getting data. + */ + switch (rs->state) { case 0: l =3D 4 - rs->index; if (l > size) { @@ -1640,6 +1644,22 @@ int net_fill_rstate(SocketReadState *rs, const uint8= _t *buf, int size) } break; case 1: + l =3D 4 - rs->index; + if (l > size) { + l =3D size; + } + memcpy(rs->buf + rs->index, buf, l); + buf +=3D l; + size -=3D l; + rs->index +=3D l; + if (rs->index =3D=3D 4) { + /* got vnet header length */ + rs->vnet_hdr_len =3D ntohl(*(uint32_t *)rs->buf); + rs->index =3D 0; + rs->state =3D 2; + } + break; + case 2: l =3D rs->packet_len - rs->index; if (l > size) { l =3D size; --=20 2.7.4 From nobody Sun May 5 12:00:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492670438341559.4136479145768; Wed, 19 Apr 2017 23:40:38 -0700 (PDT) Received: from localhost ([::1]:51900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15lc-0005g1-Qk for importer@patchew.org; Thu, 20 Apr 2017 02:40:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15k0-0004UD-5R for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d15jy-0005U3-Qw for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:56 -0400 Received: from [59.151.112.132] (port=59779 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15jx-0005Sl-UA for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:54 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Apr 2017 14:38:50 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id DEF1147CE254; Thu, 20 Apr 2017 14:38:50 +0800 (CST) Received: from localhost.localdomain (10.167.226.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 20 Apr 2017 14:38:49 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="17962611" From: Zhang Chen To: qemu devel , Jason Wang Date: Thu, 20 Apr 2017 14:39:03 +0800 Message-ID: <1492670346-18004-4-git-send-email-zhangchen.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> References: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.56] X-yoursite-MailScanner-ID: DEF1147CE254.ACF71 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: zhangchen.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH V2 3/6] net/colo-compare.c: Make colo-compare support vnet_hdr_len X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Zhijian , bian naimeng , "eddie . dong" , zhanghailiang , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" COLO-compare can get vnet header length from filter, Add vnet_hdr_len to struct packet and output packet with the vnet_hdr_len. Signed-off-by: Zhang Chen --- net/colo-compare.c | 39 ++++++++++++++++++++++++++++++++------- net/colo.c | 3 ++- net/colo.h | 4 +++- net/filter-rewriter.c | 2 +- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 54e6d40..b3e933c 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -99,7 +99,8 @@ enum { =20 static int compare_chr_send(CharBackend *out, const uint8_t *buf, - uint32_t size); + uint32_t size, + uint32_t vnet_hdr_len); =20 static gint seq_sorter(Packet *a, Packet *b, gpointer data) { @@ -121,9 +122,13 @@ static int packet_enqueue(CompareState *s, int mode) Connection *conn; =20 if (mode =3D=3D PRIMARY_IN) { - pkt =3D packet_new(s->pri_rs.buf, s->pri_rs.packet_len); + pkt =3D packet_new(s->pri_rs.buf, + s->pri_rs.packet_len, + s->pri_rs.vnet_hdr_len); } else { - pkt =3D packet_new(s->sec_rs.buf, s->sec_rs.packet_len); + pkt =3D packet_new(s->sec_rs.buf, + s->sec_rs.packet_len, + s->sec_rs.vnet_hdr_len); } =20 if (parse_packet_early(pkt)) { @@ -436,7 +441,10 @@ static void colo_compare_connection(void *opaque, void= *user_data) } =20 if (result) { - ret =3D compare_chr_send(&s->chr_out, pkt->data, pkt->size); + ret =3D compare_chr_send(&s->chr_out, + pkt->data, + pkt->size, + pkt->vnet_hdr_len); if (ret < 0) { error_report("colo_send_primary_packet failed"); } @@ -459,7 +467,8 @@ static void colo_compare_connection(void *opaque, void = *user_data) =20 static int compare_chr_send(CharBackend *out, const uint8_t *buf, - uint32_t size) + uint32_t size, + uint32_t vnet_hdr_len) { int ret =3D 0; uint32_t len =3D htonl(size); @@ -473,6 +482,16 @@ static int compare_chr_send(CharBackend *out, goto err; } =20 + /* + * We send vnet header len make other module(like colo-compare) + * know how to parse net packet correctly. + */ + len =3D htonl(vnet_hdr_len); + ret =3D qemu_chr_fe_write_all(out, (uint8_t *)&len, sizeof(len)); + if (ret !=3D sizeof(len)) { + goto err; + } + ret =3D qemu_chr_fe_write_all(out, (uint8_t *)buf, size); if (ret !=3D size) { goto err; @@ -616,7 +635,10 @@ static void compare_pri_rs_finalize(SocketReadState *p= ri_rs) =20 if (packet_enqueue(s, PRIMARY_IN)) { trace_colo_compare_main("primary: unsupported packet in"); - compare_chr_send(&s->chr_out, pri_rs->buf, pri_rs->packet_len); + compare_chr_send(&s->chr_out, + pri_rs->buf, + pri_rs->packet_len, + pri_rs->vnet_hdr_len); } else { /* compare connection */ g_queue_foreach(&s->conn_list, colo_compare_connection, s); @@ -725,7 +747,10 @@ static void colo_flush_packets(void *opaque, void *use= r_data) =20 while (!g_queue_is_empty(&conn->primary_list)) { pkt =3D g_queue_pop_head(&conn->primary_list); - compare_chr_send(&s->chr_out, pkt->data, pkt->size); + compare_chr_send(&s->chr_out, + pkt->data, + pkt->size, + pkt->vnet_hdr_len); packet_destroy(pkt, NULL); } while (!g_queue_is_empty(&conn->secondary_list)) { diff --git a/net/colo.c b/net/colo.c index 8cc166b..180eaed 100644 --- a/net/colo.c +++ b/net/colo.c @@ -153,13 +153,14 @@ void connection_destroy(void *opaque) g_slice_free(Connection, conn); } =20 -Packet *packet_new(const void *data, int size) +Packet *packet_new(const void *data, int size, int vnet_hdr_len) { Packet *pkt =3D g_slice_new(Packet); =20 pkt->data =3D g_memdup(data, size); pkt->size =3D size; pkt->creation_ms =3D qemu_clock_get_ms(QEMU_CLOCK_HOST); + pkt->vnet_hdr_len =3D vnet_hdr_len; =20 return pkt; } diff --git a/net/colo.h b/net/colo.h index 7c524f3..caedb0d 100644 --- a/net/colo.h +++ b/net/colo.h @@ -43,6 +43,8 @@ typedef struct Packet { int size; /* Time of packet creation, in wall clock ms */ int64_t creation_ms; + /* Get vnet_hdr_len from filter */ + uint32_t vnet_hdr_len; } Packet; =20 typedef struct ConnectionKey { @@ -82,7 +84,7 @@ Connection *connection_get(GHashTable *connection_track_t= able, ConnectionKey *key, GQueue *conn_list); void connection_hashtable_reset(GHashTable *connection_track_table); -Packet *packet_new(const void *data, int size); +Packet *packet_new(const void *data, int size, int vnet_hdr_len); void packet_destroy(void *opaque, void *user_data); =20 #endif /* QEMU_COLO_PROXY_H */ diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index afa06e8..63256c7 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -158,7 +158,7 @@ static ssize_t colo_rewriter_receive_iov(NetFilterState= *nf, char *buf =3D g_malloc0(size); =20 iov_to_buf(iov, iovcnt, 0, buf, size); - pkt =3D packet_new(buf, size); + pkt =3D packet_new(buf, size, 0); g_free(buf); =20 /* --=20 2.7.4 From nobody Sun May 5 12:00:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492670439510663.0512891929828; Wed, 19 Apr 2017 23:40:39 -0700 (PDT) Received: from localhost ([::1]:51902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15ld-0005h8-V8 for importer@patchew.org; Thu, 20 Apr 2017 02:40:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15k2-0004Vr-Ma for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d15k1-0005Uz-Qk for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:58 -0400 Received: from [59.151.112.132] (port=46559 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15k1-0005Uj-E1 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:57 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Apr 2017 14:38:57 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id AD09647E6343; Thu, 20 Apr 2017 14:38:52 +0800 (CST) Received: from localhost.localdomain (10.167.226.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 20 Apr 2017 14:38:51 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="17962616" From: Zhang Chen To: qemu devel , Jason Wang Date: Thu, 20 Apr 2017 14:39:04 +0800 Message-ID: <1492670346-18004-5-git-send-email-zhangchen.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> References: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.56] X-yoursite-MailScanner-ID: AD09647E6343.AACEF X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: zhangchen.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH V2 4/6] net/socket.c: Add vnet packet support in net_socket_receive() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Zhijian , bian naimeng , "eddie . dong" , zhanghailiang , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Because of net_socket_send() add vnet header length argument, Avoid conflict with net_socket_send(). Signed-off-by: Zhang Chen --- net/socket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/socket.c b/net/socket.c index fe3547b..1f1f3d2 100644 --- a/net/socket.c +++ b/net/socket.c @@ -33,6 +33,7 @@ #include "qemu/sockets.h" #include "qemu/iov.h" #include "qemu/main-loop.h" +#include "hw/virtio/virtio-net.h" =20 typedef struct NetSocketState { NetClientState nc; @@ -81,12 +82,17 @@ static void net_socket_writable(void *opaque) static ssize_t net_socket_receive(NetClientState *nc, const uint8_t *buf, = size_t size) { NetSocketState *s =3D DO_UPCAST(NetSocketState, nc, nc); + VirtIONet *n =3D qemu_get_nic_opaque(nc->peer); uint32_t len =3D htonl(size); + uint32_t vnet_hdr_len =3D htonl(n->guest_hdr_len); struct iovec iov[] =3D { { .iov_base =3D &len, .iov_len =3D sizeof(len), }, { + .iov_base =3D &vnet_hdr_len, + .iov_len =3D sizeof(vnet_hdr_len), + }, { .iov_base =3D (void *)buf, .iov_len =3D size, }, --=20 2.7.4 From nobody Sun May 5 12:00:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492670586620882.5086288418368; Wed, 19 Apr 2017 23:43:06 -0700 (PDT) Received: from localhost ([::1]:51910 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15o0-0007UU-M4 for importer@patchew.org; Thu, 20 Apr 2017 02:43:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15k3-0004Wz-T6 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:39:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d15k2-0005VP-Vz for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:59 -0400 Received: from [59.151.112.132] (port=46559 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15k2-0005Uj-JI for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:58 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Apr 2017 14:38:57 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 3309A47E6346; Thu, 20 Apr 2017 14:38:54 +0800 (CST) Received: from localhost.localdomain (10.167.226.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 20 Apr 2017 14:38:53 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="17962619" From: Zhang Chen To: qemu devel , Jason Wang Date: Thu, 20 Apr 2017 14:39:05 +0800 Message-ID: <1492670346-18004-6-git-send-email-zhangchen.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> References: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.56] X-yoursite-MailScanner-ID: 3309A47E6346.A9CEA X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: zhangchen.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH V2 5/6] net/colo.c: Add vnet packet parse feature in colo-proxy X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Zhijian , bian naimeng , "eddie . dong" , zhanghailiang , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make colo-compare and filter-rewriter can parse vnet packet. Signed-off-by: Zhang Chen --- net/colo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/colo.c b/net/colo.c index 180eaed..28ce7c8 100644 --- a/net/colo.c +++ b/net/colo.c @@ -43,11 +43,11 @@ int parse_packet_early(Packet *pkt) { int network_length; static const uint8_t vlan[] =3D {0x81, 0x00}; - uint8_t *data =3D pkt->data; + uint8_t *data =3D pkt->data + pkt->vnet_hdr_len; uint16_t l3_proto; ssize_t l2hdr_len =3D eth_get_l2_hdr_length(data); =20 - if (pkt->size < ETH_HLEN) { + if (pkt->size < ETH_HLEN + pkt->vnet_hdr_len) { trace_colo_proxy_main("pkt->size < ETH_HLEN"); return 1; } @@ -73,7 +73,7 @@ int parse_packet_early(Packet *pkt) } =20 network_length =3D pkt->ip->ip_hl * 4; - if (pkt->size < l2hdr_len + network_length) { + if (pkt->size < l2hdr_len + network_length + pkt->vnet_hdr_len) { trace_colo_proxy_main("pkt->size < network_header + network_length= "); return 1; } --=20 2.7.4 From nobody Sun May 5 12:00:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492670657864709.1743413280748; Wed, 19 Apr 2017 23:44:17 -0700 (PDT) Received: from localhost ([::1]:51913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15p9-0008D4-M8 for importer@patchew.org; Thu, 20 Apr 2017 02:44:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15k4-0004XY-J3 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:39:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d15k3-0005Va-KK for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:39:00 -0400 Received: from [59.151.112.132] (port=32048 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d15k3-0005V6-9Q for qemu-devel@nongnu.org; Thu, 20 Apr 2017 02:38:59 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Apr 2017 14:38:57 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id B333347E6347; Thu, 20 Apr 2017 14:38:55 +0800 (CST) Received: from localhost.localdomain (10.167.226.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 20 Apr 2017 14:38:54 +0800 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="17962618" From: Zhang Chen To: qemu devel , Jason Wang Date: Thu, 20 Apr 2017 14:39:06 +0800 Message-ID: <1492670346-18004-7-git-send-email-zhangchen.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> References: <1492670346-18004-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.56] X-yoursite-MailScanner-ID: B333347E6347.AA8E8 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: zhangchen.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH V2 6/6] net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Zhijian , bian naimeng , "eddie . dong" , zhanghailiang , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" COLO-Proxy just focus on packet payload, So we skip vnet header. Signed-off-by: Zhang Chen --- net/colo-compare.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index b3e933c..1941ad9 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -187,6 +187,8 @@ static int packet_enqueue(CompareState *s, int mode) */ static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offs= et) { + int offset_all; + if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) { char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20= ]; =20 @@ -200,9 +202,12 @@ static int colo_packet_compare_common(Packet *ppkt, Pa= cket *spkt, int offset) sec_ip_src, sec_ip_dst); } =20 + offset_all =3D ppkt->vnet_hdr_len + offset; + if (ppkt->size =3D=3D spkt->size) { - return memcmp(ppkt->data + offset, spkt->data + offset, - spkt->size - offset); + return memcmp(ppkt->data + offset_all, + spkt->data + offset_all, + spkt->size - offset_all); } else { trace_colo_compare_main("Net packet size are not the same"); return -1; --=20 2.7.4