qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Zhang Chen <chen.zhang@intel.com>
Cc: qemu-dev <qemu-devel@nongnu.org>,
	Li Zhijian <lizhijian@cn.fujitsu.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH V5 1/3] net/filter: Optimize transfer protocol for filter-mirror/redirector
Date: Fri, 29 Oct 2021 11:11:23 +0800	[thread overview]
Message-ID: <c603b048-1cee-1396-811d-8be857aa932b@redhat.com> (raw)
In-Reply-To: <20211028090556.3168043-2-chen.zhang@intel.com>


在 2021/10/28 下午5:05, Zhang Chen 写道:
> Make the vnet header a necessary part of filter transfer protocol.
> It make other modules(like another filter-redirector,colo-compare...)
> know how to parse net packet correctly. If local device is not the
> virtio-net-pci, vnet_hdr_len will be 0.
>
> Signed-off-by: Zhang Chen <chen.zhang@intel.com>
> ---
>   net/filter-mirror.c | 34 ++++++++++++++++------------------
>   1 file changed, 16 insertions(+), 18 deletions(-)
>
> diff --git a/net/filter-mirror.c b/net/filter-mirror.c
> index f20240cc9f..24d3e498e9 100644
> --- a/net/filter-mirror.c
> +++ b/net/filter-mirror.c
> @@ -39,6 +39,7 @@ struct MirrorState {
>       CharBackend chr_in;
>       CharBackend chr_out;
>       SocketReadState rs;
> +    /* Keep compatibility for the management layer */
>       bool vnet_hdr;
>   };
>   
> @@ -48,7 +49,7 @@ static int filter_send(MirrorState *s,
>   {
>       NetFilterState *nf = NETFILTER(s);
>       int ret = 0;
> -    ssize_t size = 0;
> +    ssize_t size = 0, vnet_hdr_len = 0;
>       uint32_t len = 0;
>       char *buf;
>   
> @@ -63,21 +64,18 @@ static int filter_send(MirrorState *s,
>           goto err;
>       }
>   
> -    if (s->vnet_hdr) {
> -        /*
> -         * If vnet_hdr = 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 = nf->netdev->vnet_hdr_len;
> +    /*
> +     * The vnet header is the necessary part of filter transfer protocol.
> +     * It make other module(like colo-compare) know how to parse net
> +     * packet correctly. If device is not the virtio-net-pci,
> +     * vnet_hdr_len will be 0.
> +     */
> +    vnet_hdr_len = nf->netdev->vnet_hdr_len;
>   
> -        len = htonl(vnet_hdr_len);
> -        ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));
> -        if (ret != sizeof(len)) {
> -            goto err;
> -        }
> +    len = htonl(vnet_hdr_len);
> +    ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));


I wonder if we need to introduce new parameter, e.g force_vnet_hdr here, 
then we can always send vnet_hdr when it is enabled.

Otherwise the "vnet_hdr_support" seems meaningless.

Thanks


> +    if (ret != sizeof(len)) {
> +        goto err;
>       }
>   
>       buf = g_malloc(size);
> @@ -252,7 +250,7 @@ static void filter_redirector_setup(NetFilterState *nf, Error **errp)
>           }
>       }
>   
> -    net_socket_rs_init(&s->rs, redirector_rs_finalize, s->vnet_hdr);
> +    net_socket_rs_init(&s->rs, redirector_rs_finalize, true);
>   
>       if (s->indev) {
>           chr = qemu_chr_find(s->indev);
> @@ -406,14 +404,14 @@ static void filter_mirror_init(Object *obj)
>   {
>       MirrorState *s = FILTER_MIRROR(obj);
>   
> -    s->vnet_hdr = false;
> +    s->vnet_hdr = true;
>   }
>   
>   static void filter_redirector_init(Object *obj)
>   {
>       MirrorState *s = FILTER_REDIRECTOR(obj);
>   
> -    s->vnet_hdr = false;
> +    s->vnet_hdr = true;
>   }
>   
>   static void filter_mirror_fini(Object *obj)



  reply	other threads:[~2021-10-29  3:13 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28  9:05 [PATCH V5 0/3] net/filter: Optimize filters vnet_hdr support Zhang Chen
2021-10-28  9:05 ` [PATCH V5 1/3] net/filter: Optimize transfer protocol for filter-mirror/redirector Zhang Chen
2021-10-29  3:11   ` Jason Wang [this message]
2021-10-29  8:08     ` Zhang, Chen
2021-11-01  3:46       ` Jason Wang
2021-11-01  7:15         ` Zhang, Chen
2021-11-04  5:37           ` Zhang, Chen
2021-11-05  3:16             ` Jason Wang
2021-11-05  3:27               ` Zhang, Chen
2021-11-05  4:03                 ` Jason Wang
2021-11-05  5:29                   ` Zhang, Chen
2021-11-05  6:10                     ` Markus Armbruster
2021-11-05  8:30                     ` Jason Wang
2021-11-05  8:43                       ` Zhang, Chen
2021-11-08  2:41                         ` Jason Wang
2021-11-08  2:50                           ` Zhang, Chen
2021-11-09  6:42                             ` Jason Wang
2021-11-09  7:20                               ` Zhang, Chen
2021-11-09  7:26                                 ` Jason Wang
2021-11-09  7:31                                   ` Zhang, Chen
2021-11-09  7:42                                     ` Jason Wang
2021-11-09  7:47                                       ` Zhang, Chen
2021-11-10  2:31                                 ` Zhang, Chen
2021-10-28  9:05 ` [PATCH V5 2/3] net/filter: Optimize transfer protocol for filter-rewriter Zhang Chen
2021-10-28  9:05 ` [PATCH V5 3/3] net/colo-compare.c: Optimize transfer protocol for colo-compare Zhang Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c603b048-1cee-1396-811d-8be857aa932b@redhat.com \
    --to=jasowang@redhat.com \
    --cc=armbru@redhat.com \
    --cc=chen.zhang@intel.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    /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).