]> git.ipfire.org Git - thirdparty/iptables.git/log
thirdparty/iptables.git
2 years agoiptables-restore: Free handle with --test also
Phil Sutter [Fri, 25 Nov 2022 18:24:38 +0000 (19:24 +0100)] 
iptables-restore: Free handle with --test also

When running 'iptables-restore -t', valgrind reports:

1,496 (160 direct, 1,336 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
   at 0x48417E5: malloc (vg_replace_malloc.c:381)
   by 0x4857A46: alloc_handle (libiptc.c:1279)
   by 0x4857A46: iptc_init (libiptc.c:1342)
   by 0x1167CE: create_handle (iptables-restore.c:72)
   by 0x1167CE: ip46tables_restore_main (iptables-restore.c:229)
   by 0x116DAE: iptables_restore_main (iptables-restore.c:388)
   by 0x49A2349: (below main) (in /lib64/libc.so.6)

Free the handle pointer before parsing the next table.

Fixes: 1c9015b2cb483 ("libiptc: remove indirections")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: shell: Fix valgrind mode for 0008-unprivileged_0
Phil Sutter [Wed, 30 Nov 2022 16:58:13 +0000 (17:58 +0100)] 
tests: shell: Fix valgrind mode for 0008-unprivileged_0

Valgrind is run as user nobody, let everyone write into the temporary
directory.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: add xt_statistics random mode translation
Florian Westphal [Thu, 1 Dec 2022 10:13:17 +0000 (11:13 +0100)] 
extensions: add xt_statistics random mode translation

Use meta random and bitops to replicate what xt_statistics
is doing.

Signed-off-by: Florian Westphal <fw@strlen.de>
2 years agonft-bridge: work around recent "among" decode breakage
Florian Westphal [Wed, 30 Nov 2022 10:38:12 +0000 (11:38 +0100)] 
nft-bridge: work around recent "among" decode breakage

ebtables-nft-save will fail with
"unknown meta key" when decoding "among" emulation with ipv4 or ipv6
addresses included.

This is because "meta protocol ip" is used as a dependency, but
its never decoded anywhere.

Skip this for now to restore the "ebtables/0006-flush_0"
test case.

Fixes: 25883ce88bfb ("nft: check for unknown meta keys")
Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Phil Sutter <phil@nwl.cc>
2 years agoxlate-test: avoid shell entanglements
Florian Westphal [Wed, 30 Nov 2022 09:31:54 +0000 (10:31 +0100)] 
xlate-test: avoid shell entanglements

Feed the nft expected output found in the .txlate test files to
nft -f via pipe/stdin directly without the shell mangling it.

The shell step isn't needed anymore because xtables-translate no longer
escapes quotes.

We only need to remove the "nft '" and trailing "'" because nft doesn't
expect those.

v3: handle multi-line expectations such as libxt_connlimmit.txlate (Phil Sutter)

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: change expected output for new format
Florian Westphal [Wed, 30 Nov 2022 09:31:53 +0000 (10:31 +0100)] 
extensions: change expected output for new format

Now that xtables-translate encloses the entire command line in ', update
the test cases accordingly.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoxlate: get rid of escape_quotes
Florian Westphal [Wed, 30 Nov 2022 09:31:52 +0000 (10:31 +0100)] 
xlate: get rid of escape_quotes

Its not necessary to escape " characters, we can let xtables-translate
print the entire translation/command enclosed in '' chracters, i.e. nft
'add rule ...', this also takes care of [, { and other special characters
that some shells might parse otherwise (when copy-pasting translated output).

The escape_quotes struct member is retained to avoid an ABI breakage.

This breaks all xlate test cases, fixup in followup patches.

v3: no need to escape ', replace strcmp(x, "") with x[0] (Phil Sutter)

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: shell: Test selective ebtables flushing
Phil Sutter [Tue, 29 Nov 2022 14:21:01 +0000 (15:21 +0100)] 
tests: shell: Test selective ebtables flushing

Found this on disk, maybe there was a problem with this and among match
at some point? Anyway, it is relevant again since it fails recently.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: xlate: Format sets consistently
Phil Sutter [Fri, 25 Nov 2022 13:05:28 +0000 (14:05 +0100)] 
extensions: xlate: Format sets consistently

Print a space after separating commas.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libxt_conntrack: Drop extra whitespace in xlate
Phil Sutter [Fri, 25 Nov 2022 03:35:35 +0000 (04:35 +0100)] 
extensions: libxt_conntrack: Drop extra whitespace in xlate

No point in having this. Interestingly, other test cases even made up
for it.

Fixes: 0afd957f6bc03 ("extensions: libxt_state: add translation to nft")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: Leverage xlate auto-spacing
Phil Sutter [Fri, 25 Nov 2022 03:27:21 +0000 (04:27 +0100)] 
extensions: Leverage xlate auto-spacing

Drop code which is used explicitly to deal with spacing.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agolibxtables: xt_xlate_add() to take care of spacing
Phil Sutter [Fri, 25 Nov 2022 02:13:14 +0000 (03:13 +0100)] 
libxtables: xt_xlate_add() to take care of spacing

Try to eliminate most of the whitespace issues by separating strings
from separate xt_xlate_add() calls by whitespace if needed.

Cover the common case of consecutive range, list or MAC/IP address
printing by inserting whitespace only if the string to be appended
starts with an alphanumeric character or a brace. The latter helps to
make spacing in anonymous sets consistent.

Provide *_nospc() variants which disable the auto-spacing for the
mandatory exception to the rule.

Make things round by dropping any trailing whitespace before returning
the buffer via xt_xlate_get().

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: ipcomp: Add comment to clarify xlate callback
Phil Sutter [Tue, 15 Mar 2022 10:58:37 +0000 (11:58 +0100)] 
extensions: ipcomp: Add comment to clarify xlate callback

Kernel ignores 'hdrres' field, this matching on reserved field value was
never effective.

While being at it, drop its description from man page. Continue to parse
and print it for compatibility reasons, but avoid attracting new users.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: frag: Add comment to clarify xlate callback
Phil Sutter [Thu, 17 Nov 2022 16:38:52 +0000 (17:38 +0100)] 
extensions: frag: Add comment to clarify xlate callback

Matching on fragmentation header length is ineffective in kernel, xlate
callback correctly ignores it. Add a comment as a hint for reviewers.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libebt_log: Add comment to clarify xlate callback
Phil Sutter [Thu, 17 Nov 2022 16:37:27 +0000 (17:37 +0100)] 
extensions: libebt_log: Add comment to clarify xlate callback

Several log flags are ignored by the function. Add a comment explaining
why this is correct.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: tcp: Translate TCP option match
Phil Sutter [Thu, 17 Nov 2022 15:39:40 +0000 (16:39 +0100)] 
extensions: tcp: Translate TCP option match

A simple task since 'tcp option' expression exists.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: ecn: Sanitize xlate callback
Phil Sutter [Thu, 17 Nov 2022 15:37:02 +0000 (16:37 +0100)] 
extensions: ecn: Sanitize xlate callback

Catch unexpected values in einfo->ip_ect.

Fixes: ca42442093d3d ("iptables: extensions: libxt_ecn: Add translation to nft")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: TOS: Fix v1 xlate callback
Phil Sutter [Thu, 17 Nov 2022 15:10:14 +0000 (16:10 +0100)] 
extensions: TOS: Fix v1 xlate callback

Translation entirely ignored tos_mask field.

Fixes: b669e18489709 ("extensions: libxt_TOS: Add translation to nft")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: TCPMSS: Use xlate callback for IPv6, too
Phil Sutter [Thu, 17 Nov 2022 15:06:46 +0000 (16:06 +0100)] 
extensions: TCPMSS: Use xlate callback for IPv6, too

Data structures are identical and the translation is layer3-agnostic.

Fixes: bebce197adb42 ("iptables: iptables-compat translation for TCPMSS")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: MARK: Sanitize MARK_xlate()
Phil Sutter [Thu, 17 Nov 2022 15:01:11 +0000 (16:01 +0100)] 
extensions: MARK: Sanitize MARK_xlate()

Since markinfo->mode might contain unexpected values, add a default case
returning zero.

Fixes: afefc7a134ca0 ("extensions: libxt_MARK: Add translation for revision 1 to nft")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: CONNMARK: Fix xlate callback
Phil Sutter [Thu, 17 Nov 2022 14:30:11 +0000 (15:30 +0100)] 
extensions: CONNMARK: Fix xlate callback

Bail out if nfmask != ctmask with XT_CONNMARK_SAVE and
XT_CONNMARK_RESTORE. Looks like this needs a similar implementation to
the one for XT_CONNMARK_SET.

Fix shift mark translation: xt_connmark_shift_ops does not contain
useful strings for nftables. Also add needed braces around the term
being shifted.

Fixes: db7b4e0de960c ("extensions: libxt_CONNMARK: Support bit-shifting for --restore,set and save-mark")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libipt_ttl: Sanitize xlate callback
Phil Sutter [Wed, 16 Nov 2022 12:09:16 +0000 (13:09 +0100)] 
extensions: libipt_ttl: Sanitize xlate callback

Catch unexpected values in info->mode, also fix indenting.

Fixes: 1b320a1a1dc1f ("extensions: libipt_ttl: Add translation to nft")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libebt_redirect: Fix xlate return code
Phil Sutter [Wed, 16 Nov 2022 12:03:05 +0000 (13:03 +0100)] 
extensions: libebt_redirect: Fix xlate return code

The callback is supposed to return 1 on success, not 0.

Fixes: 24ce7465056ae ("ebtables-compat: add redirect match extension")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libebt_mark: Fix xlate test case
Phil Sutter [Fri, 11 Mar 2022 17:28:49 +0000 (18:28 +0100)] 
extensions: libebt_mark: Fix xlate test case

The false suffix effectively disabled this test file, but it also has
problems: Apart from brmark_xlate() printing 'meta mark' instead of just
'mark', target is printed in the wrong position (like with any other
target-possessing extension.

Fixes: e67c08880961f ("ebtables-translate: add initial test cases")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libebt_mark: Fix mark target xlate
Phil Sutter [Wed, 23 Nov 2022 02:35:34 +0000 (03:35 +0100)] 
extensions: libebt_mark: Fix mark target xlate

Target value is constructed setting all non-target bits to one instead
of zero.

Fixes: 03ecffe6c2cc0 ("ebtables-compat: add initial translations")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoiptables-nft: exit nonzero when iptables-save cannot decode all expressions
Florian Westphal [Wed, 23 Nov 2022 13:44:22 +0000 (14:44 +0100)] 
iptables-nft: exit nonzero when iptables-save cannot decode all expressions

We always return 0, even if we printed some error message half-way.
Increment an error counter whenever an error message was printed so that
the chain-loop can exit with an error if this counter is nonzero.

Another effect is that iptables-save will no longer print the COMMIT line anmore.

Reported-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Phil Sutter <phil@nwl.cc>
2 years agonft: check for unknown meta keys
Florian Westphal [Fri, 18 Nov 2022 14:20:32 +0000 (15:20 +0100)] 
nft: check for unknown meta keys

Set ->errmsg when the meta key isn't supported by iptables-nft instead
of pretending everything is fine.

The old code is good enough to handle rules added by iptables-nft, but
its not enough to handle rules added by native nft.

At least make sure that there is a an error message telling that
iptables-nft could not decode the entire ruleset.

Signed-off-by: Florian Westphal <fw@strlen.de>
2 years agoextensions: mark: Test double bitwise in a rule
Phil Sutter [Wed, 16 Nov 2022 10:52:20 +0000 (11:52 +0100)] 
extensions: mark: Test double bitwise in a rule

In v1.8.8, the second bitwise changed the first one, messing
iptables-nft-save output.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft-shared: replace nftnl_expr_get_data() by nftnl_expr_get()
Pablo Neira Ayuso [Mon, 14 Nov 2022 16:57:15 +0000 (17:57 +0100)] 
nft-shared: replace nftnl_expr_get_data() by nftnl_expr_get()

Replace nftnl_expr_get_data() alias by real function call.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: replace nftnl_.*_nlmsg_build_hdr() by nftnl_nlmsg_build_hdr()
Pablo Neira Ayuso [Mon, 14 Nov 2022 16:54:42 +0000 (17:54 +0100)] 
nft: replace nftnl_.*_nlmsg_build_hdr() by nftnl_nlmsg_build_hdr()

Replace alias to real nftnl_nlmsg_build_hdr() function call.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoDrop extra newline from xtables_error() calls
Phil Sutter [Fri, 7 Jan 2022 15:26:30 +0000 (16:26 +0100)] 
Drop extra newline from xtables_error() calls

Since basic_exit_err() appends a newline to the message itself, drop
explicit ones.

While being at it, fix indentation and join texts split over multiple
lines.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: Unify ICMP parser into libxt_icmp.h
Phil Sutter [Wed, 12 Oct 2022 00:02:38 +0000 (02:02 +0200)] 
extensions: Unify ICMP parser into libxt_icmp.h

Merge all four copies of the ICMP/ICMPv6/IGMP parameter parsing code.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: Collate ICMP types/codes in libxt_icmp.h
Phil Sutter [Tue, 11 Oct 2022 15:07:33 +0000 (17:07 +0200)] 
extensions: Collate ICMP types/codes in libxt_icmp.h

Put the most extensive version of icmp_codes, icmpv6_codes and
igmp_codes into the header. Have to rename the function
xt_print_icmp_types's parameter to avoid a compiler warning.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libebt_arp, libebt_ip: Use xtables_ipparse_any()
Phil Sutter [Thu, 6 Oct 2022 12:54:48 +0000 (14:54 +0200)] 
extensions: libebt_arp, libebt_ip: Use xtables_ipparse_any()

The libxtables function covers all formerly supported inputs (and more).
The extended libebt_arp.t passes before and after this patch.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libebt_ip: Include kernel header
Phil Sutter [Thu, 6 Oct 2022 13:09:32 +0000 (15:09 +0200)] 
extensions: libebt_ip: Include kernel header

Update the local copy of linux/netfilter_bridge/ebt_ip.h and include it
instead of keeping the local copy of struct ebt_ip_info et al.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libip*t_LOG: Merge extensions
Phil Sutter [Sat, 22 Oct 2022 13:16:59 +0000 (15:16 +0200)] 
extensions: libip*t_LOG: Merge extensions

Data structures were identical already, make use of the names in
xt_LOG.h and merge all code into a single extension of family
NFPROTO_UNSPEC.

While being at it, define SYSLOG_NAMES and use the array in syslog.h
instead of dragging along an own level->name mapping two times.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft-shared: Introduce port_match_single_to_range()
Phil Sutter [Thu, 6 Oct 2022 16:20:14 +0000 (18:20 +0200)] 
nft-shared: Introduce port_match_single_to_range()

The same algorithm was present four times, outsource it. Also use
max()/min() macros for a more readable boundary notation.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoxshared: Share make_delete_mask() between ip{,6}tables
Phil Sutter [Tue, 12 May 2020 16:46:39 +0000 (18:46 +0200)] 
xshared: Share make_delete_mask() between ip{,6}tables

Function bodies were mostly identical, the only difference being the use
of struct ipt_entry or ip6t_entry for size calculation. Pass this value
via parameter to make them fully identical.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: xlate-test: Replay results for reverse direction testing
Phil Sutter [Fri, 21 Oct 2022 10:15:21 +0000 (12:15 +0200)] 
tests: xlate-test: Replay results for reverse direction testing

Call nft with translation output as input, then check xtables-save
output to make sure iptables-nft can handle anything it suggests nft to
turn its ruleset into.

This extends the test case syntax to cover for expected asymmetries.
When the existing syntax was something like this:

| <xlate command>
| <nft output1>
| [<nft output2>

The new syntax then is:

| <xlate command>[;<replay rule part>]
| <nft output1>
| [<nft output2>]

To keep things terse, <replay rule part> may omit the obligatory '-A
<chain>' argument. If missing, <xlate command> is sanitized for how it
would appear in xtables-save output: '-I' is converted into '-A' and an
optional table spec is removed.

Since replay mode has to manipulate the ruleset in-kernel, abort if
called by unprivileged user. Also try to run in own net namespace to
reduce collateral damage.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: xlate-test.py: Introduce run_proc()
Phil Sutter [Fri, 28 Oct 2022 17:07:14 +0000 (19:07 +0200)] 
tests: xlate-test.py: Introduce run_proc()

It's just a convenience wrapper around Popen(), simplifying the call.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: xlate-test: Cleanup file reading loop
Phil Sutter [Fri, 21 Oct 2022 08:28:09 +0000 (10:28 +0200)] 
tests: xlate-test: Cleanup file reading loop

Put the actual translation test into a function to call from the loop
and clean it up a bit. Preparation work for running a second test on the
same data.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: Merge SNAT, DNAT, REDIRECT and MASQUERADE
Phil Sutter [Tue, 12 Apr 2022 19:19:39 +0000 (21:19 +0200)] 
extensions: Merge SNAT, DNAT, REDIRECT and MASQUERADE

REDIRECT was already merged into DNAT. Given the callback generator and
generalized inner parsing routines, merging the other "flavors" is
relatively simple. Rename the extension into "libxt_NAT.so" while doing
so and turn the old DSOs into symlinks.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: DNAT: Rename some symbols
Phil Sutter [Wed, 2 Nov 2022 22:21:29 +0000 (23:21 +0100)] 
extensions: DNAT: Rename some symbols

No functional change intended, just a more generic name for some symbols
which won't be DNAT-specific soon.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: DNAT: Generate print, save and xlate callbacks
Phil Sutter [Sat, 9 Jul 2022 09:01:35 +0000 (11:01 +0200)] 
extensions: DNAT: Generate print, save and xlate callbacks

Each extension's callbacks follow the same scheme so introduce a
generator which accepts the specifics as parameter - including the
method to transform from per-extension data into struct nf_nat_range2.

Also move the different parser frontends and fcheck callbacks in one
spot for clarity.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: DNAT: Use __DNAT_xlate for REDIRECT, too
Phil Sutter [Sat, 9 Jul 2022 14:40:15 +0000 (16:40 +0200)] 
extensions: DNAT: Use __DNAT_xlate for REDIRECT, too

Make the common function a bit more versatile and give it a more
generic name, then use it for REDIRECT target, too.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: *NAT: Drop NF_NAT_RANGE_PROTO_RANDOM* flag checks
Phil Sutter [Wed, 2 Nov 2022 20:54:41 +0000 (21:54 +0100)] 
extensions: *NAT: Drop NF_NAT_RANGE_PROTO_RANDOM* flag checks

SNAT, DNAT and REDIRECT extensions tried to prevent
NF_NAT_RANGE_PROTO_RANDOM flag from being set if no port or address was
also given.

With SNAT and DNAT, this is not possible as the respective
--to-destination or --to-source parameters are mandatory anyway.

Looking at the kernel code, doing so with REDIRECT seems harmless.
Moreover, nftables supports 'redirect random' without specifying a
port-range.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: DNAT: Fix bad IP address error reporting
Phil Sutter [Sun, 3 Jul 2022 13:59:19 +0000 (15:59 +0200)] 
extensions: DNAT: Fix bad IP address error reporting

When introducing 'start' variable to cover for IPv6 addresses enclosed
in brackets, this single spot was missed.

Fixes: 14d77c8aa29a7 ("extensions: Merge IPv4 and IPv6 DNAT targets")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: *.t: Add missing all-one's netmasks to expected output
Phil Sutter [Wed, 12 Oct 2022 14:21:17 +0000 (16:21 +0200)] 
tests: *.t: Add missing all-one's netmasks to expected output

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: libxt_connlimit.t: Add missing default values
Phil Sutter [Wed, 5 Oct 2022 18:34:16 +0000 (20:34 +0200)] 
tests: libxt_connlimit.t: Add missing default values

This extension always prints --connlimit-mask and (the default)
--connlimit-saddr options.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: libebt_vlan.t: Drop trailing whitespace from rules
Phil Sutter [Wed, 5 Oct 2022 18:30:44 +0000 (20:30 +0200)] 
tests: libebt_vlan.t: Drop trailing whitespace from rules

Fast iptables-test.py mode is picky and it has to: Plain redirect target
prints a trailing whitespace, generally stripping the rules in test
cases won't work therefore.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: libxt_tos.t, libxt_TOS.t: Add missing masks in output
Phil Sutter [Fri, 30 Sep 2022 23:25:50 +0000 (01:25 +0200)] 
tests: libxt_tos.t, libxt_TOS.t: Add missing masks in output

Mask differs between numeric --set-tos values and symbolic ones, make
sure it is covered by the tests.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: libxt_recent.t: Add missing default values
Phil Sutter [Fri, 30 Sep 2022 23:13:54 +0000 (01:13 +0200)] 
tests: libxt_recent.t: Add missing default values

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: libxt_length.t: Fix odd use-case output
Phil Sutter [Fri, 30 Sep 2022 22:39:07 +0000 (00:39 +0200)] 
tests: libxt_length.t: Fix odd use-case output

Specifying the lower boundary suffixed by colon is an undocumented
feature. Explicitly printing the upper boundary in that case seems sane.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: libebt_redirect.t: Plain redirect prints with trailing whitespace
Phil Sutter [Fri, 30 Sep 2022 22:14:56 +0000 (00:14 +0200)] 
tests: libebt_redirect.t: Plain redirect prints with trailing whitespace

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: *.t: Fix for hexadecimal output
Phil Sutter [Fri, 30 Sep 2022 22:43:40 +0000 (00:43 +0200)] 
tests: *.t: Fix for hexadecimal output

Use hex input to avoid having to specify an expected output in trivial
cases.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: *.t: Fix expected output for simple calls
Phil Sutter [Fri, 30 Sep 2022 22:10:34 +0000 (00:10 +0200)] 
tests: *.t: Fix expected output for simple calls

These minimal extension uses print in more detailed form. Track this,
the output is desired.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: iptables-test: Cover for obligatory -j CONTINUE in ebtables
Phil Sutter [Wed, 5 Oct 2022 17:51:08 +0000 (19:51 +0200)] 
tests: iptables-test: Cover for obligatory -j CONTINUE in ebtables

Unlike iptables, ebtables includes the default rule target in output.
Instead of adding it to every rule in ebtables tests, add special casing
to the testscript checking if the expected rule output contains a target
already and adding the default one if not.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: iptables-test: Implement fast test mode
Phil Sutter [Fri, 30 Sep 2022 16:15:59 +0000 (18:15 +0200)] 
tests: iptables-test: Implement fast test mode

Implement a faster mode of operation for suitable test files:

1) Collect all rules to add and all expected output in lists
2) Any supposedly failing rules are checked immediately like in slow
   mode.
3) Create and load iptables-restore input from the list in (1)
5) Construct the expected iptables-save output from (1) and check it in
   a single search
5) If any of the steps above fail, fall back to slow mode for
   verification and detailed error analysis. Fast mode failures are not
   fatal, merely warn about them.

