]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
rule: Refactor chain_print_declaration()
authorPhil Sutter <phil@nwl.cc>
Thu, 28 Sep 2017 15:17:44 +0000 (17:17 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 29 Sep 2017 10:37:44 +0000 (12:37 +0200)
Instead of having two nearly identical printf() calls for netdev and
other chains, print the common parts separately and include the device
bit only for netdev chains.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/rule.c

index b122f020f4fcf4df3b66bc3911a35610a5413642..f88cfcbcc71935b95e38bf247549d2a7247553ff 100644 (file)
@@ -666,18 +666,12 @@ static void chain_print_declaration(const struct chain *chain)
 {
        printf("\tchain %s {\n", chain->handle.chain);
        if (chain->flags & CHAIN_F_BASECHAIN) {
-               if (chain->dev != NULL) {
-                       printf("\t\ttype %s hook %s device %s priority %d; policy %s;\n",
-                              chain->type,
-                              hooknum2str(chain->handle.family, chain->hooknum),
-                              chain->dev, chain->priority,
-                              chain_policy2str(chain->policy));
-               } else {
-                       printf("\t\ttype %s hook %s priority %d; policy %s;\n",
-                              chain->type,
-                              hooknum2str(chain->handle.family, chain->hooknum),
-                              chain->priority, chain_policy2str(chain->policy));
-               }
+               printf("\t\ttype %s hook %s", chain->type,
+                      hooknum2str(chain->handle.family, chain->hooknum));
+               if (chain->dev != NULL)
+                       printf(" device %s", chain->dev);
+               printf(" priority %d; policy %s;\n",
+                      chain->priority, chain_policy2str(chain->policy));
        }
 }