From: Jason Wang <jasowang@redhat.com>
To: Yang Hongyang <yanghy@cn.fujitsu.com>, qemu-devel@nongnu.org
Cc: thuth@redhat.com, zhang.zhanghailiang@huawei.com,
lizhijian@cn.fujitsu.com, eddie.dong@intel.com,
mrhines@linux.vnet.ibm.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v4 06/11] netfilter: add an API to pass the packet to next filter
Date: Thu, 06 Aug 2015 15:16:19 +0800 [thread overview]
Message-ID: <55C309C3.3050401@redhat.com> (raw)
In-Reply-To: <1438677044-13030-7-git-send-email-yanghy@cn.fujitsu.com>
On 08/04/2015 04:30 PM, Yang Hongyang wrote:
> add an API qemu_netfilter_pass_to_next_iov() to pass the packet
> to next filter, and a wrapper qemu_netfilter_pass_to_next().
>
> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
> ---
> include/net/filter.h | 12 ++++++++++++
> net/filter.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 55 insertions(+)
>
> diff --git a/include/net/filter.h b/include/net/filter.h
> index c146be2..867d5aa 100644
> --- a/include/net/filter.h
> +++ b/include/net/filter.h
> @@ -54,4 +54,16 @@ void qemu_del_net_filter(NetFilterState *nf);
> void netfilter_add(QemuOpts *opts, Error **errp);
> void qmp_netfilter_add(QDict *qdict, QObject **ret, Error **errp);
>
> +/* pass the packet to the next filter */
> +void qemu_netfilter_pass_to_next_iov(NetFilterState *nf,
> + NetClientState *sender,
> + unsigned flags,
> + const struct iovec *iov,
> + int iovcnt);
> +void qemu_netfilter_pass_to_next(NetFilterState *nf,
> + NetClientState *sender,
> + unsigned flags,
> + const uint8_t *data,
> + size_t size);
sender, flags, data and size were all could be inferred from packet. How
about just have a packet parameter?
> +
> #endif /* QEMU_NET_FILTER_H */
> diff --git a/net/filter.c b/net/filter.c
> index 24ec4e1..166b851 100644
> --- a/net/filter.c
> +++ b/net/filter.c
> @@ -14,9 +14,11 @@
> #include "qapi/dealloc-visitor.h"
> #include "qemu/config-file.h"
> #include "qmp-commands.h"
> +#include "qemu/iov.h"
>
> #include "net/filter.h"
> #include "net/net.h"
> +#include "net/queue.h"
>
> static QTAILQ_HEAD(, NetFilterState) net_filters;
>
> @@ -130,6 +132,47 @@ void qmp_netfilter_del(const char *id, Error **errp)
> qemu_opts_del(opts);
> }
>
> +void qemu_netfilter_pass_to_next_iov(NetFilterState *nf,
> + NetClientState *sender,
> + unsigned flags,
> + const struct iovec *iov,
> + int iovcnt)
> +{
> + int ret = 0;
> + ssize_t size = iov_size(iov, iovcnt);
> + NetFilterState *next = QTAILQ_NEXT(nf, next);
> +
> + while (next) {
> + if (next->chain == nf->chain || next->chain == NET_FILTER_ALL) {
> + ret = next->info->receive_iov(next, sender, flags, iov, iovcnt);
> + if (ret == size) {
> + return;
> + }
> + }
> + next = QTAILQ_NEXT(next, next);
> + }
> +
> + /* we have gone through all filters, pass it to receiver */
> + if (sender && sender->peer) {
> + qemu_net_queue_send_iov(sender->peer->incoming_queue, sender, flags,
> + iov, iovcnt, NULL);
> + }
> +}
> +
> +void qemu_netfilter_pass_to_next(NetFilterState *nf,
> + NetClientState *sender,
> + unsigned flags,
> + const uint8_t *data,
> + size_t size)
> +{
> + struct iovec iov = {
> + .iov_base = (void *)data,
> + .iov_len = size
> + };
> +
> + return qemu_netfilter_pass_to_next_iov(nf, sender, flags, &iov, 1);
> +}
> +
> typedef int (NetFilterInit)(const NetFilterOptions *opts,
> const char *name, int chain,
> NetClientState *netdev, Error **errp);
next prev parent reply other threads:[~2015-08-06 7:16 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 8:30 [Qemu-devel] [PATCH v4 00/11] For QEMU 2.5: Add a netfilter object and netbuffer filter Yang Hongyang
2015-08-04 8:30 ` [Qemu-devel] [PATCH v4 01/11] net: add a new object netfilter Yang Hongyang
2015-08-04 8:30 ` [Qemu-devel] [PATCH v4 02/11] init/cleanup of netfilter object Yang Hongyang
2015-08-06 7:07 ` Jason Wang
2015-08-06 7:22 ` Yang Hongyang
2015-08-06 7:29 ` Jason Wang
2015-08-06 7:35 ` Yang Hongyang
2015-08-06 7:43 ` Jason Wang
2015-08-06 7:50 ` Yang Hongyang
2015-08-06 7:53 ` Jason Wang
2015-08-04 8:30 ` [Qemu-devel] [PATCH v4 03/11] netfilter: add netfilter_{add|del} commands Yang Hongyang
2015-08-04 8:30 ` [Qemu-devel] [PATCH v4 04/11] net: delete netfilter object when delete netdev Yang Hongyang
2015-08-06 7:09 ` Jason Wang
2015-08-06 7:22 ` Yang Hongyang
2015-08-06 8:44 ` Yang Hongyang
2015-08-06 9:14 ` Jason Wang
2015-08-04 8:30 ` [Qemu-devel] [PATCH v4 05/11] netfilter: hook packets before net queue send Yang Hongyang
2015-08-06 7:13 ` Jason Wang
2015-08-06 7:28 ` Yang Hongyang
2015-08-06 7:37 ` Jason Wang
2015-08-06 7:58 ` Yang Hongyang
2015-08-04 8:30 ` [Qemu-devel] [PATCH v4 06/11] netfilter: add an API to pass the packet to next filter Yang Hongyang
2015-08-06 7:16 ` Jason Wang [this message]
2015-08-06 7:29 ` Yang Hongyang
2015-08-04 8:30 ` [Qemu-devel] [PATCH v4 07/11] net/queue: export qemu_net_queue_append_iov Yang Hongyang
2015-08-04 8:30 ` [Qemu-devel] [PATCH v4 08/11] move out net queue structs define Yang Hongyang
2015-08-04 8:30 ` [Qemu-devel] [PATCH v4 09/11] netfilter: add a netbuffer filter Yang Hongyang
2015-08-06 7:21 ` Jason Wang
2015-08-06 8:19 ` Yang Hongyang
2015-08-06 9:09 ` Jason Wang
2015-08-06 9:23 ` Yang Hongyang
2015-08-06 9:35 ` Jason Wang
2015-08-04 8:30 ` [Qemu-devel] [PATCH v4 10/11] filter/buffer: update command description and help Yang Hongyang
2015-08-06 7:22 ` Jason Wang
2015-08-06 7:31 ` Yang Hongyang
2015-08-06 7:39 ` Jason Wang
2015-08-04 8:30 ` [Qemu-devel] [PATCH v4 11/11] tests: add test cases for netfilter object 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=55C309C3.3050401@redhat.com \
--to=jasowang@redhat.com \
--cc=eddie.dong@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.