To keep things simple (and feasible), avoid complicated test files
involving external commands, multiple tables or variant-specific
results.

Aside from speeding up testsuite run-time, rule searching has become
more strict since EOL char is practically part of the search string.
This revealed many false positives where the expected string was
actually a substring of the printed rule.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: NFQUEUE: Document queue-balance limitation
Phil Sutter [Wed, 12 Oct 2022 13:00:09 +0000 (15:00 +0200)] 
extensions: NFQUEUE: Document queue-balance limitation

The range is not communicated as "min and max queue number", but "first
queue number and count" instead. With 16bits for each value, it is not
possible to balance between all 65536 possible queues. Although probably
never used in practice, point this detail out in man page and make the
parser complain instead of the cryptic "xt_NFQUEUE: number of total
queues is 0" emitted by the kernel module.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: Fix compile with -DDEBUG
Phil Sutter [Fri, 7 Oct 2022 20:16:43 +0000 (22:16 +0200)] 
nft: Fix compile with -DDEBUG

Conversion from 'ctx' to 'reg' missed some of the DEBUGP() calls.

Fixes: f315af1cf8871 ("nft: track each register individually")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agolibiptc: Fix for segfault when renaming a chain
Phil Sutter [Fri, 7 Oct 2022 16:29:07 +0000 (18:29 +0200)] 
libiptc: Fix for segfault when renaming a chain

