]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
display family in table listing
authorEric Leblond <eric@regit.org>
Mon, 16 Sep 2013 16:27:38 +0000 (18:27 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 17 Sep 2013 11:11:22 +0000 (13:11 +0200)
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/rule.c

index 2cf024a4b187a4577eaed7c20f6f82fd9b41735c..52f5e16bda00d1aa45a3e88123ab1db8c87fa2cf 100644 (file)
@@ -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;