summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2017-09-28 17:17:44 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2017-09-29 12:37:44 +0200
commit15a1f5bd55735f6f65a6fd9e2e86bb4a3f5ac815 (patch)
tree300011fdaed9e73dc624add2e6210323b85398ad /src
parent89122493a39f76a530ee0db862986d63b9186e83 (diff)
rule: Refactor chain_print_declaration()
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>
Diffstat (limited to 'src')
-rw-r--r--src/rule.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/rule.c b/src/rule.c
index b122f020..f88cfcbc 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -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));
}
}