This is an odd bug: If the number of chains is right and one renames the
last one in the list, libiptc dereferences a NULL pointer. Add fix and
test case for it.

Fixes: 64ff47cde38e4 ("libiptc: fix chain rename bug in libiptc")
Reported-by: Julien Castets <castets.j@gmail.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: shell: Fix expected ebtables log target output
Phil Sutter [Thu, 6 Oct 2022 00:10:44 +0000 (02:10 +0200)] 
tests: shell: Fix expected ebtables log target output

Forgot to update shell testsuite when removing empty --log-prefix
options.

Fixes: 9cdb52d655608 ("extensions: libebt_log: Avoid empty log-prefix in output")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: shell: Fix expected output for ip6tables dst match
Phil Sutter [Thu, 6 Oct 2022 00:08:10 +0000 (02:08 +0200)] 
tests: shell: Fix expected output for ip6tables dst match

Forgot to update the shell testsuites when fixing for duplicate
whitespace in output.

Fixes: 11e06cbb3a877 ("extensions: libip6t_dst: Fix output for empty options")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: libebt_stp.t: Drop duplicate whitespace
Phil Sutter [Wed, 5 Oct 2022 18:29:36 +0000 (20:29 +0200)] 
tests: libebt_stp.t: Drop duplicate whitespace

