qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v8 07/11] netfilter: print filter info associate


From: Thomas Huth
Subject: Re: [Qemu-devel] [PATCH v8 07/11] netfilter: print filter info associate with the netdev
Date: Thu, 27 Aug 2015 16:46:46 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0

On 26/08/15 11:59, Yang Hongyang wrote:
> From: Yang Hongyang <address@hidden>
> 
> When execute "info network", print filter info also.
> current info printed is simple, can add more info later.
> 
> Signed-off-by: Yang Hongyang <address@hidden>
> ---
> v7: initial patch
> ---
>  include/net/filter.h |  1 +
>  net/filter.c         | 22 ++++++++++++++++++++++
>  net/net.c            | 11 +++++++++++
>  3 files changed, 34 insertions(+)
> 
> diff --git a/include/net/filter.h b/include/net/filter.h
> index 9278d40..188ecb1 100644
> --- a/include/net/filter.h
> +++ b/include/net/filter.h
> @@ -56,6 +56,7 @@ NetFilterState *qemu_new_net_filter(NetFilterInfo *info,
>  void qemu_del_net_filter(NetFilterState *nf);
>  void netfilter_add(QemuOpts *opts, Error **errp);
>  void qmp_netfilter_add(QDict *qdict, QObject **ret, Error **errp);
> +const char *qemu_netfilter_get_chain_str(int chain);
>  
>  /* pass the packet to the next filter */
>  ssize_t qemu_netfilter_pass_to_next(NetFilterState *nf, NetPacket *packet);
> diff --git a/net/filter.c b/net/filter.c
> index 44c17b0..76e12ea 100644
> --- a/net/filter.c
> +++ b/net/filter.c
> @@ -23,6 +23,28 @@
>  
>  static QTAILQ_HEAD(, NetFilterState) net_filters;
>  
> +const char *qemu_netfilter_get_chain_str(int chain)
> +{
> +    const char *str = NULL;

The "= NULL" is not necessary here - the default case below should
handle this.

> +    switch (chain) {
> +    case NET_FILTER_IN:
> +        str = "in";
> +        break;
> +    case NET_FILTER_OUT:
> +        str = "out";
> +        break;
> +    case NET_FILTER_ALL:
> +        str = "all";
> +        break;
> +    default:
> +        str = "unknown";
> +        break;
> +    }
> +
> +    return str;
> +}

 Thomas





reply via email to

[Prev in Thread] Current Thread [Next in Thread]