qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 V3 04/10] net/filter-mirror.c: Add filter-mirror and filter-redirector vnet support.
Date: Fri, 5 May 2017 17:25:37 +0800	[thread overview]
Message-ID: <cb6a8f58-f047-c11c-582c-82e0152ac0b3@redhat.com> (raw)
In-Reply-To: <13c41d79-09fe-26a9-d874-4ac5a942c15b@cn.fujitsu.com>



On 2017年05月05日 16:44, Zhang Chen wrote:
>
>
> On 05/03/2017 06:19 PM, Jason Wang wrote:
>>
>>
>> On 2017年05月03日 11:18, Zhang Chen wrote:
>>>
>>>
>>> On 05/02/2017 12:47 PM, Jason Wang wrote:
>>>>
>>>>
>>>> On 2017年04月28日 17:47, Zhang Chen wrote:
>>>>> In this patch, 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 | 28 +++++++++++++++++++++++-----
>>>>>   1 file changed, 23 insertions(+), 5 deletions(-)
>>>>>
>>>>> diff --git a/net/filter-mirror.c b/net/filter-mirror.c
>>>>> index 72fa7c2..bb9ecf3 100644
>>>>> --- a/net/filter-mirror.c
>>>>> +++ b/net/filter-mirror.c
>>>>> @@ -43,12 +43,14 @@ typedef struct MirrorState {
>>>>>       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;
>>>>> +    ssize_t vnet_hdr_len;
>>>>>       uint32_t len = 0;
>>>>>       char *buf;
>>>>>   @@ -58,14 +60,30 @@ 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;
>>>>> +    }
>>>>> +
>>>>> +    /*
>>>>> +     * We send vnet header len make other module(like colo-compare)
>>>>> +     * know how to parse net packet correctly.
>>>>> +     */
>>>>> +    if (qemu_get_using_vnet_hdr(nf->netdev)) {
>>>>> +        vnet_hdr_len = qemu_get_vnet_hdr_len(nf->netdev);
>>>>> +    } else {
>>>>> +        vnet_hdr_len = qemu_get_vnet_hdr_len(nf->netdev->peer);
>>>>> +    }
>>>>
>>>> Any reason to query peer here?
>>>
>>> That's depend on using NetClientState, If we using nf->netdev that 
>>> need to query,
>>> Otherwise we query nf->netdev->peer, then we can get the real 
>>> vnet_hdr_len in my test.
>>>
>>> Thanks
>>> Zhang Chen 
>>
>> Confused, I think nf->netdev won't be a nic?
>
> I don't know whether I fully understand.
> I think it's depend on the sender, we must query sender to get real 
> vnet_hdr_len ,
> like that in filter.c:
>
>         if (sender == nf->netdev) {
>             /* This packet is sent by netdev itself */
>             direction = NET_FILTER_DIRECTION_TX;
>         } else {
>             direction = NET_FILTER_DIRECTION_RX;
>         }
>
> Thanks
> Zhang Chen

The problem is nf->netdev->peer should be a nic. But we don't care about 
its vnet_hdr_len. Take virtio-net as an example, we only care about 
host_hdr_len, since guest will strip the part that host does not care.

Thanks

>
>
>>
>> Thanks
>>
>>
>> .
>>
>

  reply	other threads:[~2017-05-05  9:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28  9:47 [Qemu-devel] [PATCH V3 00/10] Add COLO-proxy virtio-net support Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 01/10] net: Add vnet_hdr_len related callback in NetClientInfo Zhang Chen
2017-05-02  5:46   ` Jason Wang
2017-05-03  3:08     ` Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 02/10] net/tap.c: Add tap_get_vnet_hdr_len and tap_get_using_vnet_hdr function Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 03/10] net/netmap.c: Add netmap_get_vnet_hdr_len function Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 04/10] net/filter-mirror.c: Add filter-mirror and filter-redirector vnet support Zhang Chen
2017-05-02  5:47   ` Jason Wang
2017-05-03  3:18     ` Zhang Chen
2017-05-03 10:19       ` Jason Wang
2017-05-05  8:44         ` Zhang Chen
2017-05-05  9:25           ` Jason Wang [this message]
2017-05-05  9:43             ` Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 05/10] net/net.c: Add vnet header length to SocketReadState Zhang Chen
2017-05-02  5:53   ` Jason Wang
2017-05-03  3:43     ` Zhang Chen
2017-05-03 10:42       ` Jason Wang
2017-05-08  3:47         ` Zhang Chen
2017-05-09  2:40           ` Jason Wang
2017-05-09  4:03             ` Zhang Chen
2017-05-09  5:36               ` Jason Wang
2017-05-09  6:59                 ` Zhang Chen
2017-05-09  7:36                   ` Jason Wang
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 06/10] tests/e1000e-test.c : change e1000e test case send data format Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 07/10] tests/virtio-net-test.c : change virtio-net test case iov " Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 08/10] net/colo-compare.c: Make colo-compare support vnet_hdr_len Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 09/10] net/colo.c: Add vnet packet parse feature in colo-proxy Zhang Chen
2017-04-28  9:47 ` [Qemu-devel] [PATCH V3 10/10] net/colo-compare.c: Add vnet packet's tcp/udp/icmp 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=cb6a8f58-f047-c11c-582c-82e0152ac0b3@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).