Code was fixed but the testcase adjustment slipped through.

Fixes: 262dff31a998e ("extensions: libebt_stp: Eliminate duplicate space in output")
2 years agotests: IDLETIMER.t: Fix syntax, support for restore input
Phil Sutter [Fri, 30 Sep 2022 16:06:10 +0000 (18:06 +0200)] 
tests: IDLETIMER.t: Fix syntax, support for restore input

Expected output was wrong in the last OK test, probably defeating rule
search check. Also use a different label, otherwise the kernel will
reject the second idletimer with same label but different type if both
rules are added at once.

Fixes: 85b9ec8615428 ("extensions: IDLETIMER: Add alarm timer option")
2 years agoextensions: libebt_log: Avoid empty log-prefix in output
Phil Sutter [Fri, 30 Sep 2022 22:10:34 +0000 (00:10 +0200)] 
extensions: libebt_log: Avoid empty log-prefix in output

Just like iptables LOG target, omit --log-prefix from output if the
string is empty.

2 years agoextensions: TCPOPTSTRIP: Do not print empty options
Phil Sutter [Fri, 30 Sep 2022 22:36:50 +0000 (00:36 +0200)] 
extensions: TCPOPTSTRIP: Do not print empty options

No point in printing anything if none of the bits are set.

Fixes: aef4c1e727563 ("libxt_TCPOPTSTRIP")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libip6t_dst: Fix output for empty options
Phil Sutter [Fri, 30 Sep 2022 22:17:50 +0000 (00:17 +0200)] 
extensions: libip6t_dst: Fix output for empty options

