From: Jason Wang <jasowang@redhat.com>
To: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>,
qemu devel <qemu-devel@nongnu.org>
Cc: zhanghailiang <zhang.zhanghailiang@huawei.com>,
weifuqiang <weifuqiang@huawei.com>,
"eddie . dong" <eddie.dong@intel.com>,
bian naimeng <biannm@cn.fujitsu.com>,
Li Zhijian <lizhijian@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH V6 09/10] net/filter-rewriter.c: Make filter-rewriter support vnet_hdr_len
Date: Fri, 9 Jun 2017 14:20:58 +0800 [thread overview]
Message-ID: <c734e384-a0fe-0b08-2221-3d7a5842cb50@redhat.com> (raw)
In-Reply-To: <1496829322-17099-10-git-send-email-zhangchen.fnst@cn.fujitsu.com>
On 2017年06月07日 17:55, Zhang Chen wrote:
> We add the vnet_hdr_support option for filter-rewriter, default is disable.
> If you use virtio-net-pci net driver, please enable it.
> You can use it for example:
> -object filter-rewriter,id=rew0,netdev=hn0,queue=all,vnet_hdr_support
>
> We get the vnet_hdr_len from NetClientState that make us
> parse net packet correctly.
>
> Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
> ---
> net/filter-rewriter.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
> qemu-options.hx | 4 ++--
> 2 files changed, 52 insertions(+), 3 deletions(-)
>
> diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
> index 63256c7..8eaf0e8 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;
>
> static void filter_rewriter_flush(NetFilterState *nf)
> @@ -155,10 +157,25 @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf,
> ConnectionKey key;
> Packet *pkt;
> ssize_t size = iov_size(iov, iovcnt);
> + ssize_t vnet_hdr_len = 0;
> char *buf = g_malloc0(size);
>
> iov_to_buf(iov, iovcnt, 0, buf, size);
> - pkt = packet_new(buf, size, 0);
> +
> + if (s->vnet_hdr) {
> + if (nf->direction == NET_FILTER_DIRECTION_RX ||
> + nf->direction == NET_FILTER_DIRECTION_ALL) {
> + vnet_hdr_len = nf->netdev->vnet_hdr_len;
> + } else if (nf->direction == NET_FILTER_DIRECTION_TX) {
> + vnet_hdr_len = nf->netdev->peer->vnet_hdr_len;
> + } else {
> + error_report("filter-rewriter get vnet_hdr_len failed");
> + /* When error occurred we drop the packet */
> + return 1;
> + }
> + }
Similar issue as patch 02, and we can probably use a helper to avoid
duplicating codes.
Thanks
> +
> + pkt = packet_new(buf, size, vnet_hdr_len);
> g_free(buf);
>
> /*
> @@ -237,6 +254,37 @@ static void colo_rewriter_setup(NetFilterState *nf, Error **errp)
> s->incoming_queue = qemu_new_net_queue(qemu_netfilter_pass_to_next, nf);
> }
>
> +static bool filter_rewriter_get_vnet_hdr(Object *obj, Error **errp)
> +{
> + RewriterState *s = FILTER_COLO_REWRITER(obj);
> +
> + return s->vnet_hdr;
> +}
> +
> +static void filter_rewriter_set_vnet_hdr(Object *obj,
> + bool value,
> + Error **errp)
> +{
> + RewriterState *s = FILTER_COLO_REWRITER(obj);
> +
> + s->vnet_hdr = value;
> +}
> +
> +static void filter_rewriter_init(Object *obj)
> +{
> + RewriterState *s = FILTER_COLO_REWRITER(obj);
> +
> + /*
> + * The vnet_hdr is disabled by default, if you want to enable
> + * this option, you must enable all the option on related modules
> + * (like other filter or colo-compare).
> + */
> + s->vnet_hdr = 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 = NETFILTER_CLASS(oc);
> @@ -250,6 +298,7 @@ static const TypeInfo colo_rewriter_info = {
> .name = TYPE_FILTER_REWRITER,
> .parent = TYPE_NETFILTER,
> .class_init = colo_rewriter_class_init,
> + .instance_init = filter_rewriter_init,
> .instance_size = sizeof(RewriterState),
> };
>
> diff --git a/qemu-options.hx b/qemu-options.hx
> index fbfd604..8655842 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -4037,12 +4037,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.
>
> -@item -object filter-rewriter,id=@var{id},netdev=@var{netdevid},rewriter-mode=@var{mode}[,queue=@var{all|rx|tx}]
> +@item -object filter-rewriter,id=@var{id},netdev=@var{netdevid},rewriter-mode=@var{mode},queue=@var{all|rx|tx},[vnet_hdr_support]
>
> 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 have the vnet_hdr_support flag, we can parse packet with vnet header.
>
> usage:
> colo secondary:
next prev parent reply other threads:[~2017-06-09 6:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 9:55 [Qemu-devel] [PATCH V6 00/10] Add COLO-proxy virtio-net support Zhang Chen
2017-06-07 9:55 ` [Qemu-devel] [PATCH V6 01/10] net: Add vnet_hdr_len arguments in NetClientState Zhang Chen
2017-06-07 9:55 ` [Qemu-devel] [PATCH V6 02/10] net/filter-mirror.c: Make filter mirror support vnet support Zhang Chen
2017-06-09 6:08 ` Jason Wang
2017-06-12 9:27 ` Zhang Chen
2017-06-13 9:14 ` Jason Wang
2017-06-14 8:04 ` Zhang Chen
2017-06-15 4:31 ` Jason Wang
2017-06-15 8:10 ` Zhang Chen
2017-06-16 2:17 ` Jason Wang
2017-06-16 8:36 ` Zhang Chen
2017-06-07 9:55 ` [Qemu-devel] [PATCH V6 03/10] net/filter-mirror.c: Add new option to enable vnet support for filter-redirector Zhang Chen
2017-06-09 6:09 ` Jason Wang
2017-06-07 9:55 ` [Qemu-devel] [PATCH V6 04/10] net/net.c: Add vnet_hdr support in SocketReadState Zhang Chen
2017-06-09 6:15 ` Jason Wang
2017-06-07 9:55 ` [Qemu-devel] [PATCH V6 05/10] net/colo.c: Make vnet_hdr_len as packet property Zhang Chen
2017-06-07 9:55 ` [Qemu-devel] [PATCH V6 06/10] net/colo-compare.c: Make colo-compare support vnet_hdr_len Zhang Chen
2017-06-07 9:55 ` [Qemu-devel] [PATCH V6 07/10] net/colo.c: Add vnet packet parse feature in colo-proxy Zhang Chen
2017-06-07 9:55 ` [Qemu-devel] [PATCH V6 08/10] net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare Zhang Chen
2017-06-09 6:17 ` Jason Wang
2017-06-07 9:55 ` [Qemu-devel] [PATCH V6 09/10] net/filter-rewriter.c: Make filter-rewriter support vnet_hdr_len Zhang Chen
2017-06-09 6:20 ` Jason Wang [this message]
2017-06-07 9:55 ` [Qemu-devel] [PATCH V6 10/10] docs/colo-proxy.txt: Update colo-proxy usage of net driver with vnet_header Zhang Chen
2017-06-09 6:22 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c734e384-a0fe-0b08-2221-3d7a5842cb50@redhat.com \
--to=jasowang@redhat.com \
--cc=biannm@cn.fujitsu.com \
--cc=eddie.dong@intel.com \
--cc=lizhijian@cn.fujitsu.com \
--cc=qemu-devel@nongnu.org \
--cc=weifuqiang@huawei.com \
--cc=zhang.zhanghailiang@huawei.com \
--cc=zhangchen.fnst@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).