netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Leblond <eric@regit.org>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org, Eric Leblond <eric@regit.org>
Subject: [nftables PATCH 4/4] display family in table listing.
Date: Mon, 16 Sep 2013 18:27:38 +0200	[thread overview]
Message-ID: <1379348858-29187-5-git-send-email-eric@regit.org> (raw)
In-Reply-To: <1379348858-29187-1-git-send-email-eric@regit.org>

As family was not displayed in table listing, it was not possible
to restore an ipv6 table saved via 'nft list table ip6 TABLE'.

Signed-off-by: Eric Leblond <eric@regit.org>
---
 src/rule.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/rule.c b/src/rule.c
index 2cf024a..52f5e16 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -269,6 +269,23 @@ struct chain *chain_lookup(const struct table *table, const struct handle *h)
 	return NULL;
 }
 
+static const char *family2str(unsigned int family)
+{
+	switch (family) {
+		case NFPROTO_IPV4:
+			return "ip";
+		case NFPROTO_IPV6:
+			return "ip6";
+		case NFPROTO_ARP:
+			return "arp";
+		case NFPROTO_BRIDGE:
+			return "bridge";
+		default:
+			break;
+	}
+	return "unknown";
+}
+
 static const char *hooknum2str(unsigned int family, unsigned int hooknum)
 {
 	switch (family) {
@@ -371,8 +388,9 @@ static void table_print(const struct table *table)
 	struct chain *chain;
 	struct set *set;
 	const char *delim = "";
+	const char *family = family2str(table->handle.family);
 
-	printf("table %s {\n", table->handle.table);
+	printf("table %s %s {\n", family, table->handle.table);
 	list_for_each_entry(set, &table->sets, list) {
 		if (set->flags & SET_F_ANONYMOUS)
 			continue;
-- 
1.8.4.rc3


  parent reply	other threads:[~2013-09-16 17:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-16 16:27 [nftables 0/4] misc improvements and cleaning Eric Leblond
2013-09-16 16:27 ` [nftables PATCH 1/4] nat: add mandatory family attribute Eric Leblond
2013-09-16 16:27 ` [nftables PATCH 2/4] Suppress non working examples Eric Leblond
2013-09-16 16:27 ` [nftables PATCH 3/4] Update chain creation format Eric Leblond
2013-09-16 20:21   ` Florian Westphal
2013-09-16 21:04     ` Eric Leblond
2013-09-16 16:27 ` Eric Leblond [this message]
2013-09-17 11:14 ` [nftables 0/4] misc improvements and cleaning Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379348858-29187-5-git-send-email-eric@regit.org \
    --to=eric@regit.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).