If no --dst-opts were given, print_options() would print just a
whitespace.

Fixes: 73866357e4a7a ("iptables: do not print trailing whitespaces")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libebt_stp: Eliminate duplicate space in output
Phil Sutter [Fri, 30 Sep 2022 22:15:35 +0000 (00:15 +0200)] 
extensions: libebt_stp: Eliminate duplicate space in output

No need for print_range() to print a trailing whitespace, caller does
this already.

Fixes: fd8d7d7e5d911 ("ebtables-nft: add stp match")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: among: Fix for use with ebtables-restore
Phil Sutter [Fri, 30 Sep 2022 15:51:55 +0000 (17:51 +0200)] 
extensions: among: Fix for use with ebtables-restore

When restoring multiple rules which use among match, new size may be
smaller than the old one which caused invalid writes by the memcpy()
call. Expect this and realloc the match only if it needs to grow. Also
use realloc instead of freeing and allocating from scratch.

Fixes: 26753888720d8 ("nft: bridge: Rudimental among extension support")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: among: Remove pointless fall through
Phil Sutter [Thu, 29 Sep 2022 17:11:55 +0000 (19:11 +0200)] 
extensions: among: Remove pointless fall through

This seems to be a leftover from an earlier version of the switch().
This fall through is never effective as the next case's code will never
apply. So just break instead.

