qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Yang Hongyang <yanghy@cn.fujitsu.com>, qemu-devel@nongnu.org
Cc: thuth@redhat.com, mrhines@linux.vnet.ibm.com,
	stefanha@redhat.com, zhang.zhanghailiang@huawei.com,
	lizhijian@cn.fujitsu.com
Subject: Re: [Qemu-devel] [PATCH v2 8/9] netfilter: add a netbuffer filter
Date: Fri, 31 Jul 2015 14:08:39 +0800	[thread overview]
Message-ID: <55BB10E7.4070407@redhat.com> (raw)
In-Reply-To: <1438316014-8369-9-git-send-email-yanghy@cn.fujitsu.com>



On 07/31/2015 12:13 PM, Yang Hongyang wrote:
> This filter is to buffer/release packets, this feature can be used
> when using MicroCheckpointing, or other Remus like VM FT solutions, you
> can also use it to simulate the network delay.
> It has an interval option, if supplied, this filter will release
> packets by interval.
>
> Usage:
>  -netdev tap,id=bn0
>  -netfilter buffer,id=f0,netdev=bn0,chain=in,interval=1000
>
> NOTE:
>  the scale of interval is microsecond.
>
> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
> ---
>  net/Makefile.objs   |   1 +
>  net/filter-buffer.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  net/filter.c        |   2 +
>  net/filters.h       |  17 ++++++
>  qapi-schema.json    |  18 +++++-
>  5 files changed, 197 insertions(+), 1 deletion(-)
>  create mode 100644 net/filter-buffer.c
>  create mode 100644 net/filters.h
>
> diff --git a/net/Makefile.objs b/net/Makefile.objs
> index 914aec0..5fa2f97 100644
> --- a/net/Makefile.objs
> +++ b/net/Makefile.objs
> @@ -14,3 +14,4 @@ common-obj-$(CONFIG_SLIRP) += slirp.o
>  common-obj-$(CONFIG_VDE) += vde.o
>  common-obj-$(CONFIG_NETMAP) += netmap.o
>  common-obj-y += filter.o
> +common-obj-y += filter-buffer.o
> diff --git a/net/filter-buffer.c b/net/filter-buffer.c
> new file mode 100644
> index 0000000..7f2b050
> --- /dev/null
> +++ b/net/filter-buffer.c
> @@ -0,0 +1,160 @@
> +/*
> + * Copyright (c) 2015 FUJITSU LIMITED
> + * Author: Yang Hongyang <yanghy@cn.fujitsu.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or
> + * later.  See the COPYING file in the top-level directory.
> + */
> +
> +#include "net/filter.h"
> +#include "net/queue.h"
> +#include "filters.h"
> +#include "qemu-common.h"
> +#include "qemu/error-report.h"
> +#include "qemu/main-loop.h"
> +#include "qemu/timer.h"
> +#include "qemu/iov.h"
> +
> +typedef struct FILTERBUFFERState {
> +    NetFilterState nf;
> +    NetQueue *incoming_queue;
> +    NetQueue *inflight_queue;
> +    QEMUBH *flush_bh;
> +    int64_t interval;
> +    QEMUTimer release_timer;
> +} FILTERBUFFERState;
> +
> +static void packet_send_completed(NetClientState *nc, ssize_t len)
> +{
> +    return;
> +}
> +
> +static void filter_buffer_flush(NetFilterState *nf)
> +{
> +    FILTERBUFFERState *s = DO_UPCAST(FILTERBUFFERState, nf, nf);
> +    NetQueue *queue = s->inflight_queue;
> +    NetPacket *packet;
> +
> +    while (queue && !QTAILQ_EMPTY(&queue->packets)) {
> +        packet = QTAILQ_FIRST(&queue->packets);
> +        QTAILQ_REMOVE(&queue->packets, packet, entry);
> +        queue->nq_count--;
> +
> +        qemu_net_queue_send(packet->sender->peer->incoming_queue,
> +                            packet->sender,
> +                            packet->flags,
> +                            packet->data,
> +                            packet->size,
> +                            packet->sent_cb);

Need to check peer since it may be NULL e.g after it was deleted. And we
probably need to queue the packet into next filter.

  reply	other threads:[~2015-07-31  6:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31  4:13 [Qemu-devel] [PATCH v2 0/9] For QEMU 2.5: Add a netfilter object and netbuffer filter Yang Hongyang
2015-07-31  4:13 ` [Qemu-devel] [PATCH v2 1/9] net: add a new object netfilter Yang Hongyang
2015-07-31  4:13 ` [Qemu-devel] [PATCH v2 2/9] init/cleanup of netfilter object Yang Hongyang
2015-07-31  4:13 ` [Qemu-devel] [PATCH v2 3/9] netfilter: add netfilter_{add|del} commands Yang Hongyang
2015-07-31  4:13 ` [Qemu-devel] [PATCH v2 4/9] net: add/remove filters from network backend Yang Hongyang
2015-07-31  4:13 ` [Qemu-devel] [PATCH v2 5/9] netfilter: hook packets before net queue send Yang Hongyang
2015-07-31  6:06   ` Jason Wang
2015-07-31  8:24     ` Yang Hongyang
2015-07-31  9:09       ` Jason Wang
2015-07-31  9:58         ` Yang Hongyang
2015-07-31  4:13 ` [Qemu-devel] [PATCH v2 6/9] net/queue: export qemu_net_queue_append_iov Yang Hongyang
2015-07-31  4:13 ` [Qemu-devel] [PATCH v2 7/9] move out net queue structs define Yang Hongyang
2015-07-31  4:13 ` [Qemu-devel] [PATCH v2 8/9] netfilter: add a netbuffer filter Yang Hongyang
2015-07-31  6:08   ` Jason Wang [this message]
2015-07-31  8:30     ` Yang Hongyang
2015-07-31  9:15       ` Jason Wang
2015-07-31 18:58   ` Dr. David Alan Gilbert
2015-08-03  1:10     ` Yang Hongyang
2015-07-31  4:13 ` [Qemu-devel] [PATCH v2 9/9] filter/buffer: update command description and help Yang Hongyang
2015-07-31  5:58 ` [Qemu-devel] [PATCH v2 0/9] For QEMU 2.5: Add a netfilter object and netbuffer filter Jason Wang
2015-07-31  8:20   ` Yang Hongyang
2015-07-31  9:08     ` Jason Wang
2015-07-31  9:51       ` Yang Hongyang

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=55BB10E7.4070407@redhat.com \
    --to=jasowang@redhat.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=mrhines@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    --cc=yanghy@cn.fujitsu.com \
    --cc=zhang.zhanghailiang@huawei.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).