[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH V5 1/3] net/filter: Optimize transfer protocol for filter-mir
From: |
Jason Wang |
Subject: |
Re: [PATCH V5 1/3] net/filter: Optimize transfer protocol for filter-mirror/redirector |
Date: |
Mon, 1 Nov 2021 11:46:03 +0800 |
On Fri, Oct 29, 2021 at 4:08 PM Zhang, Chen <chen.zhang@intel.com> wrote:
>
>
>
> > -----Original Message-----
> > From: Jason Wang <jasowang@redhat.com>
> > Sent: Friday, October 29, 2021 11:11 AM
> > To: Zhang, Chen <chen.zhang@intel.com>
> > Cc: qemu-dev <qemu-devel@nongnu.org>; Markus Armbruster
> > <armbru@redhat.com>; Li Zhijian <lizhijian@cn.fujitsu.com>
> > Subject: Re: [PATCH V5 1/3] net/filter: Optimize transfer protocol for
> > filter-
> > mirror/redirector
> >
> >
> > 在 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.
>
> Yes, Current "vnet_hdr_support" default enabled, and vnet_hdr_len already
> forced from attached nf->netdev.
> Maybe we can introduce a new parameter "force_no_vnet_hdr" here to make the
> vnet_hdr_len always keep 0.
> If you think OK, I will update it in next version.
Let me explain, if I was not wrong:
"vnet_hdr_support" means whether or not to send vnet header length. If
vnet_hdr_support=false, we won't send the vnet header. This looks the
same as you "force_no_vent_hdr" above.
And my "force_vnet_hdr" seems duplicated with vnet_hdr_support=true.
So it looks to me we can leave the mirror code as is and just change
the compare? (depends on the mgmt to set a correct vnet_hdr_support)
Thanks
>
> Thanks
> Chen
>
> >
> > 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)
>