Fix DEBUG build
Phil Sutter
reviewerPATCH 1/2 Fix DEBUG build
Fixed commit missed to update this conditional call to nft_rule_print_save().
--- iptables/nft-shared.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
iptables/nft-shared.c +1 -1
@@ -998,7 +998,7 @@ bool nft_ipv46_rule_find(struct nft_handle *h, struct nftnl_rule *r, void *data)DEBUGP ("comparing with... " );#ifdef DEBUG_DEL -nft_rule_print_save (r,NFT_RULE_APPEND ,0 ); +nft_rule_print_save (h, r,NFT_RULE_APPEND ,0 );#endif if (!h->ops->is_same (cs, &this)) goto out;
Signature · 1 line
2.24.0
Phil Sutter
reviewerPATCH 2/2 xtables-restore: Fix parser feed from line buffer
When called with --noflush, xtables-restore would trip over chain lines:
Parser uses strtok() to separate chain name, policy and counters which inserts nul-chars into the source string. Therefore strlen() can't be used anymore to find end of line. Fix this by caching line length before calling xtables_restore_parse_line().
--- .../testcases/ipt-restore/0010-noflush-new-chain_0 | 10 ++++++++++ iptables/xtables-restore.c | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 iptables/tests/shell/testcases/ipt-restore/0010-noflush-new-chain_0
iptables/tests/shell/testcases/ipt-restore/0010-noflush-new-chain_0 new file +10 -0
@@ -0,0 +1,10 @@ +#!/bin/sh -e + +# assert input feed from buffer doesn't trip over +# added nul-chars from parsing chain line. + +$XT_MULTI iptables-restore --noflush <<EOF +*filter +:foobar - [0:0] +-A foobar -j ACCEPT +COMMIT
iptables/xtables-restore.c +3 -1
@@ -327,10 +327,12 @@ void xtables_restore_parse(struct nft_handle *h, line =0 ; ptr = preload_buffer;while (*ptr) { +size_t len =strlen (ptr); + h->error.lineno = ++line;DEBUGP ("%s: buffered line %d: '%s'\n" , __func__, line, ptr);xtables_restore_parse_line (h, p, &state, ptr); - ptr +=strlen (ptr) +1 ; + ptr += len +1 ; }if (*buffer) { h->error.lineno = ++line;
Signature · 1 line
2.24.0
Re: [iptables PATCH 2/2] xtables-restore: Fix parser feed from line buffer
Quoted 8 lines · Phil Sutter
When called with --noflush, xtables-restore would trip over chain lines:
Parser usesstrtok()to separate chain name, policy and counters which inserts nul-chars into the source string. Thereforestrlen()can't be used anymore to find end of line. Fix this by caching line length before callingxtables_restore_parse_line().Fixes 09cb517949e69 ("xtables-restore: Improve performance of --noflush operation")Signed-off-by Phil Sutter <[email protected]>
Quoted 5 lines · Phil Sutter
Fixed commit missed to update this conditional call to
nft_rule_print_save().Fixes 1e8ef6a584754 ("nft: family_ops: Pass nft_handle to 'rule_to_cs' callback")Signed-off-by Phil Sutter <[email protected]>
If you still find all this debugging useful.
Otherwise, remove the nft DEBUG is another option. IIRC those were added at very early stage to fix a few issues with -D and -C commands.
Pick the one you prefer. Thanks!
Phil Sutter
reviewerHi,
Quoted 7 lines · Pablo Neira Ayuso
Quoted 5 lines · Phil Sutter
Fixed commit missed to update this conditional call to
nft_rule_print_save().Fixes 1e8ef6a584754 ("nft: family_ops: Pass nft_handle to 'rule_to_cs' callback")Signed-off-by Phil Sutter <[email protected]>
Quoted 8 lines
If you still find all this debugging useful.
Otherwise, remove the nft DEBUG is another option. IIRC those were added at very early stage to fix a few issues with -D and -C commands.
Pick the one you prefer. Thanks!
While it's definitely not as convenient as calling 'nft --debug=<foo>', it's better than nothing. So I'm rather tempted to try and implement a permanent debug output option although all the added jumps will probably kill kubernetes. ;)
Cheers, Phil