From: Phil Sutter <phil@nwl.cc>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH xtables-nft 1/3] xtables-monitor: fix rule printing
Date: Mon, 14 Dec 2020 15:19:18 +0100 [thread overview]
Message-ID: <20201214141918.GD28824@orbyte.nwl.cc> (raw)
In-Reply-To: <20201212151534.54336-2-fw@strlen.de>
On Sat, Dec 12, 2020 at 04:15:32PM +0100, Florian Westphal wrote:
> trace_print_rule does a rule dump. This prints unrelated rules
> in the same chain. Instead the function should only request the
> specific handle.
>
> Furthermore, flush output buffer afterwards so this plays nice when
> output isn't a terminal.
>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
> iptables/xtables-monitor.c | 32 +++++++++++++++-----------------
> 1 file changed, 15 insertions(+), 17 deletions(-)
>
> diff --git a/iptables/xtables-monitor.c b/iptables/xtables-monitor.c
> index 4008cc00d469..364e600e1b38 100644
> --- a/iptables/xtables-monitor.c
> +++ b/iptables/xtables-monitor.c
> @@ -227,12 +227,12 @@ static void trace_print_rule(const struct nftnl_trace *nlt, struct cb_arg *args)
> exit(EXIT_FAILURE);
> }
>
> - nlh = nftnl_chain_nlmsg_build_hdr(buf, NFT_MSG_GETRULE, family, NLM_F_DUMP, 0);
> + nlh = nftnl_chain_nlmsg_build_hdr(buf, NFT_MSG_GETRULE, family, 0, 0);
>
> nftnl_rule_set_u32(r, NFTNL_RULE_FAMILY, family);
> nftnl_rule_set_str(r, NFTNL_RULE_CHAIN, chain);
> nftnl_rule_set_str(r, NFTNL_RULE_TABLE, table);
> - nftnl_rule_set_u64(r, NFTNL_RULE_POSITION, handle);
> + nftnl_rule_set_u64(r, NFTNL_RULE_HANDLE, handle);
> nftnl_rule_nlmsg_build_payload(nlh, r);
> nftnl_rule_free(r);
>
> @@ -248,24 +248,21 @@ static void trace_print_rule(const struct nftnl_trace *nlt, struct cb_arg *args)
> }
>
> portid = mnl_socket_get_portid(nl);
> - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
> - perror("mnl_socket_send");
> - exit(EXIT_FAILURE);
> - }
> + if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
> + perror("mnl_socket_send");
> + exit(EXIT_FAILURE);
> + }
Just in case someone else wonders as well: This does a whitespace
cleanup, replacing spaces by tabs. Later changes contain the same
cleanup, too.
Cheers, Phil
next prev parent reply other threads:[~2020-12-14 14:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-12 15:15 [PATCH xtables-nft 0/3] xt-monitor fixes Florian Westphal
2020-12-12 15:15 ` [PATCH xtables-nft 1/3] xtables-monitor: fix rule printing Florian Westphal
2020-12-14 14:19 ` Phil Sutter [this message]
2020-12-12 15:15 ` [PATCH xtables-nft 2/3] xtables-monitor: fix packet family protocol Florian Westphal
2020-12-12 15:15 ` [PATCH xtables-nft 3/3] xtables-monitor: print packet first Florian Westphal
2020-12-14 14:14 ` Phil Sutter
2020-12-14 16:06 ` Florian Westphal
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=20201214141918.GD28824@orbyte.nwl.cc \
--to=phil@nwl.cc \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.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).