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>,
Li Zhijian <lizhijian@cn.fujitsu.com>,
weifuqiang <weifuqiang@huawei.com>,
"eddie . dong" <eddie.dong@intel.com>,
bian naimeng <biannm@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH V5 2/9] net/filter-mirror.c: Make filter mirror support vnet support.
Date: Fri, 26 May 2017 13:25:19 +0800 [thread overview]
Message-ID: <1550e79d-c657-6e9b-d7b0-39ee94c8f7af@redhat.com> (raw)
In-Reply-To: <f9344c1f-fa0a-4745-bf51-658c37d1d53e@cn.fujitsu.com>
On 2017年05月25日 20:55, Zhang Chen wrote:
>
>
> On 05/25/2017 02:04 PM, Jason Wang wrote:
>>
>>
>> On 2017年05月23日 22:20, Zhang Chen wrote:
>>> We add the vnet_hdr option for filter-mirror, default is disable.
>>> If you use virtio-net-pci net driver, please enable it.
>>> You can use it for example:
>>> -object
>>> filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0,vnet_hdr=on
>>>
>>> If vnet_hdr=on we change the send packet format from
>>> struct {int size; const uint8_t buf[];} to {int size; int
>>> vnet_hdr_len; const uint8_t buf[];}.
>>> make other module(like colo-compare) know how to parse net packet
>>> correctly.
>>>
>>> Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
>>> ---
>>> net/filter-mirror.c | 73
>>> +++++++++++++++++++++++++++++++++++++++++++++++++----
>>> qemu-options.hx | 5 ++--
>>> 2 files changed, 70 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/net/filter-mirror.c b/net/filter-mirror.c
>>> index 72fa7c2..8df0be6 100644
>>> --- a/net/filter-mirror.c
>>> +++ b/net/filter-mirror.c
>>> @@ -38,15 +38,17 @@ typedef struct MirrorState {
>>> NetFilterState parent_obj;
>>> char *indev;
>>> char *outdev;
>>> + bool vnet_hdr;
>>> CharBackend chr_in;
>>> CharBackend chr_out;
>>> SocketReadState rs;
>>> } MirrorState;
>>> -static int filter_mirror_send(CharBackend *chr_out,
>>> +static int filter_mirror_send(MirrorState *s,
>>> const struct iovec *iov,
>>> int iovcnt)
>>> {
>>> + NetFilterState *nf = NETFILTER(s);
>>> int ret = 0;
>>> ssize_t size = 0;
>>> uint32_t len = 0;
>>> @@ -58,14 +60,42 @@ static int filter_mirror_send(CharBackend *chr_out,
>>> }
>>> len = htonl(size);
>>> - ret = qemu_chr_fe_write_all(chr_out, (uint8_t *)&len,
>>> sizeof(len));
>>> + ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len,
>>> sizeof(len));
>>> if (ret != sizeof(len)) {
>>> 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;
>>> +
>>> + /*
>>> + * In anytime, nf->netdev and nf->netdev->peer both have a
>>> vnet_hdr_len,
>>> + * Here we just find out which is we need. When filter set
>>> RX or TX
>>> + * that the real vnet_hdr_len are different.
>>> + */
>>> + if (nf->netdev->using_vnet_hdr) {
>>> + vnet_hdr_len = nf->netdev->vnet_hdr_len;
>>> + } else if (nf->netdev->peer->using_vnet_hdr) {
>>> + vnet_hdr_len = nf->netdev->peer->vnet_hdr_len;
>>
>> Rethink about this, looks like what we really want is:
>>
>> - For tx direction, only check nf->netdev->vnet_hdr_len,
>> - For rx direction, only check nf->netdev->peer->vnet_hdr_len
>
> Agree, So do you means we should remove the using_vnet_hdr related
> codes then just
> use the nf->direction to choice which we need check?
>
> Thanks
> Zhang Chen
Maybe.
Thanks
next prev parent reply other threads:[~2017-05-26 5:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-23 14:20 [Qemu-devel] [PATCH V5 0/9] Add COLO-proxy virtio-net support Zhang Chen
2017-05-23 14:20 ` [Qemu-devel] [PATCH V5 1/9] net: Add vnet_hdr_len related arguments in NetClientState Zhang Chen
2017-05-23 14:24 ` Zhang Chen
2017-05-23 14:20 ` [Qemu-devel] [PATCH V5 2/9] net/filter-mirror.c: Make filter mirror support vnet support Zhang Chen
2017-05-25 6:04 ` Jason Wang
2017-05-25 12:55 ` Zhang Chen
2017-05-26 5:25 ` Jason Wang [this message]
2017-05-23 14:20 ` [Qemu-devel] [PATCH V5 3/9] net/filter-mirror.c: Add new option to enable vnet support for filter-redirector Zhang Chen
2017-05-25 6:10 ` Jason Wang
2017-05-25 12:58 ` Zhang Chen
2017-05-26 5:30 ` Jason Wang
2017-06-01 7:18 ` Zhang Chen
2017-05-23 14:20 ` [Qemu-devel] [PATCH V5 4/9] net/net.c: Add vnet_hdr support in SocketReadState Zhang Chen
2017-05-23 14:20 ` [Qemu-devel] [PATCH V5 5/9] net/colo.c: Make vnet_hdr_len as packet property Zhang Chen
2017-05-23 14:20 ` [Qemu-devel] [PATCH V5 6/9] net/colo-compare.c: Make colo-compare support vnet_hdr_len Zhang Chen
2017-05-25 6:22 ` Jason Wang
2017-05-25 13:18 ` Zhang Chen
2017-05-26 5:35 ` Jason Wang
2017-05-26 5:36 ` Jason Wang
2017-06-01 14:11 ` Zhang Chen
2017-05-23 14:20 ` [Qemu-devel] [PATCH V5 7/9] net/colo.c: Add vnet packet parse feature in colo-proxy Zhang Chen
2017-05-23 14:20 ` [Qemu-devel] [PATCH V5 8/9] net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare Zhang Chen
2017-05-23 14:20 ` [Qemu-devel] [PATCH V5 9/9] net/filter-rewriter.c: Make filter-rewriter support vnet_hdr_len 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=1550e79d-c657-6e9b-d7b0-39ee94c8f7af@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).