From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: Thomas Huth <thuth@redhat.com>, qemu-devel@nongnu.org
Cc: zhang.zhanghailiang@huawei.com, lizhijian@cn.fujitsu.com,
jasowang@redhat.com, mrhines@linux.vnet.ibm.com,
stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v7 RESEND 02/11] init/cleanup of netfilter object
Date: Tue, 25 Aug 2015 09:31:28 +0800 [thread overview]
Message-ID: <55DBC570.1030509@cn.fujitsu.com> (raw)
In-Reply-To: <55D9D5F1.6020107@redhat.com>
On 08/23/2015 10:17 PM, Thomas Huth wrote:
> On 21/08/15 00:43, Yang Hongyang wrote:
>> QTAILQ_ENTRY global_list but used by filter layer, so that we can
>> manage all filters together.
>> QTAILQ_ENTRY next used by netdev, filter belongs to the specific netdev is
>> in this queue.
>> This is mostly the same with init/cleanup of netdev object.
>>
>> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
>> ---
>> v7: add check for vhost
> [...]
>> diff --git a/net/filter.c b/net/filter.c
>> index 4e40f08..9183cd8 100644
>> --- a/net/filter.c
>> +++ b/net/filter.c
>> @@ -6,10 +6,158 @@
>> */
>>
>> #include "qemu-common.h"
>> +#include "qapi-visit.h"
>> +#include "qapi/qmp/qerror.h"
>> +#include "qemu/error-report.h"
>> +#include "qapi-visit.h"
>> +#include "qapi/opts-visitor.h"
>> +#include "qapi/dealloc-visitor.h"
>> +#include "qemu/config-file.h"
>> +
>> #include "net/filter.h"
>> +#include "net/net.h"
>
> Don't you need to include "net/vhost_net.h" here, too, to get the
> prototype of get_vhost_nest() for using it in the function below?
Yes, it's wired that this patchset can be successfuly bulid on my test
machine...will add in the next version. thank you.
>
>> +static int net_filter_init1(const NetFilter *netfilter, Error **errp)
>> +{
>> + NetClientState *ncs[MAX_QUEUE_NUM];
>> + const char *name = netfilter->id;
>> + const char *netdev_id = netfilter->netdev;
>> + const char *chain_str = NULL;
>> + const NetFilterOptions *opts = netfilter->opts;
>> + int chain, queues, i;
>> +
>> + if (!net_filter_init_fun[opts->kind]) {
>> + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type",
>> + "a net filter type");
>> + return -1;
>> + }
>> +
>> + if (netfilter->has_chain) {
>> + chain_str = netfilter->chain;
>> + if (!strcmp(chain_str, "in")) {
>> + chain = NET_FILTER_IN;
>> + } else if (!strcmp(chain_str, "out")) {
>> + chain = NET_FILTER_OUT;
>> + } else if (!strcmp(chain_str, "all")) {
>> + chain = NET_FILTER_ALL;
>> + } else {
>> + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "chain",
>> + "netfilter chain (in/out/all)");
>> + return -1;
>> + }
>> + } else {
>> + /* default */
>> + chain = NET_FILTER_ALL;
>> + }
>> +
>> + queues = qemu_find_net_clients_except(netdev_id, ncs,
>> + NET_CLIENT_OPTIONS_KIND_NIC,
>> + MAX_QUEUE_NUM);
>> + if (queues < 1) {
>> + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "netdev",
>> + "a network backend id");
>> + return -1;
>> + }
>> +
>> + if (get_vhost_net(ncs[0])) {
>> + error_setg(errp, "vhost is not supported");
>> + return -1;
>> + }
>> +
>> + for (i = 0; i < queues; i++) {
>> + if (net_filter_init_fun[opts->kind](opts, name,
>> + chain, ncs[i], errp) < 0) {
>> + if (errp && !*errp) {
>> + error_setg(errp, QERR_DEVICE_INIT_FAILED,
>> + NetFilterOptionsKind_lookup[opts->kind]);
>> + }
>> + return -1;
>> + }
>> + }
>> +
>> + return 0;
>> +}
>
> Thomas
>
> .
>
--
Thanks,
Yang.
next prev parent reply other threads:[~2015-08-25 1:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-21 4:43 [Qemu-devel] [PATCH v7 RESEND 00/11] Add a netfilter object and netbuffer filter Yang Hongyang
2015-08-21 4:43 ` [Qemu-devel] [PATCH v7 RESEND 01/11] net: add a new object netfilter Yang Hongyang
2015-08-21 4:43 ` [Qemu-devel] [PATCH v7 RESEND 02/11] init/cleanup of netfilter object Yang Hongyang
2015-08-23 14:17 ` Thomas Huth
2015-08-25 1:31 ` Yang Hongyang [this message]
2015-08-21 4:43 ` [Qemu-devel] [PATCH v7 RESEND 03/11] netfilter: add netfilter_{add|del} commands Yang Hongyang
2015-08-23 20:10 ` Thomas Huth
2015-08-21 4:43 ` [Qemu-devel] [PATCH v7 RESEND 04/11] netfilter: hook packets before net queue send Yang Hongyang
2015-08-21 4:43 ` [Qemu-devel] [PATCH v7 RESEND 05/11] move out net queue structs define Yang Hongyang
2015-08-21 4:43 ` [Qemu-devel] [PATCH v7 RESEND 06/11] netfilter: add an API to pass the packet to next filter Yang Hongyang
2015-08-21 4:43 ` [Qemu-devel] [PATCH v7 RESEND 07/11] netfilter: print filter info associate with the netdev Yang Hongyang
2015-08-21 4:43 ` [Qemu-devel] [PATCH v7 RESEND 08/11] net/queue: export qemu_net_queue_append_iov Yang Hongyang
2015-08-21 4:43 ` [Qemu-devel] [PATCH v7 RESEND 09/11] netfilter: add a netbuffer filter Yang Hongyang
2015-08-21 4:43 ` [Qemu-devel] [PATCH v7 RESEND 10/11] filter/buffer: update command description and help Yang Hongyang
2015-08-23 20:24 ` Thomas Huth
2015-08-25 1:32 ` Yang Hongyang
2015-08-21 4:43 ` [Qemu-devel] [PATCH v7 RESEND 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=55DBC570.1030509@cn.fujitsu.com \
--to=yanghy@cn.fujitsu.com \
--cc=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=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.