From nobody Thu May 2 23:02:27 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.zohomail.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 1500294208326817.5417236076831; Mon, 17 Jul 2017 05:23:28 -0700 (PDT) Received: from localhost ([::1]:50048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX53e-0001TM-HX for importer@patchew.org; Mon, 17 Jul 2017 08:23:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52E-0000Xt-IK for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:21:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52D-0007o0-KM for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:21:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38678) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52D-0007nD-EA for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:21:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 521B34DD7C; Mon, 17 Jul 2017 12:21:56 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 777C7600C2; Mon, 17 Jul 2017 12:21:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 521B34DD7C Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 521B34DD7C From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:32 +0800 Message-Id: <1500294105-13713-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 17 Jul 2017 12:21:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/14] net: Add vnet_hdr_len arguments in NetClientState 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen Add vnet_hdr_len arguments in NetClientState that make other module get real vnet_hdr_len easily. Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- include/net/net.h | 1 + net/net.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 99b28d5..9a92c70 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -100,6 +100,7 @@ struct NetClientState { unsigned int queue_index; unsigned rxfilter_notify_enabled:1; int vring_enable; + int vnet_hdr_len; QTAILQ_HEAD(NetFilterHead, NetFilterState) filters; }; =20 diff --git a/net/net.c b/net/net.c index 6235aab..b62ce10 100644 --- a/net/net.c +++ b/net/net.c @@ -492,6 +492,7 @@ void qemu_set_vnet_hdr_len(NetClientState *nc, int len) return; } =20 + nc->vnet_hdr_len =3D len; nc->info->set_vnet_hdr_len(nc, len); } =20 --=20 2.7.4 From nobody Thu May 2 23:02:27 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.zohomail.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 150029421934843.56959154014646; Mon, 17 Jul 2017 05:23:39 -0700 (PDT) Received: from localhost ([::1]:50050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX53j-0001XN-QO for importer@patchew.org; Mon, 17 Jul 2017 08:23:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52H-0000YO-5Q for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52G-0007tB-1F for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59510) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52F-0007pU-NH for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:21:59 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A717D81235; Mon, 17 Jul 2017 12:21:58 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE037600C2; Mon, 17 Jul 2017 12:21:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A717D81235 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A717D81235 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:33 +0800 Message-Id: <1500294105-13713-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 17 Jul 2017 12:21:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/14] net/net.c: Add vnet_hdr support in 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen We add a flag to decide whether net_fill_rstate() need read the vnet_hdr_len or not. Signed-off-by: Zhang Chen Suggested-by: Jason Wang Signed-off-by: Jason Wang --- include/net/net.h | 9 +++++++-- net/colo-compare.c | 4 ++-- net/filter-mirror.c | 2 +- net/net.c | 36 ++++++++++++++++++++++++++++++++---- net/socket.c | 8 ++++---- 5 files changed, 46 insertions(+), 13 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 9a92c70..1c55a93 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -112,9 +112,13 @@ 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; + /* This flag decide whether to read the vnet_hdr_len field */ + bool vnet_hdr; uint32_t index; uint32_t packet_len; + uint32_t vnet_hdr_len; uint8_t buf[NET_BUFSIZE]; SocketReadStateFinalize *finalize; }; @@ -177,7 +181,8 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, void print_net_client(Monitor *mon, NetClientState *nc); void hmp_info_network(Monitor *mon, const QDict *qdict); void net_socket_rs_init(SocketReadState *rs, - SocketReadStateFinalize *finalize); + SocketReadStateFinalize *finalize, + bool vnet_hdr); =20 /* NIC info */ =20 diff --git a/net/colo-compare.c b/net/colo-compare.c index abfc23c..ea9bccc 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -743,8 +743,8 @@ static void colo_compare_complete(UserCreatable *uc, Er= ror **errp) return; } =20 - net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize); - net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize); + net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize, false); + net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize, false); =20 g_queue_init(&s->conn_list); =20 diff --git a/net/filter-mirror.c b/net/filter-mirror.c index 6043549..1b6211b 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -229,7 +229,7 @@ static void filter_redirector_setup(NetFilterState *nf,= Error **errp) } } =20 - net_socket_rs_init(&s->rs, redirector_rs_finalize); + net_socket_rs_init(&s->rs, redirector_rs_finalize, false); =20 if (s->indev) { chr =3D qemu_chr_find(s->indev); diff --git a/net/net.c b/net/net.c index b62ce10..0e28099 100644 --- a/net/net.c +++ b/net/net.c @@ -1616,11 +1616,14 @@ QemuOptsList qemu_net_opts =3D { }; =20 void net_socket_rs_init(SocketReadState *rs, - SocketReadStateFinalize *finalize) + SocketReadStateFinalize *finalize, + bool vnet_hdr) { rs->state =3D 0; + rs->vnet_hdr =3D vnet_hdr; rs->index =3D 0; rs->packet_len =3D 0; + rs->vnet_hdr_len =3D 0; memset(rs->buf, 0, sizeof(rs->buf)); rs->finalize =3D finalize; } @@ -1635,8 +1638,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) { @@ -1650,10 +1657,31 @@ int net_fill_rstate(SocketReadState *rs, const uint= 8_t *buf, int size) /* got length */ rs->packet_len =3D ntohl(*(uint32_t *)rs->buf); rs->index =3D 0; - rs->state =3D 1; + if (rs->vnet_hdr) { + rs->state =3D 1; + } else { + rs->state =3D 2; + rs->vnet_hdr_len =3D 0; + } } 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; diff --git a/net/socket.c b/net/socket.c index dcae1ae..f85ef7d 100644 --- a/net/socket.c +++ b/net/socket.c @@ -174,7 +174,7 @@ static void net_socket_send(void *opaque) closesocket(s->fd); =20 s->fd =3D -1; - net_socket_rs_init(&s->rs, net_socket_rs_finalize); + net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); s->nc.link_down =3D true; memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); =20 @@ -366,7 +366,7 @@ static NetSocketState *net_socket_fd_init_dgram(NetClie= ntState *peer, s->fd =3D fd; s->listen_fd =3D -1; s->send_fn =3D net_socket_send_dgram; - net_socket_rs_init(&s->rs, net_socket_rs_finalize); + net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); net_socket_read_poll(s, true); =20 /* mcast: save bound address as dst */ @@ -417,7 +417,7 @@ static NetSocketState *net_socket_fd_init_stream(NetCli= entState *peer, =20 s->fd =3D fd; s->listen_fd =3D -1; - net_socket_rs_init(&s->rs, net_socket_rs_finalize); + net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); =20 /* Disable Nagle algorithm on TCP sockets to reduce latency */ socket_set_nodelay(fd); @@ -522,7 +522,7 @@ static int net_socket_listen_init(NetClientState *peer, s->fd =3D -1; s->listen_fd =3D fd; s->nc.link_down =3D true; - net_socket_rs_init(&s->rs, net_socket_rs_finalize); + net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); =20 qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s); return 0; --=20 2.7.4 From nobody Thu May 2 23:02:27 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.zohomail.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 1500294332827829.696039476882; Mon, 17 Jul 2017 05:25:32 -0700 (PDT) Received: from localhost ([::1]:50059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX55d-0003TH-CV for importer@patchew.org; Mon, 17 Jul 2017 08:25:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52I-0000Zk-TI for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52H-0007x1-VV for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38788) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52H-0007vv-Pr for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5A1B4E33D; Mon, 17 Jul 2017 12:22:00 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BCC2600C2; Mon, 17 Jul 2017 12:21:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C5A1B4E33D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C5A1B4E33D From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:34 +0800 Message-Id: <1500294105-13713-4-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 17 Jul 2017 12:22:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/14] net/filter-mirror.c: Introduce parameter for filter_send() 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen This patch change the filter_send() parameter from CharBackend to MirrorSta= te, we can get more information like vnet_hdr(We use it to support packet with = vnet_header). Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- net/filter-mirror.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/filter-mirror.c b/net/filter-mirror.c index 1b6211b..e8e5b60 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -43,7 +43,7 @@ typedef struct MirrorState { SocketReadState rs; } MirrorState; =20 -static int filter_send(CharBackend *chr_out, +static int filter_send(MirrorState *s, const struct iovec *iov, int iovcnt) { @@ -58,14 +58,14 @@ static int filter_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; } =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 +141,7 @@ static ssize_t filter_mirror_receive_iov(NetFilterState= *nf, MirrorState *s =3D FILTER_MIRROR(nf); int ret; =20 - ret =3D filter_send(&s->chr_out, iov, iovcnt); + ret =3D filter_send(s, iov, iovcnt); if (ret) { error_report("filter mirror send failed(%s)", strerror(-ret)); } @@ -164,7 +164,7 @@ static ssize_t filter_redirector_receive_iov(NetFilterS= tate *nf, int ret; =20 if (qemu_chr_fe_backend_connected(&s->chr_out)) { - ret =3D filter_send(&s->chr_out, iov, iovcnt); + ret =3D filter_send(s, iov, iovcnt); if (ret) { error_report("filter redirector send failed(%s)", strerror(-re= t)); } --=20 2.7.4 From nobody Thu May 2 23:02:27 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.zohomail.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 1500294337800840.2184520696957; Mon, 17 Jul 2017 05:25:37 -0700 (PDT) Received: from localhost ([::1]:50061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX55k-0003b6-DS for importer@patchew.org; Mon, 17 Jul 2017 08:25:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52M-0000cW-3h for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52K-00080k-BL for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55982) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52K-0007zu-1u for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 146DD85A05; Mon, 17 Jul 2017 12:22:03 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64FF4600C2; Mon, 17 Jul 2017 12:22:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 146DD85A05 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 146DD85A05 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:35 +0800 Message-Id: <1500294105-13713-5-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 17 Jul 2017 12:22:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/14] net/filter-mirror.c: Make filter mirror support 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen We add the vnet_hdr_support option for filter-mirror, default is disabled. If you use virtio-net-pci or other driver needs vnet_hdr, please enable it. You can use it for example: -object filter-mirror,id=3Dm0,netdev=3Dhn0,queue=3Dtx,outdev=3Dmirror0,vnet= _hdr_support If it has vnet_hdr_support flag, we will change the sending packet format f= rom 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 Signed-off-by: Jason Wang --- net/filter-mirror.c | 42 +++++++++++++++++++++++++++++++++++++++++- qemu-options.hx | 5 ++--- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/net/filter-mirror.c b/net/filter-mirror.c index e8e5b60..32ecdb3 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -41,12 +41,14 @@ typedef struct MirrorState { CharBackend chr_in; CharBackend chr_out; SocketReadState rs; + bool vnet_hdr; } MirrorState; =20 static int filter_send(MirrorState *s, const struct iovec *iov, int iovcnt) { + NetFilterState *nf =3D NETFILTER(s); int ret =3D 0; ssize_t size =3D 0; uint32_t len =3D 0; @@ -63,6 +65,23 @@ static int filter_send(MirrorState *s, goto err; } =20 + if (s->vnet_hdr) { + /* + * If vnet_hdr =3D on, we send vnet header len to make other + * module(like colo-compare) know how to parse net + * packet correctly. + */ + ssize_t vnet_hdr_len; + + vnet_hdr_len =3D nf->netdev->vnet_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; + } + } + buf =3D g_malloc(size); iov_to_buf(iov, iovcnt, 0, buf, size); ret =3D qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size); @@ -229,7 +248,7 @@ static void filter_redirector_setup(NetFilterState *nf,= Error **errp) } } =20 - net_socket_rs_init(&s->rs, redirector_rs_finalize, false); + net_socket_rs_init(&s->rs, redirector_rs_finalize, s->vnet_hdr); =20 if (s->indev) { chr =3D qemu_chr_find(s->indev); @@ -318,6 +337,20 @@ static void filter_mirror_set_outdev(Object *obj, } } =20 +static bool filter_mirror_get_vnet_hdr(Object *obj, Error **errp) +{ + MirrorState *s =3D FILTER_MIRROR(obj); + + return s->vnet_hdr; +} + +static void filter_mirror_set_vnet_hdr(Object *obj, bool value, Error **er= rp) +{ + MirrorState *s =3D FILTER_MIRROR(obj); + + s->vnet_hdr =3D value; +} + static char *filter_redirector_get_outdev(Object *obj, Error **errp) { MirrorState *s =3D FILTER_REDIRECTOR(obj); @@ -337,8 +370,15 @@ static void filter_redirector_set_outdev(Object *obj, =20 static void filter_mirror_init(Object *obj) { + MirrorState *s =3D FILTER_MIRROR(obj); + object_property_add_str(obj, "outdev", filter_mirror_get_outdev, filter_mirror_set_outdev, NULL); + + s->vnet_hdr =3D false; + object_property_add_bool(obj, "vnet_hdr_support", + filter_mirror_get_vnet_hdr, + filter_mirror_set_vnet_hdr, NULL); } =20 static void filter_redirector_init(Object *obj) diff --git a/qemu-options.hx b/qemu-options.hx index 2cc70b9..9eee712 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4249,10 +4249,9 @@ queue @var{all|rx|tx} is an option that can be appli= ed to any netfilter. @option{tx}: the filter is attached to the transmit queue of the netdev, where it will receive packets sent by the netdev. =20 -@item -object filter-mirror,id=3D@var{id},netdev=3D@var{netdevid},outdev= =3D@var{chardevid}[,queue=3D@var{all|rx|tx}] +@item -object filter-mirror,id=3D@var{id},netdev=3D@var{netdevid},outdev= =3D@var{chardevid},queue=3D@var{all|rx|tx}[,vnet_hdr_support] =20 -filter-mirror on netdev @var{netdevid},mirror net packet to chardev -@var{chardevid} +filter-mirror on netdev @var{netdevid},mirror net packet to chardev@var{ch= ardevid}, if it has the vnet_hdr_support flag, filter-mirror will mirror pa= cket with vnet_hdr_len. =20 @item -object filter-redirector,id=3D@var{id},netdev=3D@var{netdevid},inde= v=3D@var{chardevid}, outdev=3D@var{chardevid}[,queue=3D@var{all|rx|tx}] --=20 2.7.4 From nobody Thu May 2 23:02:27 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.zohomail.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 1500294463116380.6734511805587; Mon, 17 Jul 2017 05:27:43 -0700 (PDT) Received: from localhost ([::1]:50066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX57k-0005Gs-LL for importer@patchew.org; Mon, 17 Jul 2017 08:27:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52N-0000dx-Nt for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52M-00083A-Mj for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47676) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52M-00082e-Cp for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:06 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B303C049D5C; Mon, 17 Jul 2017 12:22:05 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E663600C2; Mon, 17 Jul 2017 12:22:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6B303C049D5C Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6B303C049D5C From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:36 +0800 Message-Id: <1500294105-13713-6-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 17 Jul 2017 12:22:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/14] net/filter-mirror.c: Add new option to enable vnet support for filter-redirector 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen We add the vnet_hdr_support option for filter-redirector, default is disabl= ed. If you use virtio-net-pci net driver or other driver needs vnet_hdr, please= enable it. Because colo-compare or other modules needs the vnet_hdr_len to parse packet, we add this new option send the len to others. You can use it for example: -object filter-redirector,id=3Dr0,netdev=3Dhn0,queue=3Dtx,outdev=3Dred0,vne= t_hdr_support Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- net/filter-mirror.c | 23 +++++++++++++++++++++++ qemu-options.hx | 6 +++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/net/filter-mirror.c b/net/filter-mirror.c index 32ecdb3..90e2c92 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -368,6 +368,22 @@ static void filter_redirector_set_outdev(Object *obj, s->outdev =3D g_strdup(value); } =20 +static bool filter_redirector_get_vnet_hdr(Object *obj, Error **errp) +{ + MirrorState *s =3D FILTER_REDIRECTOR(obj); + + return s->vnet_hdr; +} + +static void filter_redirector_set_vnet_hdr(Object *obj, + bool value, + Error **errp) +{ + MirrorState *s =3D FILTER_REDIRECTOR(obj); + + s->vnet_hdr =3D value; +} + static void filter_mirror_init(Object *obj) { MirrorState *s =3D FILTER_MIRROR(obj); @@ -383,10 +399,17 @@ static void filter_mirror_init(Object *obj) =20 static void filter_redirector_init(Object *obj) { + MirrorState *s =3D FILTER_REDIRECTOR(obj); + object_property_add_str(obj, "indev", filter_redirector_get_indev, filter_redirector_set_indev, NULL); object_property_add_str(obj, "outdev", filter_redirector_get_outdev, filter_redirector_set_outdev, NULL); + + s->vnet_hdr =3D false; + object_property_add_bool(obj, "vnet_hdr_support", + filter_redirector_get_vnet_hdr, + filter_redirector_set_vnet_hdr, NULL); } =20 static void filter_mirror_fini(Object *obj) diff --git a/qemu-options.hx b/qemu-options.hx index 9eee712..b86c09e 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4253,11 +4253,11 @@ queue @var{all|rx|tx} is an option that can be appl= ied to any netfilter. =20 filter-mirror on netdev @var{netdevid},mirror net packet to chardev@var{ch= ardevid}, if it has the vnet_hdr_support flag, filter-mirror will mirror pa= cket with vnet_hdr_len. =20 -@item -object filter-redirector,id=3D@var{id},netdev=3D@var{netdevid},inde= v=3D@var{chardevid}, -outdev=3D@var{chardevid}[,queue=3D@var{all|rx|tx}] +@item -object filter-redirector,id=3D@var{id},netdev=3D@var{netdevid},inde= v=3D@var{chardevid},outdev=3D@var{chardevid},queue=3D@var{all|rx|tx}[,vnet_= hdr_support] =20 filter-redirector on netdev @var{netdevid},redirect filter's net packet to= chardev -@var{chardevid},and redirect indev's packet to filter. +@var{chardevid},and redirect indev's packet to filter.if it has the vnet_h= dr_support flag, +filter-redirector will redirect packet with vnet_hdr_len. Create a filter-redirector we need to differ outdev id from indev id, id c= an not be the same. we can just use indev or outdev, but at least one of indev or= outdev need to be specified. --=20 2.7.4 From nobody Thu May 2 23:02:27 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.zohomail.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 1500294333795974.1214736542886; Mon, 17 Jul 2017 05:25:33 -0700 (PDT) Received: from localhost ([::1]:50060 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX55g-0003XD-Fo for importer@patchew.org; Mon, 17 Jul 2017 08:25:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52R-0000hF-2h for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52Q-000868-2v for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47738) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52P-00085H-Pv for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8C12C0467D6; Mon, 17 Jul 2017 12:22:08 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0213600C2; Mon, 17 Jul 2017 12:22:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C8C12C0467D6 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C8C12C0467D6 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:37 +0800 Message-Id: <1500294105-13713-7-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 17 Jul 2017 12:22:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/14] net/colo.c: Make vnet_hdr_len as packet property 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen We can use this property flush and send packet with vnet_hdr_len. Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- net/colo-compare.c | 8 ++++++-- net/colo.c | 3 ++- net/colo.h | 4 +++- net/filter-rewriter.c | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index ea9bccc..9c2b1ea 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -121,9 +121,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)) { 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 Thu May 2 23:02:27 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.zohomail.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 1500294471404537.3799541469825; Mon, 17 Jul 2017 05:27:51 -0700 (PDT) Received: from localhost ([::1]:50068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX57r-0005Mp-3W for importer@patchew.org; Mon, 17 Jul 2017 08:27:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52V-0000lZ-Oa for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52S-00087k-KM for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52868) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52S-00087M-Bb for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E4F67A161; Mon, 17 Jul 2017 12:22:11 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62963600C2; Mon, 17 Jul 2017 12:22:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5E4F67A161 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5E4F67A161 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:38 +0800 Message-Id: <1500294105-13713-8-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 17 Jul 2017 12:22:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/14] net/colo-compare.c: Introduce parameter for compare_chr_send() 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen This patch change the compare_chr_send() parameter from CharBackend to Comp= areState, we can get more information like vnet_hdr(We use it to support packet with = vnet_header). Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- net/colo-compare.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 9c2b1ea..c5d01da 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -97,7 +97,7 @@ enum { SECONDARY_IN, }; =20 -static int compare_chr_send(CharBackend *out, +static int compare_chr_send(CompareState *s, const uint8_t *buf, uint32_t size); =20 @@ -483,7 +483,7 @@ 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, pkt->data, pkt->size); if (ret < 0) { error_report("colo_send_primary_packet failed"); } @@ -504,7 +504,7 @@ static void colo_compare_connection(void *opaque, void = *user_data) } } =20 -static int compare_chr_send(CharBackend *out, +static int compare_chr_send(CompareState *s, const uint8_t *buf, uint32_t size) { @@ -515,12 +515,12 @@ static int compare_chr_send(CharBackend *out, return 0; } =20 - ret =3D qemu_chr_fe_write_all(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; } =20 - ret =3D qemu_chr_fe_write_all(out, (uint8_t *)buf, size); + ret =3D qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size); if (ret !=3D size) { goto err; } @@ -665,7 +665,7 @@ static void compare_pri_rs_finalize(SocketReadState *pr= i_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, pri_rs->buf, pri_rs->packet_len); } else { /* compare connection */ g_queue_foreach(&s->conn_list, colo_compare_connection, s); @@ -774,7 +774,7 @@ static void colo_flush_packets(void *opaque, void *user= _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, pkt->data, pkt->size); packet_destroy(pkt, NULL); } while (!g_queue_is_empty(&conn->secondary_list)) { --=20 2.7.4 From nobody Thu May 2 23:02:27 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.zohomail.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 1500294593982616.9829797126627; Mon, 17 Jul 2017 05:29:53 -0700 (PDT) Received: from localhost ([::1]:50074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX59q-0007V9-Hz for importer@patchew.org; Mon, 17 Jul 2017 08:29:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52X-0000n7-IK for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52W-0008BT-7u for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59908) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52V-0008B3-Vo for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF78981243; Mon, 17 Jul 2017 12:22:14 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id EABBE600C2; Mon, 17 Jul 2017 12:22:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EF78981243 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EF78981243 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:39 +0800 Message-Id: <1500294105-13713-9-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 17 Jul 2017 12:22:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/14] 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen We add the vnet_hdr_support option for colo-compare, default is disabled. If you use virtio-net-pci or other driver needs vnet_hdr, please enable it. You can use it for example: -object colo-compare,id=3Dcomp0,primary_in=3Dcompare0-0,secondary_in=3Dcomp= are1,outdev=3Dcompare_out0,vnet_hdr_support 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 Signed-off-by: Jason Wang --- net/colo-compare.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++---= ---- qemu-options.hx | 4 ++-- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index c5d01da..95911a2 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -73,6 +73,7 @@ typedef struct CompareState { CharBackend chr_out; SocketReadState pri_rs; SocketReadState sec_rs; + bool vnet_hdr; =20 /* connection list: the connections belonged to this NIC could be found * in this list. @@ -99,7 +100,8 @@ enum { =20 static int compare_chr_send(CompareState *s, 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) { @@ -483,7 +485,10 @@ static void colo_compare_connection(void *opaque, void= *user_data) } =20 if (result) { - ret =3D compare_chr_send(s, pkt->data, pkt->size); + ret =3D compare_chr_send(s, + pkt->data, + pkt->size, + pkt->vnet_hdr_len); if (ret < 0) { error_report("colo_send_primary_packet failed"); } @@ -506,7 +511,8 @@ static void colo_compare_connection(void *opaque, void = *user_data) =20 static int compare_chr_send(CompareState *s, 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); @@ -520,6 +526,18 @@ static int compare_chr_send(CompareState *s, goto err; } =20 + if (s->vnet_hdr) { + /* + * We send vnet header len make other module(like filter-redirecto= r) + * know how to parse net packet correctly. + */ + 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; + } + } + ret =3D qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size); if (ret !=3D size) { goto err; @@ -659,13 +677,32 @@ static void compare_set_outdev(Object *obj, const cha= r *value, Error **errp) s->outdev =3D g_strdup(value); } =20 +static bool compare_get_vnet_hdr(Object *obj, Error **errp) +{ + CompareState *s =3D COLO_COMPARE(obj); + + return s->vnet_hdr; +} + +static void compare_set_vnet_hdr(Object *obj, + bool value, + Error **errp) +{ + CompareState *s =3D COLO_COMPARE(obj); + + s->vnet_hdr =3D value; +} + static void compare_pri_rs_finalize(SocketReadState *pri_rs) { CompareState *s =3D container_of(pri_rs, CompareState, pri_rs); =20 if (packet_enqueue(s, PRIMARY_IN)) { trace_colo_compare_main("primary: unsupported packet in"); - compare_chr_send(s, pri_rs->buf, pri_rs->packet_len); + compare_chr_send(s, + 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); @@ -747,8 +784,8 @@ static void colo_compare_complete(UserCreatable *uc, Er= ror **errp) return; } =20 - net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize, false); - net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize, false); + net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize, s->vnet_hdr); + net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize, s->vnet_hdr); =20 g_queue_init(&s->conn_list); =20 @@ -774,7 +811,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, pkt->data, pkt->size); + compare_chr_send(s, + pkt->data, + pkt->size, + pkt->vnet_hdr_len); packet_destroy(pkt, NULL); } while (!g_queue_is_empty(&conn->secondary_list)) { @@ -792,6 +832,8 @@ static void colo_compare_class_init(ObjectClass *oc, vo= id *data) =20 static void colo_compare_init(Object *obj) { + CompareState *s =3D COLO_COMPARE(obj); + object_property_add_str(obj, "primary_in", compare_get_pri_indev, compare_set_pri_indev, NULL); @@ -801,6 +843,10 @@ static void colo_compare_init(Object *obj) object_property_add_str(obj, "outdev", compare_get_outdev, compare_set_outdev, NULL); + + s->vnet_hdr =3D false; + object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr, + compare_set_vnet_hdr, NULL); } =20 static void colo_compare_finalize(Object *obj) diff --git a/qemu-options.hx b/qemu-options.hx index b86c09e..91a25ee 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4282,13 +4282,13 @@ Dump the network traffic on netdev @var{dev} to the= file specified by The file format is libpcap, so it can be analyzed with tools such as tcpdu= mp or Wireshark. =20 -@item -object colo-compare,id=3D@var{id},primary_in=3D@var{chardevid},seco= ndary_in=3D@var{chardevid}, -outdev=3D@var{chardevid} +@item -object colo-compare,id=3D@var{id},primary_in=3D@var{chardevid},seco= ndary_in=3D@var{chardevid},outdev=3D@var{chardevid}[,vnet_hdr_support] =20 Colo-compare gets packet from primary_in@var{chardevid} and secondary_in@v= ar{chardevid}, than compare primary packet with secondary packet. If the packets are same, we will output primary packet to outdev@var{chardevid}, else we will notify colo-frame do checkpoint and send primary packet to outdev@var{chardevid}. +if it has the vnet_hdr_support flag, colo compare will send/recv packet wi= th vnet_hdr_len. =20 we must use it with the help of filter-mirror and filter-redirector. =20 --=20 2.7.4 From nobody Thu May 2 23:02:27 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.zohomail.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 1500294464260412.8011304753179; Mon, 17 Jul 2017 05:27:44 -0700 (PDT) Received: from localhost ([::1]:50067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX57l-0005IY-Vd for importer@patchew.org; Mon, 17 Jul 2017 08:27:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52Z-0000ot-CE for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52Y-0008Cq-Fa for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39070) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52Y-0008CH-9w for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:18 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4BBF14E33D; Mon, 17 Jul 2017 12:22:17 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85CC0600C2; Mon, 17 Jul 2017 12:22:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4BBF14E33D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4BBF14E33D From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:40 +0800 Message-Id: <1500294105-13713-10-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 17 Jul 2017 12:22:17 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/14] 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen Make colo-compare and filter-rewriter can parse vnet packet. Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- 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 Thu May 2 23:02:27 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.zohomail.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 1500294749326411.81116122835067; Mon, 17 Jul 2017 05:32:29 -0700 (PDT) Received: from localhost ([::1]:50088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX5CN-0001F6-1g for importer@patchew.org; Mon, 17 Jul 2017 08:32:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52b-0000r3-It for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52a-0008Et-Q9 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46288) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52a-0008Ec-Ja for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:20 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8FA2780F6D; Mon, 17 Jul 2017 12:22:19 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3A5C600C2; Mon, 17 Jul 2017 12:22:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8FA2780F6D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8FA2780F6D From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:41 +0800 Message-Id: <1500294105-13713-11-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 17 Jul 2017 12:22:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/14] 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen COLO-Proxy just focus on packet payload, so we skip vnet header. Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- net/colo-compare.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 95911a2..ca67c68 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -201,8 +201,11 @@ static int colo_packet_compare_common(Packet *ppkt, Pa= cket *spkt, int offset) sec_ip_src, sec_ip_dst); } =20 + offset =3D ppkt->vnet_hdr_len + offset; + if (ppkt->size =3D=3D spkt->size) { - return memcmp(ppkt->data + offset, spkt->data + offset, + return memcmp(ppkt->data + offset, + spkt->data + offset, spkt->size - offset); } else { trace_colo_compare_main("Net packet size are not the same"); @@ -261,8 +264,9 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet= *ppkt) */ if (ptcp->th_off > 5) { ptrdiff_t tcp_offset; + tcp_offset =3D ppkt->transport_header - (uint8_t *)ppkt->data - + (ptcp->th_off * 4); + + (ptcp->th_off * 4) - ppkt->vnet_hdr_len; res =3D colo_packet_compare_common(ppkt, spkt, tcp_offset); } else if (ptcp->th_sum =3D=3D stcp->th_sum) { res =3D colo_packet_compare_common(ppkt, spkt, ETH_HLEN); --=20 2.7.4 From nobody Thu May 2 23:02:27 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.zohomail.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 1500294586320412.7999227235673; Mon, 17 Jul 2017 05:29:46 -0700 (PDT) Received: from localhost ([::1]:50073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX59j-0007RD-S7 for importer@patchew.org; Mon, 17 Jul 2017 08:29:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52e-0000tw-O9 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52d-0008G4-BG for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42514) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52d-0008Fo-24 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:23 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E5E323DE3D; Mon, 17 Jul 2017 12:22:21 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25C78600C2; Mon, 17 Jul 2017 12:22:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E5E323DE3D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E5E323DE3D From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:42 +0800 Message-Id: <1500294105-13713-12-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 17 Jul 2017 12:22:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/14] net/filter-rewriter.c: Make filter-rewriter 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen We add the vnet_hdr_support option for filter-rewriter, default is disabled. If you use virtio-net-pci or other driver needs vnet_hdr, please enable it. You can use it for example: -object filter-rewriter,id=3Drew0,netdev=3Dhn0,queue=3Dall,vnet_hdr_support We get the vnet_hdr_len from NetClientState that make us parse net packet correctly. Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- net/filter-rewriter.c | 37 ++++++++++++++++++++++++++++++++++++- qemu-options.hx | 4 ++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index 63256c7..55a6cf5 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -17,6 +17,7 @@ #include "qemu-common.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" +#include "qemu/error-report.h" #include "qapi-visit.h" #include "qom/object.h" #include "qemu/main-loop.h" @@ -33,6 +34,7 @@ typedef struct RewriterState { NetQueue *incoming_queue; /* hashtable to save connection */ GHashTable *connection_track_table; + bool vnet_hdr; } RewriterState; =20 static void filter_rewriter_flush(NetFilterState *nf) @@ -155,10 +157,16 @@ static ssize_t colo_rewriter_receive_iov(NetFilterSta= te *nf, ConnectionKey key; Packet *pkt; ssize_t size =3D iov_size(iov, iovcnt); + ssize_t vnet_hdr_len =3D 0; char *buf =3D g_malloc0(size); =20 iov_to_buf(iov, iovcnt, 0, buf, size); - pkt =3D packet_new(buf, size, 0); + + if (s->vnet_hdr) { + vnet_hdr_len =3D nf->netdev->vnet_hdr_len; + } + + pkt =3D packet_new(buf, size, vnet_hdr_len); g_free(buf); =20 /* @@ -237,6 +245,32 @@ static void colo_rewriter_setup(NetFilterState *nf, Er= ror **errp) s->incoming_queue =3D qemu_new_net_queue(qemu_netfilter_pass_to_next, = nf); } =20 +static bool filter_rewriter_get_vnet_hdr(Object *obj, Error **errp) +{ + RewriterState *s =3D FILTER_COLO_REWRITER(obj); + + return s->vnet_hdr; +} + +static void filter_rewriter_set_vnet_hdr(Object *obj, + bool value, + Error **errp) +{ + RewriterState *s =3D FILTER_COLO_REWRITER(obj); + + s->vnet_hdr =3D value; +} + +static void filter_rewriter_init(Object *obj) +{ + RewriterState *s =3D FILTER_COLO_REWRITER(obj); + + s->vnet_hdr =3D false; + object_property_add_bool(obj, "vnet_hdr_support", + filter_rewriter_get_vnet_hdr, + filter_rewriter_set_vnet_hdr, NULL); +} + static void colo_rewriter_class_init(ObjectClass *oc, void *data) { NetFilterClass *nfc =3D NETFILTER_CLASS(oc); @@ -250,6 +284,7 @@ static const TypeInfo colo_rewriter_info =3D { .name =3D TYPE_FILTER_REWRITER, .parent =3D TYPE_NETFILTER, .class_init =3D colo_rewriter_class_init, + .instance_init =3D filter_rewriter_init, .instance_size =3D sizeof(RewriterState), }; =20 diff --git a/qemu-options.hx b/qemu-options.hx index 91a25ee..e0e04c8 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4262,12 +4262,12 @@ Create a filter-redirector we need to differ outdev= id from indev id, id can not be the same. we can just use indev or outdev, but at least one of indev or= outdev need to be specified. =20 -@item -object filter-rewriter,id=3D@var{id},netdev=3D@var{netdevid}[,queue= =3D@var{all|rx|tx}] +@item -object filter-rewriter,id=3D@var{id},netdev=3D@var{netdevid},queue= =3D@var{all|rx|tx},[vnet_hdr_support] =20 Filter-rewriter is a part of COLO project.It will rewrite tcp packet to secondary from primary to keep secondary tcp connection,and rewrite tcp packet to primary from secondary make tcp packet can be handled by -client. +client.if it has the vnet_hdr_support flag, we can parse packet with vnet = header. =20 usage: colo secondary: --=20 2.7.4 From nobody Thu May 2 23:02:27 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.zohomail.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 15002948699331001.5121253326345; Mon, 17 Jul 2017 05:34:29 -0700 (PDT) Received: from localhost ([::1]:50096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX5EK-0003Ah-Nj for importer@patchew.org; Mon, 17 Jul 2017 08:34:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52g-0000vL-AU for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52f-0008Hl-AA for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46402) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52f-0008Gd-3d for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:25 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2DD7D80F97; Mon, 17 Jul 2017 12:22:24 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67E4C600C2; Mon, 17 Jul 2017 12:22:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2DD7D80F97 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2DD7D80F97 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:43 +0800 Message-Id: <1500294105-13713-13-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 17 Jul 2017 12:22:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 12/14] docs/colo-proxy.txt: Update colo-proxy usage of net driver with vnet_header 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: Jason Wang , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- docs/colo-proxy.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/colo-proxy.txt b/docs/colo-proxy.txt index c4941de..f6a624f 100644 --- a/docs/colo-proxy.txt +++ b/docs/colo-proxy.txt @@ -182,6 +182,32 @@ Secondary(ip:3.3.3.8): -chardev socket,id=3Dred1,host=3D3.3.3.3,port=3D9004 -object filter-redirector,id=3Df1,netdev=3Dhn0,queue=3Dtx,indev=3Dred0 -object filter-redirector,id=3Df2,netdev=3Dhn0,queue=3Drx,outdev=3Dred1 +-object filter-rewriter,id=3Df3,netdev=3Dhn0,queue=3Dall + +If you want to use virtio-net-pci or other driver with vnet_header: + +Primary(ip:3.3.3.3): +-netdev tap,id=3Dhn0,vhost=3Doff,script=3D/etc/qemu-ifup,downscript=3D/etc= /qemu-ifdown +-device e1000,id=3De0,netdev=3Dhn0,mac=3D52:a4:00:12:78:66 +-chardev socket,id=3Dmirror0,host=3D3.3.3.3,port=3D9003,server,nowait +-chardev socket,id=3Dcompare1,host=3D3.3.3.3,port=3D9004,server,nowait +-chardev socket,id=3Dcompare0,host=3D3.3.3.3,port=3D9001,server,nowait +-chardev socket,id=3Dcompare0-0,host=3D3.3.3.3,port=3D9001 +-chardev socket,id=3Dcompare_out,host=3D3.3.3.3,port=3D9005,server,nowait +-chardev socket,id=3Dcompare_out0,host=3D3.3.3.3,port=3D9005 +-object filter-mirror,id=3Dm0,netdev=3Dhn0,queue=3Dtx,outdev=3Dmirror0,vne= t_hdr_support +-object filter-redirector,netdev=3Dhn0,id=3Dredire0,queue=3Drx,indev=3Dcom= pare_out,vnet_hdr_support +-object filter-redirector,netdev=3Dhn0,id=3Dredire1,queue=3Drx,outdev=3Dco= mpare0,vnet_hdr_support +-object colo-compare,id=3Dcomp0,primary_in=3Dcompare0-0,secondary_in=3Dcom= pare1,outdev=3Dcompare_out0,vnet_hdr_support + +Secondary(ip:3.3.3.8): +-netdev tap,id=3Dhn0,vhost=3Doff,script=3D/etc/qemu-ifup,down script=3D/et= c/qemu-ifdown +-device e1000,netdev=3Dhn0,mac=3D52:a4:00:12:78:66 +-chardev socket,id=3Dred0,host=3D3.3.3.3,port=3D9003 +-chardev socket,id=3Dred1,host=3D3.3.3.3,port=3D9004 +-object filter-redirector,id=3Df1,netdev=3Dhn0,queue=3Dtx,indev=3Dred0,vne= t_hdr_support +-object filter-redirector,id=3Df2,netdev=3Dhn0,queue=3Drx,outdev=3Dred1,vn= et_hdr_support +-object filter-rewriter,id=3Df3,netdev=3Dhn0,queue=3Dall,vnet_hdr_support =20 Note: a.COLO-proxy must work with COLO-frame and Block-replication. --=20 2.7.4 From nobody Thu May 2 23:02:27 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.zohomail.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 1500294583115196.143352484645; Mon, 17 Jul 2017 05:29:43 -0700 (PDT) Received: from localhost ([::1]:50072 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX59g-0007Ot-Gb for importer@patchew.org; Mon, 17 Jul 2017 08:29:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52i-0000wz-7S for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52h-0008JQ-Hd for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53348) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52h-0008J4-B4 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 576887A166; Mon, 17 Jul 2017 12:22:26 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id A737F7E66F; Mon, 17 Jul 2017 12:22:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 576887A166 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 576887A166 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:44 +0800 Message-Id: <1500294105-13713-14-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 17 Jul 2017 12:22:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/14] virtion-net: Prefer is_power_of_2() 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: Michal Privoznik , Jason Wang 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Michal Privoznik We have a function that checks if given number is power of two. We should prefer it instead of expanding the check on our own. Signed-off-by: Michal Privoznik Signed-off-by: Jason Wang --- hw/net/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 5630a9e..657d099 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1942,7 +1942,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) */ if (n->net_conf.rx_queue_size < VIRTIO_NET_RX_QUEUE_MIN_SIZE || n->net_conf.rx_queue_size > VIRTQUEUE_MAX_SIZE || - (n->net_conf.rx_queue_size & (n->net_conf.rx_queue_size - 1))) { + !is_power_of_2(n->net_conf.rx_queue_size)) { error_setg(errp, "Invalid rx_queue_size (=3D %" PRIu16 "), " "must be a power of 2 between %d and %d.", n->net_conf.rx_queue_size, VIRTIO_NET_RX_QUEUE_MIN_SIZE, --=20 2.7.4 From nobody Thu May 2 23:02:27 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.zohomail.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 1500294745456223.49358504564566; Mon, 17 Jul 2017 05:32:25 -0700 (PDT) Received: from localhost ([::1]:50087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX5CH-0001AW-0P for importer@patchew.org; Mon, 17 Jul 2017 08:32:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX52n-000117-9s for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX52k-0008Le-7e for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:22:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58106) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX52k-0008Ke-29; Mon, 17 Jul 2017 08:22:30 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 186AB61E53; Mon, 17 Jul 2017 12:22:29 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-128.pek2.redhat.com [10.72.12.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEE02600C2; Mon, 17 Jul 2017 12:22:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 186AB61E53 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 186AB61E53 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 20:21:45 +0800 Message-Id: <1500294105-13713-15-git-send-email-jasowang@redhat.com> In-Reply-To: <1500294105-13713-1-git-send-email-jasowang@redhat.com> References: <1500294105-13713-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 17 Jul 2017 12:22:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/14] virtio-net: fix offload ctrl endian 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: Jason Wang , Dmitry Fleytman , qemu-stable@nongnu.org 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Spec said offloads should be le64, so use virtio_ldq_p() to guarantee valid endian. Fixes: 644c98587d4c ("virtio-net: dynamic network offloads configuration") Cc: qemu-stable@nongnu.org Cc: Dmitry Fleytman Signed-off-by: Jason Wang --- hw/net/virtio-net.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 657d099..148071a 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -758,6 +758,8 @@ static int virtio_net_handle_offloads(VirtIONet *n, uin= t8_t cmd, if (cmd =3D=3D VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET) { uint64_t supported_offloads; =20 + offloads =3D virtio_ldq_p(vdev, &offloads); + if (!n->has_vnet_hdr) { return VIRTIO_NET_ERR; } --=20 2.7.4