From patchwork Wed Sep 9 07:24:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Hongyang X-Patchwork-Id: 515729 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 615EE14056B for ; Wed, 9 Sep 2015 17:30:16 +1000 (AEST) Received: from localhost ([::1]:40421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZZpe-0000yb-ES for incoming@patchwork.ozlabs.org; Wed, 09 Sep 2015 03:30:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZZkl-0000qk-PE for qemu-devel@nongnu.org; Wed, 09 Sep 2015 03:25:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZZkf-0005K8-Rx for qemu-devel@nongnu.org; Wed, 09 Sep 2015 03:25:11 -0400 Received: from [59.151.112.132] (port=42215 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZZkf-00057J-Gz for qemu-devel@nongnu.org; Wed, 09 Sep 2015 03:25:05 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100509196" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Sep 2015 15:28:00 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t897Oo6F032215; Wed, 9 Sep 2015 15:24:50 +0800 Received: from localhost (10.167.226.223) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 9 Sep 2015 15:25:02 +0800 From: Yang Hongyang To: Date: Wed, 9 Sep 2015 15:24:38 +0800 Message-ID: <1441783481-17698-8-git-send-email-yanghy@cn.fujitsu.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441783481-17698-1-git-send-email-yanghy@cn.fujitsu.com> References: <1441783481-17698-1-git-send-email-yanghy@cn.fujitsu.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: thuth@redhat.com, zhang.zhanghailiang@huawei.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, armbru@redhat.com, Yang Hongyang , stefanha@redhat.com, Yang Hongyang Subject: [Qemu-devel] [PATCH v10 07/10] netfilter: print filter info associate with the netdev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Yang Hongyang When execute "info network", print filter info also. add a info_str member to NetFilterState, store specific filters info. Signed-off-by: Yang Hongyang --- v10: add a info_str member to NetFilterState v9: tiny cleanup according to Tomas's comment. v7: initial patch --- include/net/filter.h | 1 + net/net.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/net/filter.h b/include/net/filter.h index ed2bb66..c0b9f0a 100644 --- a/include/net/filter.h +++ b/include/net/filter.h @@ -53,6 +53,7 @@ struct NetFilterState { char *netdev_id; NetClientState *netdev; NetFilterChain chain; + char info_str[256]; QTAILQ_ENTRY(NetFilterState) global_list; QTAILQ_ENTRY(NetFilterState) next; }; diff --git a/net/net.c b/net/net.c index 112f334..d39ca1c 100644 --- a/net/net.c +++ b/net/net.c @@ -1172,10 +1172,27 @@ void qmp_netdev_del(const char *id, Error **errp) void print_net_client(Monitor *mon, NetClientState *nc) { + NetFilterState *nf; + monitor_printf(mon, "%s: index=%d,type=%s,%s\n", nc->name, nc->queue_index, NetClientOptionsKind_lookup[nc->info->type], nc->info_str); + if (!QTAILQ_EMPTY(&nc->filters)) { + monitor_printf(mon, "filters:\n"); + } + QTAILQ_FOREACH(nf, &nc->filters, next) { + monitor_printf(mon, " - %s: type=%s,netdev=%s,chain=%s", + object_get_canonical_path_component(OBJECT(nf)), + object_get_typename(OBJECT(nf)), + nf->netdev->name, + NetFilterChain_lookup[nf->chain]); + if (strlen(nf->info_str)) { + monitor_printf(mon, ",%s\n", nf->info_str); + } else { + monitor_printf(mon, "\n"); + } + } } RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name,