Fixes: 26753888720d8 ("nft: bridge: Rudimental among extension support")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: iptables-test: Test both variants by default
Phil Sutter [Thu, 29 Sep 2022 14:00:09 +0000 (16:00 +0200)] 
tests: iptables-test: Test both variants by default

Via '--legacy' and '--nftables' flags one may choose the variant to
test. Change the default (none of them given) from legacy to both,
by effectively running twice. Prefix the summary line with the tested
variant for clarity and print a total count line as well.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: iptables-test: Pass netns to execute_cmd()
Phil Sutter [Thu, 29 Sep 2022 13:52:40 +0000 (15:52 +0200)] 
tests: iptables-test: Pass netns to execute_cmd()

The command to run might have to be prefixed. Once if the command is
'iptables' (or related) to define the variant, once if '-N' was given to
run the command inside the netns. Doing both prefixing inside
execute_cmd() avoids a potential conflict and thus simplifies things:
The "external command" and "external iptables call" lines become
identical in handling, there is no need for a separate prefix char
anymore.

As a side-effect, this commit also fixes for delete_rule() calls in
error case ignoring the netns value.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: iptables-test: Simplify execute_cmd() calling
Phil Sutter [Thu, 29 Sep 2022 12:48:29 +0000 (14:48 +0200)] 
tests: iptables-test: Simplify execute_cmd() calling

Default 'lineno' parameter to zero,

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: iptables-test: Simplify '-N' option a bit
Phil Sutter [Thu, 29 Sep 2022 12:46:26 +0000 (14:46 +0200)] 
tests: iptables-test: Simplify '-N' option a bit

Instead of hard-coding, store the netns name in args.netns if the flag
was given. The value defaults to None, so existing 'if netns' checks are
still valid.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft-bridge: Drop 'sreg_count' variable
Phil Sutter [Wed, 28 Sep 2022 16:42:02 +0000 (18:42 +0200)] 
nft-bridge: Drop 'sreg_count' variable

It is not needed, one can just use 'reg' function parameter in its
place.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Florian Westphal <fw@strlen.de>
2 years agonft: Fix meta statement parsing
Phil Sutter [Wed, 28 Sep 2022 16:08:43 +0000 (18:08 +0200)] 
nft: Fix meta statement parsing

The function nft_meta_set_to_target() would always bail since nothing
sets 'sreg->meta_sreg.set' to true. This is obvious, as the immediate
expression "filling" the source register does not indicate its purpose.

The whole source register purpose storing in meta_sreg seems to be
pointless, so drop it altogether.

Fixes: f315af1cf8871 ("nft: track each register individually")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables: Fix among match
Phil Sutter [Thu, 4 Aug 2022 15:01:26 +0000 (17:01 +0200)] 
ebtables: Fix among match

Fixed commit broke among match in two ways:

1) The two lookup sizes are 12 and 6, not 12 and 4 - among supports
   either ether+IP or ether only, not IP only.

2) Adding two to sreg_count to get the second register is too simple: It
   works only for four byte regs, not the 16 byte ones. The first
   register is always a 16 byte one, though.

Fixing (1) is trivial, fix (2) by introduction of nft_get_next_reg()
doing the right thing. For consistency, use it for among match creation,
too.

Fixes: f315af1cf8871 ("nft: track each register individually")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables: Support '-p Length'
Phil Sutter [Tue, 27 Sep 2022 21:19:34 +0000 (23:19 +0200)] 
ebtables: Support '-p Length'

To match on Ethernet frames using the etherproto field as length value,
ebtables accepts the special protocol name "LENGTH". Implement this in
ebtables-nft using a native match for 'ether type < 0x0600'.

Since extension 802_3 matches are valid only with such Ethernet frames,
add a local add_match() wrapper which complains if the extension is used
without '-p Length' parameter. Legacy ebtables does this within the
extension's final_check callback, but it's not possible here due for lack of
fw->bitmask field access.

