From patchwork Thu Oct 8 20:49:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 527889 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 5E391140DA0 for ; Fri, 9 Oct 2015 07:42:42 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754122AbbJHUmk (ORCPT ); Thu, 8 Oct 2015 16:42:40 -0400 Received: from mail.us.es ([193.147.175.20]:47754 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752837AbbJHUmj (ORCPT ); Thu, 8 Oct 2015 16:42:39 -0400 Received: (qmail 22505 invoked from network); 8 Oct 2015 22:42:38 +0200 Received: from unknown (HELO us.es) (192.168.2.12) by us.es with SMTP; 8 Oct 2015 22:42:38 +0200 Received: (qmail 6086 invoked by uid 507); 8 Oct 2015 20:42:37 -0000 X-Qmail-Scanner-Diagnostics: from 127.0.0.1 by antivirus2 (envelope-from , uid 501) with qmail-scanner-2.10 (clamdscan: 0.98.7/20956. spamassassin: 3.4.0. Clear:RC:1(127.0.0.1):SA:0(-103.2/7.5):. Processed in 1.660661 secs); 08 Oct 2015 20:42:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on antivirus2 X-Spam-Level: X-Spam-Status: No, score=-103.2 required=7.5 tests=BAYES_50,SMTPAUTH_US, USER_IN_WHITELIST autolearn=disabled version=3.4.0 X-Spam-ASN: AS12715 87.216.0.0/16 X-Envelope-From: pablo@netfilter.org Received: from unknown (HELO antivirus2) (127.0.0.1) by us.es with SMTP; 8 Oct 2015 20:42:36 -0000 Received: from 192.168.1.13 (192.168.1.13) by antivirus2 (F-Secure/fsigk_smtp/412/antivirus2); Thu, 08 Oct 2015 22:42:36 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/412/antivirus2) Received: (qmail 21745 invoked from network); 8 Oct 2015 22:42:36 +0200 Received: from 77.166.216.87.static.jazztel.es (HELO salvia.here) (pneira@us.es@87.216.166.77) by mail.us.es with SMTP; 8 Oct 2015 22:42:36 +0200 From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: kaber@trash.net, fw@strlen.de, arturo.borrero.glez@gmail.com Subject: [PATCH nft 3/7] rule: display table when listing one set Date: Thu, 8 Oct 2015 22:49:26 +0200 Message-Id: <1444337370-8269-4-git-send-email-pablo@netfilter.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444337370-8269-1-git-send-email-pablo@netfilter.org> References: <1444337370-8269-1-git-send-email-pablo@netfilter.org> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org After: # nft list set ip6 test foo table ip6 test { set foo { type ipv4_addr } } Before: # nft list set ip6 test foo set foo { type ipv4_addr } Signed-off-by: Pablo Neira Ayuso --- src/rule.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/rule.c b/src/rule.c index 4e4126d..58bac76 100644 --- a/src/rule.c +++ b/src/rule.c @@ -1042,6 +1042,13 @@ static int do_list_tables(struct netlink_ctx *ctx, struct cmd *cmd) return 0; } +static void table_print_declaration(struct table *table) +{ + printf("table %s %s {\n", + family2str(table->handle.family), + table->handle.table); +} + static int do_list_chains(struct netlink_ctx *ctx, struct cmd *cmd) { struct table *table; @@ -1052,9 +1059,7 @@ static int do_list_chains(struct netlink_ctx *ctx, struct cmd *cmd) cmd->handle.family != table->handle.family) continue; - printf("table %s %s {\n", - family2str(table->handle.family), - table->handle.table); + table_print_declaration(table); list_for_each_entry(chain, &table->chains, list) { chain_print_declaration(chain); @@ -1075,7 +1080,10 @@ static int do_list_set(struct netlink_ctx *ctx, struct cmd *cmd, if (set == NULL) return -1; + table_print_declaration(table); set_print(set); + printf("}\n"); + return 0; }