[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC 4/7] net/filter: Introduce a helper to add a
From: |
Jason Wang |
Subject: |
Re: [Qemu-devel] [PATCH RFC 4/7] net/filter: Introduce a helper to add a filter to the netdev |
Date: |
Mon, 25 Jan 2016 13:20:43 +0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 |
On 01/22/2016 04:36 PM, zhanghailiang wrote:
> Signed-off-by: zhanghailiang <address@hidden>
Commit log please.
> ---
> include/net/filter.h | 5 +++++
> net/filter.c | 63
> ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 68 insertions(+)
>
> diff --git a/include/net/filter.h b/include/net/filter.h
> index d797ee4..c7bd8f9 100644
> --- a/include/net/filter.h
> +++ b/include/net/filter.h
> @@ -81,4 +81,9 @@ static inline bool qemu_need_skip_netfilter(NetFilterState
> *nf)
>
> void netfilter_print_info(NetFilterState *nf, char *output_str, int size);
>
> +void netdev_add_filter(const char *netdev_id,
> + const char *filter_type,
> + const char *id,
> + Error **errp);
> +
> #endif /* QEMU_NET_FILTER_H */
> diff --git a/net/filter.c b/net/filter.c
> index f4933cc..4d96301 100644
> --- a/net/filter.c
> +++ b/net/filter.c
> @@ -16,6 +16,10 @@
> #include "qom/object_interfaces.h"
> #include "qemu/iov.h"
> #include "qapi/string-output-visitor.h"
> +#include "qapi/qmp/qdict.h"
> +#include "qapi/qmp-output-visitor.h"
> +#include "qapi/qmp-input-visitor.h"
> +#include "monitor/monitor.h"
>
> ssize_t qemu_netfilter_receive(NetFilterState *nf,
> NetFilterDirection direction,
> @@ -232,6 +236,65 @@ static void netfilter_complete(UserCreatable *uc, Error
> **errp)
> QTAILQ_INSERT_TAIL(&nf->netdev->filters, nf, next);
> }
>
> +/*
> +* This will be used by COLO or MC FT, for which they will need
> +* to buffer the packets of VM's net devices, Here we add a default
> +* buffer filter for each netdev. The name of default buffer filter is
> +* 'nop'
> +*/
> +void netdev_add_filter(const char *netdev_id,
> + const char *filter_type,
> + const char *id,
> + Error **errp)
> +{
> + QmpOutputVisitor *qov;
> + QmpInputVisitor *qiv;
> + Visitor *ov, *iv;
> + QObject *obj = NULL;
> + QDict *qdict;
> + void *dummy = NULL;
> + NetClientState *nc = qemu_find_netdev(netdev_id);
> + Error *err = NULL;
> +
> + /* FIXME: Not support multiple queues */
> + if (!nc || nc->queue_index > 1) {
> + return;
> + }
> + /* Not support vhost-net */
> + if (get_vhost_net(nc)) {
> + return;
> + }
> +
> + qov = qmp_output_visitor_new();
> + ov = qmp_output_get_visitor(qov);
> + visit_start_struct(ov, &dummy, NULL, NULL, 0, &err);
> + if (err) {
> + goto out;
> + }
> + visit_type_str(ov, &nc->name, "netdev", &err);
> + if (err) {
> + goto out;
> + }
> + visit_end_struct(ov, &err);
> + if (err) {
> + goto out;
> + }
> + obj = qmp_output_get_qobject(qov);
> + g_assert(obj != NULL);
> + qdict = qobject_to_qdict(obj);
> + qmp_output_visitor_cleanup(qov);
> +
> + qiv = qmp_input_visitor_new(obj);
> + iv = qmp_input_get_visitor(qiv);
> + object_add(filter_type, id, qdict, iv, &err);
> + qmp_input_visitor_cleanup(qiv);
> + qobject_decref(obj);
> +out:
> + if (err) {
> + error_propagate(errp, err);
> + }
> +}
> +
> static void netfilter_finalize(Object *obj)
> {
> NetFilterState *nf = NETFILTER(obj);
- [Qemu-devel] [PATCH RFC 7/7] net/filter: prevent the default filter to be deleted, (continued)
- [Qemu-devel] [PATCH RFC 7/7] net/filter: prevent the default filter to be deleted, zhanghailiang, 2016/01/22
- [Qemu-devel] [PATCH RFC 2/7] net/filter: Add a 'status' property for filter object, zhanghailiang, 2016/01/22
- [Qemu-devel] [PATCH RFC 1/7] net/filter: Fix the output information for command 'info network', zhanghailiang, 2016/01/22
- [Qemu-devel] [PATCH RFC 4/7] net/filter: Introduce a helper to add a filter to the netdev, zhanghailiang, 2016/01/22
- Re: [Qemu-devel] [PATCH RFC 4/7] net/filter: Introduce a helper to add a filter to the netdev,
Jason Wang <=
- [Qemu-devel] [PATCH RFC 3/7] net/filter: Skip the disabled filter when delivering packets, zhanghailiang, 2016/01/22
- [Qemu-devel] [PATCH RFC 5/7] filter-buffer: Accept zero interval, zhanghailiang, 2016/01/22
- [Qemu-devel] [PATCH RFC 6/7] net/filter: Add a default filter to each netdev, zhanghailiang, 2016/01/22