]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
erec_print: Pass output FILE pointer to netlink_dump_expr()
authorPhil Sutter <phil@nwl.cc>
Thu, 28 Sep 2017 15:17:43 +0000 (17:17 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 29 Sep 2017 10:37:44 +0000 (12:37 +0200)
It was a bit odd that erec_print() outputs to a given FILE pointer but
then calls netlink_dump_expr() which just prints to stdout. Fix this by
passing the given FILE pointer along so output is guaranteed to go to
the same destination.

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

index b395cf1cd9addada9ae5a4304c2e5cf54ec23938..79dc08f873b9820e413b8ca93be8c7bc1f8dcc5e 100644 (file)
@@ -184,7 +184,7 @@ extern void netlink_dump_chain(const struct nftnl_chain *nlc,
 extern void netlink_dump_rule(const struct nftnl_rule *nlr,
                              unsigned int debug_mask);
 extern void netlink_dump_expr(const struct nftnl_expr *nle,
-                             unsigned int debug_mask);
+                             FILE *fp, unsigned int debug_mask);
 extern void netlink_dump_set(const struct nftnl_set *nls,
                             unsigned int debug_mask);
 extern void netlink_dump_obj(struct nftnl_obj *nlo, unsigned int debug_mask);
index f62bc78ccdfab837b14fdcba5250ca753dbf411e..174d1aeb0ca8fa90ab95e8210274eb4820d5f70e 100644 (file)
@@ -153,7 +153,7 @@ void erec_print(FILE *f, const struct error_record *erec,
                fprintf(f, "%s\n", erec->msg);
                for (l = 0; l < (int)erec->num_locations; l++) {
                        loc = &erec->locations[l];
-                       netlink_dump_expr(loc->nle, debug_mask);
+                       netlink_dump_expr(loc->nle, f, debug_mask);
                }
                fprintf(f, "\n");
        } else {
index e414718ba1b9d36bf37d669d58d6167251d503bf..3183a8100f75203511bd10169946fc22b2b90bad 100644 (file)
@@ -515,7 +515,8 @@ void netlink_dump_rule(const struct nftnl_rule *nlr, unsigned int debug_mask)
        fprintf(stdout, "%s\n", buf);
 }
 
-void netlink_dump_expr(const struct nftnl_expr *nle, unsigned int debug_mask)
+void netlink_dump_expr(const struct nftnl_expr *nle,
+                      FILE *fp, unsigned int debug_mask)
 {
        char buf[4096];
 
@@ -523,7 +524,7 @@ void netlink_dump_expr(const struct nftnl_expr *nle, unsigned int debug_mask)
                return;
 
        nftnl_expr_snprintf(buf, sizeof(buf), nle, 0, 0);
-       fprintf(stdout, "%s\n", buf);
+       fprintf(fp, "%s\n", buf);
 }
 
 static int list_rule_cb(struct nftnl_rule *nlr, void *arg)