While being at it, add xlate support, adjust tests and make ebtables-nft
print the case-insensitive argument with capital 'L' like legacy
ebtables does.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft-shared: Introduce __get_cmp_data()
Phil Sutter [Tue, 27 Sep 2022 21:15:37 +0000 (23:15 +0200)] 
nft-shared: Introduce __get_cmp_data()

This is an inner function to get_cmp_data() returning the op value as-is
for caller examination.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables: Merge OPT_* flags with xshared ones
Phil Sutter [Tue, 27 Sep 2022 17:46:47 +0000 (19:46 +0200)] 
ebtables: Merge OPT_* flags with xshared ones

Despite also including xshared.h, xtables-eb.c defined its own OPT_*
flags with clashing values. Albeit ugly, this wasn't a problem in
practice until commit 51d9d9e081344 ("ebtables: Support verbose mode")
which introduced use of OPT_VERBOSE from xshared - with same value as
the local OPT_PROTOCOL define.

Eliminate the clash by appending ebtables-specific flags to the xshared
enum and adjust for the different names of some others.

Fixes: 51d9d9e081344 ("ebtables: Support verbose mode")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables: Eliminate OPT_TABLE
Phil Sutter [Tue, 27 Sep 2022 17:03:47 +0000 (19:03 +0200)] 
ebtables: Eliminate OPT_TABLE

The flag is used for duplicate option checking only and there is a
boolean indicating the same already. So copy the error message from
EBT_CHECK_OPTION() in situ and just take care not to disturb restore
mode handling.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables: Drop unused OPT_* defines
Phil Sutter [Tue, 27 Sep 2022 16:53:50 +0000 (18:53 +0200)] 
ebtables: Drop unused OPT_* defines

Obviously copied from legacy ebtables, not needed by ebtables-nft.
OPT_CNT_* ones seem not even used in legacy anymore.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: extend native delinearize script
Florian Westphal [Fri, 23 Sep 2022 12:17:25 +0000 (14:17 +0200)] 
tests: extend native delinearize script

Feed nft-generated ruleset to iptables-nft.
At this time, this will NOT pass. because dissector can handle

  meta l4proto tcp ip saddr 1.2.3.4
but not
  ip saddr 1.2.3.4 meta l4proto tcp

In the latter case, iptables-nft picks up the immediate value (6) as the ip
address, because the first one (1.2.3.4) gets moved as PAYLOAD_PREV due to
missing 'removal' of the CTX_PAYLOAD flag.

This is error prone, so lets rewrite the dissector to track each
register separately and auto-clear state on writes.

Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Phil Sutter <phil@nwl.cc>
2 years agonft: track each register individually
Florian Westphal [Fri, 23 Sep 2022 12:17:08 +0000 (14:17 +0200)] 
nft: track each register individually

Instead of assuming only one register is used, track all 16 regs
individually.

This avoids need for the 'PREV_PAYLOAD' hack and also avoids the need to
clear out old flags:

When we see that register 'x' will be written to, that register state is
reset automatically.

Existing dissector decodes
ip saddr 1.2.3.4 meta l4proto tcp
... as
-s 6.0.0.0 -p tcp

iptables-nft -s 1.2.3.4 -p tcp is decoded correctly because the expressions
are ordered like:

meta l4proto tcp ip saddr 1.2.3.4
                                                                                                                                                                                                                   |
... and 'meta l4proto' did clear the PAYLOAD flag.

The simpler fix is:
ctx->flags &= ~NFT_XT_CTX_PAYLOAD;

in nft_parse_cmp(), but that breaks dissection of '1-42', because
the second compare ('cmp lte 42') will not find the
payload expression anymore.

Link: https://lore.kernel.org/netfilter-devel/20220922143544.GA22541@breakpoint.cc/T/#t
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Phil Sutter <phil@nwl.cc>
2 years agotests: shell: Test delinearization of native nftables expressions
Phil Sutter [Thu, 22 Sep 2022 17:04:32 +0000 (19:04 +0200)] 
tests: shell: Test delinearization of native nftables expressions

Even if iptables-nft doesn't generate them anymore, it should continue
to correctly parse them. Make sure this is tested for.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
2 years agoRevert "nft: prefer payload to ttl/hl module"/'meta pkttype' match.
Florian Westphal [Thu, 22 Sep 2022 14:14:51 +0000 (16:14 +0200)] 
Revert "nft: prefer payload to ttl/hl module"/'meta pkttype' match.

This reverts commit 8acaccf69c22fb195a0b88e28489792304728245.
This reverts commit 793caef9076cceb24336b6cbb8f55107de49f269.

As per ongoing discussion, keep the dissection side but keep using
nft_compat mode for now until we've figured out how to handle
backwards compatibility with older iptables-nft binaries dumping
the ruleset.

Furthermore, "nft: prefer native 'meta pkttype' instead of xt match"
broke ebtables: it has its own, incompatible pkttype match and needs
special handling.

Signed-off-by: Florian Westphal <fw@strlen.de>
2 years agonft: un-break among match with concatenation
Florian Westphal [Thu, 22 Sep 2022 11:33:50 +0000 (13:33 +0200)] 
nft: un-break among match with concatenation

The kernel commit 88cccd908d51 ("netfilter: nf_tables: NFTA_SET_ELEM_KEY_END requires concat and interval flags")
breaks ebtables-nft 'among' emulation, it sets NFTA_SET_ELEM_KEY_END but
doesn't set the CONCAT flag.

Update uapi header and also set CONCAT.

