From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, Eric Leblond <eric@regit.org>,
Florian Westphal <fw@strlen.de>
Subject: [nft PATCH v2 3/5] erec_print: Pass output FILE pointer to netlink_dump_expr()
Date: Thu, 28 Sep 2017 17:17:43 +0200 [thread overview]
Message-ID: <20170928151745.28426-4-phil@nwl.cc> (raw)
In-Reply-To: <20170928151745.28426-1-phil@nwl.cc>
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>
---
include/netlink.h | 2 +-
src/erec.c | 2 +-
src/netlink.c | 5 +++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/netlink.h b/include/netlink.h
index b395cf1cd9add..79dc08f873b98 100644
--- a/include/netlink.h
+++ b/include/netlink.h
@@ -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);
diff --git a/src/erec.c b/src/erec.c
index f62bc78ccdfab..174d1aeb0ca8f 100644
--- a/src/erec.c
+++ b/src/erec.c
@@ -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 {
diff --git a/src/netlink.c b/src/netlink.c
index e414718ba1b9d..3183a8100f752 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -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)
--
2.13.1
next prev parent reply other threads:[~2017-09-28 15:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-28 15:17 [nft PATCH v2 0/5] Get output under application control Phil Sutter
2017-09-28 15:17 ` [nft PATCH v2 1/5] rule: Use C99-style initializer in cache_init() Phil Sutter
2017-09-29 10:25 ` Pablo Neira Ayuso
2017-09-28 15:17 ` [nft PATCH v2 2/5] exthdr: Simplify tcp option printing a bit Phil Sutter
2017-09-29 10:25 ` Pablo Neira Ayuso
2017-09-28 15:17 ` Phil Sutter [this message]
2017-09-29 10:26 ` [nft PATCH v2 3/5] erec_print: Pass output FILE pointer to netlink_dump_expr() Pablo Neira Ayuso
2017-09-28 15:17 ` [nft PATCH v2 4/5] rule: Refactor chain_print_declaration() Phil Sutter
2017-09-29 10:26 ` Pablo Neira Ayuso
2017-09-28 15:17 ` [nft PATCH v2 5/5] src: get rid of printf Phil Sutter
2017-09-29 10:38 ` Pablo Neira Ayuso
2017-09-29 10:57 ` Phil Sutter
2017-09-29 11:19 ` 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=20170928151745.28426-4-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=eric@regit.org \
--cc=fw@strlen.de \
--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).