On 26/08/15 11:59, Yang Hongyang wrote:
> From: Yang Hongyang <bur...@gmail.com>
> 
> When execute "info network", print filter info also.
> current info printed is simple, can add more info later.
> 
> Signed-off-by: Yang Hongyang <yan...@cn.fujitsu.com>
> ---
> 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