Signed-off-by: Florian Westphal <fw@strlen.de>
2 years agonft: prefer payload to ttl/hl module
Florian Westphal [Mon, 12 Sep 2022 08:58:46 +0000 (10:58 +0200)] 
nft: prefer payload to ttl/hl module

Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Phil Sutter <phil@nwl.cc>
2 years agonft: support ttl/hoplimit dissection
Florian Westphal [Mon, 12 Sep 2022 08:58:44 +0000 (10:58 +0200)] 
nft: support ttl/hoplimit dissection

xlate raw "nft ... ttl eq 1" and so on to the ttl/hl matches.

Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libxt_pkttype: support otherhost
Florian Westphal [Thu, 8 Sep 2022 15:12:42 +0000 (17:12 +0200)] 
extensions: libxt_pkttype: support otherhost

Makes no sense for iptables/ip6tables but it does make sense for ebtables.
Classic ebtables uses libebt_pkttype which isn't compatible, but
iptables-nft can use the libxt_pkttype version when printing native
'meta pkttype'.

Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Phil Sutter <phil@nwl.cc>
2 years agonft: prefer native 'meta pkttype' instead of xt match
Florian Westphal [Thu, 8 Sep 2022 15:12:41 +0000 (17:12 +0200)] 
nft: prefer native 'meta pkttype' instead of xt match

Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Phil Sutter <phil@nwl.cc>
2 years agonft: support dissection of meta pkktype mode
Florian Westphal [Thu, 8 Sep 2022 15:12:40 +0000 (17:12 +0200)] 
nft: support dissection of meta pkktype mode

Makes iptables-nft-save dump 'nft meta pkttype' rules.

Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Phil Sutter <phil@nwl.cc>
2 years agonft: Expand extended error reporting to nft_cmd, too
Phil Sutter [Fri, 26 Aug 2022 14:53:52 +0000 (16:53 +0200)] 
nft: Expand extended error reporting to nft_cmd, too

Introduce the same embedded 'error' struct in nft_cmd and initialize it
with the current value from nft_handle. Then in preparation phase,
update nft_handle's error.lineno with the value from the current
nft_cmd.

This serves two purposes:

* Allocated batch objects (obj_update) get the right lineno value
  instead of the COMMIT one.

* Any error during preparation may be reported with line number. Do this
  and change the relevant fprintf() call to use nft_handle's lineno
  instead of the global 'line' variable.

With this change, cryptic iptables-nft-restore error messages should
finally be gone:

| # iptables-nft-restore <<EOF
| *filter
| -A nonexist
| COMMIT
| EOF
| iptables-nft-restore: line 2 failed: No chain/target/match by that name.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoxtables-restore: Extend failure error message
Phil Sutter [Thu, 25 Aug 2022 09:53:04 +0000 (11:53 +0200)] 
xtables-restore: Extend failure error message

If a line causes zero 'ret' value and errno is set, call nft_strerror()
for a more detailed error message. While not perfect, it helps with
debugging ominous "line NN failed" messages pointing at COMMIT:

| # iptables-nft-restore <<EOF
| *filter
| -A nonexist
| COMMIT
| EOF
| iptables-nft-restore: line 3 failed: No chain/target/match by that name.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: add ebtables among testcase
Yi Chen [Wed, 3 Aug 2022 07:14:55 +0000 (09:14 +0200)] 
tests: add ebtables among testcase

Validate that matching works as expected.

Signed-off-by: Florian Westphal <fw@strlen.de>
2 years agonft: fix ebtables among match when mac+ip addresses are used
Florian Westphal [Tue, 2 Aug 2022 12:52:30 +0000 (14:52 +0200)] 
nft: fix ebtables among match when mac+ip addresses are used

When matching mac and ip addresses, the ip address needs to be placed
into then 2nd 32bit register, the switch to dynamic register allocation
instead re-uses reg1, this partially clobbers the mac address, so
set lookup comes up empty even though it should find a match.

Fixes: 7e38890c6b4fb ("nft: prepare for dynamic register allocation")
Reported-by: Yi Chen <yiche@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
3 years agoxshared: Print protocol numbers if --numeric was given
Phil Sutter [Thu, 28 Jul 2022 10:31:36 +0000 (12:31 +0200)] 
xshared: Print protocol numbers if --numeric was given

This is much trickier than expected: On one hand, proto_to_name() is
used to lookup protocol extensions so must resolve despite FMT_NUMERIC
being set. On the other, --verbose implies --numeric but changing the
output there is probably a bad idea. Luckily the latter situation is
identified by FMT_NOTABLE bit.

Signed-off-by: Phil Sutter <phil@nwl.cc>
3 years agoxshared: Fix for missing space after 'prot' column
Phil Sutter [Wed, 27 Jul 2022 12:14:23 +0000 (14:14 +0200)] 
xshared: Fix for missing space after 'prot' column

Format string ensured a minimum field width of five characters, but
allowed for longer strings to eat the column delimiting white space.

Signed-off-by: Phil Sutter <phil@nwl.cc>
3 years agotests: shell: Fix testcases for changed ip6tables opts output
Phil Sutter [Thu, 28 Jul 2022 11:02:50 +0000 (13:02 +0200)] 
tests: shell: Fix testcases for changed ip6tables opts output

Adjust captured output, ip6tables prints '--' instead of spaces since
the commit in Fixes: tag.

Fixes: 6e41c2d8747b2 ("iptables: xshared: Ouptut '--' in the opt field in ipv6's fake mode")
Signed-off-by: Phil Sutter <phil@nwl.cc>