[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V2] net/filter-mirror: Change filter_mirror_send
From: |
Jason Wang |
Subject: |
Re: [Qemu-devel] [PATCH V2] net/filter-mirror: Change filter_mirror_send interface |
Date: |
Wed, 16 Mar 2016 12:12:22 +0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 |
On 03/15/2016 06:02 PM, Zhang Chen wrote:
> Change filter_mirror_send interface to make it easier
> to used by other filter
>
> Signed-off-by: Zhang Chen <address@hidden>
> Signed-off-by: Wen Congyang <address@hidden>
> Signed-off-by: Li Zhijian <address@hidden>
> ---
> net/filter-mirror.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/net/filter-mirror.c b/net/filter-mirror.c
> index 2e2ed27..1b1ec16 100644
> --- a/net/filter-mirror.c
> +++ b/net/filter-mirror.c
> @@ -34,11 +34,10 @@ typedef struct MirrorState {
> CharDriverState *chr_out;
> } MirrorState;
>
> -static int filter_mirror_send(NetFilterState *nf,
> +static int filter_mirror_send(CharDriverState *chr_out,
> const struct iovec *iov,
> int iovcnt)
> {
> - MirrorState *s = FILTER_MIRROR(nf);
> int ret = 0;
> ssize_t size = 0;
> uint32_t len = 0;
> @@ -50,14 +49,14 @@ static int filter_mirror_send(NetFilterState *nf,
> }
>
> len = htonl(size);
> - ret = qemu_chr_fe_write_all(s->chr_out, (uint8_t *)&len, sizeof(len));
> + ret = qemu_chr_fe_write_all(chr_out, (uint8_t *)&len, sizeof(len));
> if (ret != sizeof(len)) {
> goto err;
> }
>
> buf = g_malloc(size);
> iov_to_buf(iov, iovcnt, 0, buf, size);
> - ret = qemu_chr_fe_write_all(s->chr_out, (uint8_t *)buf, size);
> + ret = qemu_chr_fe_write_all(chr_out, (uint8_t *)buf, size);
> g_free(buf);
> if (ret != size) {
> goto err;
> @@ -76,9 +75,10 @@ static ssize_t filter_mirror_receive_iov(NetFilterState
> *nf,
> int iovcnt,
> NetPacketSent *sent_cb)
> {
> + MirrorState *s = FILTER_MIRROR(nf);
> int ret;
>
> - ret = filter_mirror_send(nf, iov, iovcnt);
> + ret = filter_mirror_send(s->chr_out, iov, iovcnt);
> if (ret) {
> error_report("filter_mirror_send failed(%s)", strerror(-ret));
> }
Applied to -net.
Thanks