]> git.ipfire.org Git - thirdparty/iptables.git/log
thirdparty/iptables.git
20 months agoman: Do not escape exclamation marks
Phil Sutter [Tue, 28 Nov 2023 12:29:17 +0000 (13:29 +0100)] 
man: Do not escape exclamation marks

This appears to be not necessary, also mandoc complains about it:

| mandoc: iptables/iptables-extensions.8:2170:52: UNSUPP: unsupported escape sequence: \!

Fixes: 71eddedcbf7ae ("libip6t_DNPT: add manpage")
Fixes: 0a4c357cb91e1 ("libip6t_SNPT: add manpage")
Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agonft: Leave interface masks alone when parsing from kernel
Phil Sutter [Fri, 17 Nov 2023 16:27:56 +0000 (17:27 +0100)] 
nft: Leave interface masks alone when parsing from kernel

The mask is entirely unused by nft-variants in general and legacy ones
when printing. It is relevant only when inserting a legacy rule into
kernel as it doesn't detect the '+'-suffix.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoxshared: Do not populate interface masks per default
Phil Sutter [Sat, 18 Nov 2023 03:28:25 +0000 (04:28 +0100)] 
xshared: Do not populate interface masks per default

These are needed by legacy variants only, so introduce a simplified
xtables_parse_interface() replacement which does not deal with them and
a small function which sets the mask based on given interface name for
use by legacy tools.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoxshared: Entirely ignore interface masks when saving rules
Phil Sutter [Wed, 15 Nov 2023 12:55:08 +0000 (13:55 +0100)] 
xshared: Entirely ignore interface masks when saving rules

Rule printing code does this for more than 20 years now, assume it's
safe to rely upon the wildcard interface name to contain a '+' suffix.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoxshared: Simplify generic_opt_check()
Phil Sutter [Fri, 17 Nov 2023 12:33:15 +0000 (13:33 +0100)] 
xshared: Simplify generic_opt_check()

The option/command matrix does not contain any '+' entries anymore, so
each option/command combination is either allowed (and optional) or not.

Reduce the matrix to an array of unsigned ints which specify the
commands a given option is allowed with.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoxshared: Introduce xt_cmd_parse_ops::option_invert
Phil Sutter [Tue, 14 Nov 2023 19:18:12 +0000 (20:18 +0100)] 
xshared: Introduce xt_cmd_parse_ops::option_invert

Replace the awkward inverse_for_options array with basically a few
switch() statements clearly identifying the relation between option and
inverse values and relieve callers from having to find the option flag
bit's position.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoxshared: Introduce xt_cmd_parse_ops::option_name
Phil Sutter [Tue, 14 Nov 2023 17:51:59 +0000 (18:51 +0100)] 
xshared: Introduce xt_cmd_parse_ops::option_name

The old opt2char() function was flawed: Since not every field in
optflags contains a printable character, typical use of its return value
in print statements could lead to garbage on screen.

Replace this by a mechanism to retrieve an option's long name which
supports family-specific overrides. and get rid of optflags field
altogether and define NUMBER_OF_OPT similar to NUMBER_OF_CMD.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoman: proper roff encoding for ~ and ^
Jan Engelhardt [Sat, 25 Nov 2023 16:12:50 +0000 (17:12 +0100)] 
man: proper roff encoding for ~ and ^

Fixes: v1.8.10-28-g4b0c168a
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Florian Westphal <fw@strlen.de>
20 months agoextensions: MARK: arptables: Use guided option parser
Phil Sutter [Fri, 3 Sep 2021 17:23:43 +0000 (19:23 +0200)] 
extensions: MARK: arptables: Use guided option parser

It expects mark values in hex which is possible by setting the base
field.

The only adjustment needed to use the revision 2 parser is to fill the
mask for --set-mark: With XTTYPE_MARKMASK32, an omitted mask sets all
mask bits, XTTYPE_UINT32 leaves it uninitialized, though.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoextensions: libarpt_mangle: Use guided option parser
Phil Sutter [Thu, 2 Sep 2021 14:53:26 +0000 (16:53 +0200)] 
extensions: libarpt_mangle: Use guided option parser

Sadly not the best conversion, struct arpt_mangle is not ideal for use
as storage backend: With MAC addresses, xtopt_parse_ethermac() refuses
to write into *_devaddr fields as they are larger than expected. With
XTTYPE_HOSTMASK OTOH, XTOPT_PUT is not supported in the first place.

As a side-effect, network names (from /etc/networks) are no longer
accepted. But earlier migrations to guided option parser had this
side-effect as well, so probably not a frequently used feature.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agolibxtables: Introduce struct xt_option_entry::base
Phil Sutter [Wed, 22 Nov 2023 19:43:40 +0000 (20:43 +0100)] 
libxtables: Introduce struct xt_option_entry::base

Enable guided option parser users to parse integer values with a fixed
base.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agolibxtables: Introduce xtables_strtoul_base()
Phil Sutter [Wed, 22 Nov 2023 19:41:34 +0000 (20:41 +0100)] 
libxtables: Introduce xtables_strtoul_base()

Semantically identical to xtables_strtoul() but accepts the base as
parameter so callers may force it irrespective of number prefix. The old
xtables_strtoul() becomes a shallow wrapper.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agolibxtables: Fix guided option parser for use with arptables
Phil Sutter [Thu, 2 Sep 2021 14:51:15 +0000 (16:51 +0200)] 
libxtables: Fix guided option parser for use with arptables

With an unexpected value in afinfo->family, guided option parser was
rather useless when called from arptables extensions. Introduce
afinfo_family() wrapper to sanitize at least NFPROTO_ARP value.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agolibxtables: Combine the two extension option mergers
Phil Sutter [Fri, 3 Sep 2021 21:43:41 +0000 (23:43 +0200)] 
libxtables: Combine the two extension option mergers

For extending the command parser's struct option array, there is
xtables_merge_options() and xtables_options_xfrm(). Since their bodies
were almost identical, make the latter a wrapper of the former by
transforming the passed struct xt_option_entry array into a temporary
struct option one before handing over.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoebtables: Implement --change-counters command
Phil Sutter [Tue, 21 Nov 2023 22:14:47 +0000 (23:14 +0100)] 
ebtables: Implement --change-counters command

Treat it like --replace against the same rule with changed counters.
The operation is obviously not atomic, so rule counters may change in
kernel while the rule is fetched, modified and replaced.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoxshared: do_parse: Ignore '-j CONTINUE'
Phil Sutter [Wed, 22 Nov 2023 02:58:18 +0000 (03:58 +0100)] 
xshared: do_parse: Ignore '-j CONTINUE'

While iptables does not support his NOP, arptables man page claims it
does (although legacy arptables rejects it) and ebtables prefers to
print it instead of omitting the '-j' option.

Accept and ignore the target when parsing to at least fix for
arptables-nft and prepare for ebtables-nft using do_parse() as well.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoebtables: Align line number formatting with legacy
Phil Sutter [Tue, 21 Nov 2023 21:58:47 +0000 (22:58 +0100)] 
ebtables: Align line number formatting with legacy

Legacy ebtables appends a dot to the number printed in first column if
--Ln flag was given.

Fixes: da871de2a6efb ("nft: bootstrap ebtables-compat")
Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoebtables: Make ebt_load_match_extensions() static
Phil Sutter [Wed, 22 Nov 2023 03:09:33 +0000 (04:09 +0100)] 
ebtables: Make ebt_load_match_extensions() static

The function is not used outside of xtables-eb.c.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoebtables: Drop append_entry() wrapper
Phil Sutter [Wed, 22 Nov 2023 02:49:09 +0000 (03:49 +0100)] 
ebtables: Drop append_entry() wrapper

There is no point in having it when there is no code to share.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agotests: xlate: Print failing command line
Phil Sutter [Sun, 19 Nov 2023 10:23:09 +0000 (11:23 +0100)] 
tests: xlate: Print failing command line

If the command segfaults, 'error' variable is empty and the resulting
error message is even misleading as the called program may not have been
iptables-translate.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoxshared: Drop pointless CMD_REPLACE check
Phil Sutter [Thu, 16 Nov 2023 16:03:10 +0000 (17:03 +0100)] 
xshared: Drop pointless CMD_REPLACE check

All current users set default source and destination addresses in their
post_parse callbacks, so legacy variants are safe and nft variants don't
have this restriction anyway.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoxshared: Drop needless assignment in --help case
Phil Sutter [Wed, 22 Nov 2023 02:54:24 +0000 (03:54 +0100)] 
xshared: Drop needless assignment in --help case

Help text printing code does not refer to optarg, so there is no need to
assign to it if unset.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoxshared: All variants support -v, update OPTSTRING_COMMON
Phil Sutter [Sun, 19 Nov 2023 12:25:36 +0000 (13:25 +0100)] 
xshared: All variants support -v, update OPTSTRING_COMMON

Fixes: 51d9d9e081344 ("ebtables: Support verbose mode")
Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoxshared: struct xt_cmd_parse::xlate is unused
Phil Sutter [Sun, 19 Nov 2023 12:18:26 +0000 (13:18 +0100)] 
xshared: struct xt_cmd_parse::xlate is unused

Drop the boolean, it was meant to disable some existence checks in
do_parse() prior to the caching rework. Now that do_parse() runs before
any caching is done, the checks in question don't exist anymore so drop
this relict.

Fixes: a7f1e208cdf9c ("nft: split parsing from netlink commands")
Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agonft-bridge: nft_bridge_add() uses wrong flags
Phil Sutter [Wed, 15 Nov 2023 16:41:50 +0000 (17:41 +0100)] 
nft-bridge: nft_bridge_add() uses wrong flags

When checking whether -s or -d was given, invflags were used by
accident. This change has no functional effect since the values remain
the same, but this way it's clear where the previously assigned flags
are used.

Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoMakefile: Install arptables-translate link and man page
Phil Sutter [Sun, 19 Nov 2023 10:20:55 +0000 (11:20 +0100)] 
Makefile: Install arptables-translate link and man page

While at it, introduce a variable to hold the various semantic links to
xtables-translate.8 man page.

Fixes: 5b7324e0675e3 ("nft-arp: add arptables-translate")
Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoman: more backslash-encoding of characters
Jan Engelhardt [Mon, 13 Nov 2023 10:17:35 +0000 (11:17 +0100)] 
man: more backslash-encoding of characters

"-" is the dash, "\-" is minus as we know, but groff lists some more
characters: "^" is "modifier circumflex" and "~" is "modifier tilde",
which, too, need to be escaped for our use.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
20 months agoman: limit targets for -P option synopsis
Jan Engelhardt [Mon, 13 Nov 2023 10:09:32 +0000 (11:09 +0100)] 
man: limit targets for -P option synopsis

Do not suggest that -P could be used with arbitrary targets.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
20 months agoman: copy synopsis markup from iptables.8 to arptables-nft.8
Jan Engelhardt [Mon, 13 Nov 2023 09:45:06 +0000 (10:45 +0100)] 
man: copy synopsis markup from iptables.8 to arptables-nft.8

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
20 months agoman: stop putting non-terminals in italic
Jan Engelhardt [Mon, 13 Nov 2023 10:08:28 +0000 (11:08 +0100)] 
man: stop putting non-terminals in italic

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
20 months agoman: repeal manual hyphenation
Jan Engelhardt [Mon, 13 Nov 2023 10:27:50 +0000 (11:27 +0100)] 
man: repeal manual hyphenation

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
20 months agoman: remove lone .nh command
Jan Engelhardt [Mon, 13 Nov 2023 09:20:50 +0000 (10:20 +0100)] 
man: remove lone .nh command

No other manpage files use .nh, and I cannot see a reason
iptables-apply would exceptionally need it.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
20 months agoman: consistent use of \(em in Name sections
Jan Engelhardt [Mon, 13 Nov 2023 09:19:03 +0000 (10:19 +0100)] 
man: consistent use of \(em in Name sections

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
20 months agoextensions: libarpt_standard.t: Add a rule with builtin option masks
Phil Sutter [Wed, 8 Nov 2023 03:26:42 +0000 (04:26 +0100)] 
extensions: libarpt_standard.t: Add a rule with builtin option masks

Just some random values in hope this starts failing if masks support
changes or breaks.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Florian Westphal <fw@strlen.de>
20 months agoarptables: Fix --proto-type mask formatting
Phil Sutter [Wed, 8 Nov 2023 03:08:44 +0000 (04:08 +0100)] 
arptables: Fix --proto-type mask formatting

Arptables accepts numeric --proto-type values and masks in any numeral
system identified by (absence of) prefix. Yet it prints the mask value
in hex without '0x'-prefix, breaking save and restore the same way
numeric --h-type output did.

In theory, this could be fixed either by adding the missing prefix or
printing the mask in decimal (like most other builtin matches do), but
since the value is printed in hex with prefix already, align mask output
with that.

Also a day 1 bug and consistent with legacy, so no Fixes: tag here as
well.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Florian Westphal <fw@strlen.de>
20 months agoarptables: Fix formatting of numeric --h-type output
Phil Sutter [Wed, 8 Nov 2023 02:58:42 +0000 (03:58 +0100)] 
arptables: Fix formatting of numeric --h-type output

Arptables expects numeric arguments to --h-type option in hexadecimal
form, even if no '0x'-prefix is present. In contrast, it prints such
values in decimal. This is not just inconsistent, but makes it
impossible to save and later restore a ruleset without fixing up the
values in between.

Assuming that the parser side can't be changed for compatibility
reasons, fix the output side instead.

This is a day 1 bug and present in legacy arptables as well, so treat
this as a "feature" of arptables-nft and omit a Fixes: tag.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Florian Westphal <fw@strlen.de>
20 months agoextensions: MARK: fix arptables support
Florian Westphal [Tue, 7 Nov 2023 11:15:40 +0000 (12:15 +0100)] 
extensions: MARK: fix arptables support

arptables "--set-mark" is really just "--or-mark".
This bug is also in arptables-legacy.

Fix this and add test cases.
Note that the test for "16" vs. "0x16" is intentional,
arptables parser is buggy and always uses "%x".

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoarptables-txlate: add test cases
Florian Westphal [Tue, 7 Nov 2023 11:15:39 +0000 (12:15 +0100)] 
arptables-txlate: add test cases

Add test cases for libarpt_mangle and extend the generic
tests to cover basic arptables matches.

Note that there are several historic artefacts that could be revised.
For example, arptables-legacy and arptables-nft both ignore "-p"
instead of returning an error about an unsupported option.

The ptype could be hard-wired to 0x800 and set unconditionally.
OTOH, this should always match for ethernet arp packets anyway.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agonft-arp: add arptables-translate
Florian Westphal [Tue, 7 Nov 2023 11:15:38 +0000 (12:15 +0100)] 
nft-arp: add arptables-translate

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agonft-arp: add missing mask support
Florian Westphal [Tue, 7 Nov 2023 11:15:37 +0000 (12:15 +0100)] 
nft-arp: add missing mask support

arptables-legacy supports masks for --h-type, --opcode
and --proto-type, but arptables-nft did not.

Add this.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoebtables: Fix corner-case noflush restore bug
Phil Sutter [Tue, 7 Nov 2023 18:12:14 +0000 (19:12 +0100)] 
ebtables: Fix corner-case noflush restore bug

Report came from firwalld, but this is actually rather hard to trigger.
Since a regular chain line prevents it, typical dump/restore use-cases
are unaffected.

Fixes: 73611d5582e72 ("ebtables-nft: add broute table emulation")
Cc: Eric Garver <eric@garver.life>
Signed-off-by: Phil Sutter <phil@nwl.cc>
20 months agoarptables-nft: remove ARPT_INV flags usage
Florian Westphal [Fri, 3 Nov 2023 16:33:22 +0000 (17:33 +0100)] 
arptables-nft: remove ARPT_INV flags usage

ARPT_ and IPT_INV flags are not interchangeable, e.g.:
define IPT_INV_SRCDEVADDR 0x0080
define ARPT_INV_SRCDEVADDR 0x0010

as these flags can be tested by libarp_foo.so such checks can yield
incorrect results.

Because arptables-nft uses existing code, e.g. xt_mark, it makes
sense to unify this completely by converting the last users of
ARPT_INV_ constants.

Note that arptables-legacy does not do run-time module loading via
dlopen(). Functionaliy implemented by "extensions" in the
arptables-legacy git tree are built-in, so this doesn't break
arptables-legacy binaries.

Fixes: 44457c080590 ("xtables-arp: Don't use ARPT_INV_*")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
21 months agoman: reveal rateest's combination categories
Phil Sutter [Tue, 24 Oct 2023 15:52:01 +0000 (17:52 +0200)] 
man: reveal rateest's combination categories

The .\" prefix made these paragraphs invisible in at least regular
man page output. Turn them into tags instead.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
21 months agoman: use .TP for lists in xt_osf man page
Phil Sutter [Tue, 24 Oct 2023 15:49:13 +0000 (17:49 +0200)] 
man: use .TP for lists in xt_osf man page

Value and description are more clearly set apart. Using .RS/.RE
pairs also adds proper indenting.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
21 months agoman: use native bullet point markup
Jan Engelhardt [Tue, 24 Oct 2023 13:16:40 +0000 (15:16 +0200)] 
man: use native bullet point markup

Replace some "fake" bullet point by the official syntax/markup
for bulleted lists.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
21 months agoman: grammar fixes to some manpages
Jan Engelhardt [Tue, 24 Oct 2023 13:06:37 +0000 (15:06 +0200)] 
man: grammar fixes to some manpages

English generally uses open compounds rather than closed ones;
fix the excess hyphens in words. Fix a missing dash for the
portnr option as well.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
21 months agoman: consistent casing of "IPv[46]"
Jan Engelhardt [Tue, 24 Oct 2023 13:14:54 +0000 (15:14 +0200)] 
man: consistent casing of "IPv[46]"

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
21 months agoman: encode hyphens the way groff/man requires it
Jan Engelhardt [Tue, 24 Oct 2023 13:04:03 +0000 (15:04 +0200)] 
man: encode hyphens the way groff/man requires it

Edit a few spots where indeed a hyphens (U+2010) rather than U+002D is desired.
("set-name" is not something you input, it is a placeholder in the context of
documentation. "out-of-flow" is part of the regular flowed text, so should not
use anything but hyphens.)

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
21 months agoman: encode emdash the way groff/man requires it
Jan Engelhardt [Tue, 24 Oct 2023 13:00:42 +0000 (15:00 +0200)] 
man: encode emdash the way groff/man requires it

Unlike LaTeX, two/three U+002D in the source do not translate to an
en and em-dash in man. Using \(en and \(em, respectively, addresses
this.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
21 months agoman: encode minushyphen the way groff/man requires it
Jan Engelhardt [Tue, 24 Oct 2023 12:58:06 +0000 (14:58 +0200)] 
man: encode minushyphen the way groff/man requires it

Sparked by a recent LWN article[1], sweeps over the iptables manpages
for incorrectly encoded dashes was made by Phil Sutter and myself.

An ASCII minushyphen in the source manpage translates to a hyphen in
output, so one has to use the sequence "\-" to get a minushyphen in
the output, as groff_char(7) explains.

[1] https://lwn.net/Articles/947941/ (paywalled until about 2023-11-06)

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
21 months agoman: display number ranges with an en dash
Jan Engelhardt [Thu, 26 Oct 2023 08:34:26 +0000 (10:34 +0200)] 
man: display number ranges with an en dash

For ranges, en dashes should be used; cf. e.g.
https://en.wikipedia.org/wiki/Dash#En_dash .

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
21 months agoextensions: string: Adjust description of --to to recent kernel changes
Phil Sutter [Tue, 24 Oct 2023 09:57:31 +0000 (11:57 +0200)] 
extensions: string: Adjust description of --to to recent kernel changes

This reverts commit 920ece2b392fb83bd26416e0e6f8f6a847aacbaa.

Since kernel commit c4eee56e14fe ("net: skb_find_text: Ignore patterns
extending past 'to'"), pattern scanning no longer happens past --to
offset even if skb_seq_read() returned a larger block. Point this out in
the description and also drop the '-1' offset which is not true as
kernel's selftest in tools/testing/selftests/netfilter/xt_string.sh
shows.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1707
Signed-off-by: Phil Sutter <phil@nwl.cc>
21 months agoextensions: string: Clarify description of --to
Phil Sutter [Thu, 12 Oct 2023 15:54:53 +0000 (17:54 +0200)] 
extensions: string: Clarify description of --to

String match indeed returns a match as long as the given pattern starts
in the range of --from and --to, update the text accordingly.
Also add a note regarding fragment boundaries.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1707
21 months agolibiptc: Fix for another segfault due to chain index NULL pointer
Phil Sutter [Thu, 12 Oct 2023 15:27:42 +0000 (17:27 +0200)] 
libiptc: Fix for another segfault due to chain index NULL pointer

Chain rename code missed to adjust the num_chains value which is used to
calculate the number of chain index buckets to allocate during an index
rebuild. So with the right number of chains present, the last chain in a
middle bucket being renamed (and ending up in another bucket) triggers
an index rebuild based on false data. The resulting NULL pointer index
bucket then causes a segfault upon reinsertion.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1713
Fixes: 64ff47cde38e4 ("libiptc: fix chain rename bug in libiptc")
21 months agoconfigure: Bump version for 1.8.10 release v1.8.10
Pablo Neira Ayuso [Tue, 10 Oct 2023 09:20:12 +0000 (11:20 +0200)] 
configure: Bump version for 1.8.10 release

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
22 months agobuild: Bump dependency on libnftnl
Phil Sutter [Fri, 29 Sep 2023 23:35:48 +0000 (01:35 +0200)] 
build: Bump dependency on libnftnl

Recently added support for broute table emulation requires libnftnl
version 1.2.6.

Fixes: 73611d5582e72 ("ebtables-nft: add broute table emulation")
Signed-off-by: Phil Sutter <phil@nwl.cc>
22 months agoinclude: linux: Update kernel.h
Phil Sutter [Wed, 6 Sep 2023 17:02:52 +0000 (19:02 +0200)] 
include: linux: Update kernel.h

Its contents were moved into const.h and sysinfo.h, apply these changes
to the cached copies. Fixes for the following warning when compiling
xtables-monitor.c with new kernel headers in /usr/include:

| In file included from ../include/linux/netfilter/x_tables.h:3,
|                  from ../include/xtables.h:19,
|                  from xtables-monitor.c:36:
| ../include/linux/kernel.h:7: warning: "__ALIGN_KERNEL" redefined
|     7 | #define __ALIGN_KERNEL(x, a)            __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
|       |
| In file included from /usr/include/linux/netlink.h:5,
|                  from /home/n0-1/git/libmnl/install/include/libmnl/libmnl.h:9,
|                  from xtables-monitor.c:30:
| /usr/include/linux/const.h:31: note: this is the location of the previous definition
|    31 | #define __ALIGN_KERNEL(x, a)            __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
|       |

Signed-off-by: Phil Sutter <phil@nwl.cc>
22 months agonft: Fix for useless meta expressions in rule
Phil Sutter [Wed, 6 Sep 2023 14:32:47 +0000 (16:32 +0200)] 
nft: Fix for useless meta expressions in rule

A relict of legacy iptables' mandatory matching on interfaces and IP
addresses is support for the '-i +' notation, basically a "match any
input interface". Trying to make things better than its predecessor,
iptables-nft boldly optimizes that nop away - not entirely though, the
meta expression loading the interface name was left in place. While not
a problem (apart from pointless overhead) in current HEAD, v1.8.7 would
trip over this as a following cmp expression (for another match) was
incorrectly linked to that stale meta expression, loading strange values
into the respective interface name field.

While being at it, merge and generalize the functions into a common one
for use with ebtables' NFT_META_BRI_(I|O)IFNAME matches, too.

Fixes: 0a8635183edd0 ("xtables-compat: ignore '+' interface name")
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1702
Signed-off-by: Phil Sutter <phil@nwl.cc>
22 months agotests: shell: Fix for ineffective 0007-mid-restore-flush_0
Phil Sutter [Fri, 1 Sep 2023 11:16:56 +0000 (13:16 +0200)] 
tests: shell: Fix for ineffective 0007-mid-restore-flush_0

The test did not catch non-zero exit status of the spawned coprocess. To
make it happen, Drop the line killing it (it will exit anyway) and pass
its PID to 'wait'.

While being at it, put the sleep into the correct spot (otherwise the
check for chain 'foo' existence fails as it runs too early) and make
said chain existence check effective.

Fixes: 4e3c11a6f5a94 ("nft: Fix for ruleset flush while restoring")
Signed-off-by: Phil Sutter <phil@nwl.cc>
22 months agoextensions: Fix checking of conntrack --ctproto 0
Quentin Armitage [Sat, 23 Nov 2013 08:41:58 +0000 (08:41 +0000)] 
extensions: Fix checking of conntrack --ctproto 0

There are three issues in the code:
1) the check (sinfo->invflags & XT_INV_PROTO) is using the wrong mask
2) in conntrack_mt_parse it is testing (info->invert_flags &
   XT_INV_PROTO) before the invert bit has been set.
3) the sense of the error message is the wrong way round

1) To get the error, ! -ctstatus XXX has to be specified, since
   XT_INV_PROTO == XT_CONNTRACK_STATUS e.g.
   | iptables -I CHAIN -m conntrack ! --ctstatus ASSURED --ctproto 0 ...

3) Unlike --proto 0 (where 0 means all protocols), in the conntrack
   match --ctproto 0 appears to mean protocol 0, which can never be.
   Therefore --ctproto 0 could never match and ! --ctproto 0 will always
   match. Both of these should be rejected, since the user clearly
   cannot be intending what was specified.

The attached patch resolves the issue, and also produces an error
message if --ctproto 0 is specified (as well as ! --ctproto 0 ), since
--ctproto 0 will never match, and ! --ctproto 0 will always match.

[Phil: - Added Fixes: tag - it's a day 1 bug
       - Copied patch description from Bugzilla
       - Reorganized changes to reduce diff
       - Added test cases]

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=874
Fixes: 5054e85be3068 ("general conntrack match module userspace support files")
Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
Signed-off-by: Phil Sutter <phil@nwl.cc>
22 months agoRevert --compat option related commits
Phil Sutter [Tue, 15 Aug 2023 11:47:28 +0000 (13:47 +0200)] 
Revert --compat option related commits

This reverts the following commits:

b14c971db6db0 ("tests: Test compat mode")
11c464ed015b5 ("Add --compat option to *tables-nft and *-nft-restore commands")
ca709b5784c98 ("nft: Introduce and use bool nft_handle::compat")
402b9b3c07c81 ("nft: Pass nft_handle to add_{target,action}()")

This implementation of a compatibility mode implements rules using
xtables extensions if possible and thus relies upon existence of those
in kernel space. Assuming no viable replacement for the internal
mechanics of this mode will be found in foreseeable future, it will
effectively block attempts at deprecating and removing of these xtables
extensions in favor of nftables expressions and thus hinder upstream's
future plans for iptables.

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agodoc: fix example of xt_cpu
Victor Julien [Tue, 29 Aug 2023 12:59:32 +0000 (14:59 +0200)] 
doc: fix example of xt_cpu

REDIRECT uses --to-ports instead of --to-port.

Fixes: 2d59208943a3 ("extension: add xt_cpu match")
Signed-off-by: Victor Julien <victor@inliniac.net>
Signed-off-by: Florian Westphal <fw@strlen.de>
23 months agotests: Test compat mode
Phil Sutter [Fri, 5 May 2023 18:18:38 +0000 (20:18 +0200)] 
tests: Test compat mode

Extend iptables-test.py by a third mode, which is using
xtables-nft-multi and passing --compat to all calls creating rules.

Also add a shell testcase asserting the effectiveness of --compat by
comparing debug (-vv) output.

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoAdd --compat option to *tables-nft and *-nft-restore commands
Phil Sutter [Fri, 5 May 2023 18:04:41 +0000 (20:04 +0200)] 
Add --compat option to *tables-nft and *-nft-restore commands

The flag sets nft_handle::compat boolean, indicating a compatible rule
implementation is wanted. Users expecting their created rules to be
fetched from kernel by an older version of *tables-nft may use this to
avoid potential compatibility issues.

Changes since v1:
- Expect short option '-C' in {ip,ip6,eb}tables-nft-restore command line
  parser
- Support -C/--compat in arptables-nft-restore, too
- Update man pages with the new flag

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agonft: Introduce and use bool nft_handle::compat
Phil Sutter [Fri, 5 May 2023 15:39:08 +0000 (17:39 +0200)] 
nft: Introduce and use bool nft_handle::compat

If set, create rules using compat expressions where possible and disable
the bitwise expression avoidance introduced in 323259001d617 ("nft:
Optimize class-based IP prefix matches").

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agonft: Pass nft_handle to add_{target,action}()
Phil Sutter [Fri, 5 May 2023 14:01:29 +0000 (16:01 +0200)] 
nft: Pass nft_handle to add_{target,action}()

Prepare for varying rule content based on a global flag.

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoUse SOCK_CLOEXEC/O_CLOEXEC where available
Phil Sutter [Tue, 8 Aug 2023 14:33:44 +0000 (16:33 +0200)] 
Use SOCK_CLOEXEC/O_CLOEXEC where available

No need for the explicit fcntl() call, request the behaviour when
opening the descriptor.

One fcntl() call setting FD_CLOEXEC remains in extensions/libxt_bpf.c,
the indirect syscall seems not to support passing the flag directly.

Reported-by: Gaurav Gupta <g.gupta@samsung.com>
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1104
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agotests: shell: Test chain policy counter behaviour
Phil Sutter [Thu, 10 Aug 2023 10:51:13 +0000 (12:51 +0200)] 
tests: shell: Test chain policy counter behaviour

Test the last two fixes in that area.

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoRevert "libiptc: fix wrong maptype of base chain counters on restore"
Phil Sutter [Thu, 3 Aug 2023 15:59:03 +0000 (17:59 +0200)] 
Revert "libiptc: fix wrong maptype of base chain counters on restore"

This reverts commit 7c4d668c9c2ee007c82063b7fc784cbbf46b2ec4.

The change can't be right: A simple rule append call will reset all
built-in chains' counters. The old code works fine even given the
mentioned "empty restore" use-case, at least if counters don't change on
the fly in-kernel.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=912
Fixes: 7c4d668c9c2ee ("libiptc: fix wrong maptype of base chain counters on restore")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agonft: Create builtin chains with counters enabled
Phil Sutter [Thu, 10 Aug 2023 09:30:59 +0000 (11:30 +0200)] 
nft: Create builtin chains with counters enabled

The kernel enables policy counters for nftables chains only if
NFTA_CHAIN_COUNTERS attribute is present. For this to be generated, one
has to set NFTNL_CHAIN_PACKETS and NFTNL_CHAIN_BYTES attributes in the
allocated nftnl_chain object.

The above happened for base chains only with iptables-nft-restore if
called with --counters flag. Since this is very unintuitive to users,
fix the situation by adding counters to base chains in any case.

Fixes: 384958620abab ("use nf_tables and nf_tables compatibility interface")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agotests: iptables-test: Fix command segfault reports
Phil Sutter [Wed, 26 Jul 2023 17:43:20 +0000 (19:43 +0200)] 
tests: iptables-test: Fix command segfault reports

Logging produced a stack trace due to undefined variable 'cmd'.

Fixes: 0e80cfea3762b ("tests: iptables-test: Implement fast test mode")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agonft-ruleparse: parse meta mark set as MARK target
Florian Westphal [Thu, 3 Aug 2023 19:39:13 +0000 (21:39 +0200)] 
nft-ruleparse: parse meta mark set as MARK target

Mixing nftables and iptables-nft in the same table doesn't work,
but some people do this.

v1.8.8 ignored rules it could not represent in iptables syntax,
v1.8.9 bails in this case.

Add parsing of meta mark expressions so iptables-nft can render them
as -j MARK rules.

This is flawed, nft has features that have no corresponding
syntax in iptables, but we can't undo this.

Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1659
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agonft-ruleparse: Introduce nft_create_target()
Phil Sutter [Tue, 31 Jan 2023 18:55:57 +0000 (19:55 +0100)] 
nft-ruleparse: Introduce nft_create_target()

Like nft_create_match(), this is a small wrapper around the typical
target extension lookup and (standard) init code.

To use it from nft_parse_target() and nft_parse_log(), introduce an
inner variant which accepts the target payload size as parameter.

The call to rule_parse_ops::target callback was problematic with
standard target, because the callbacks initialized
iptables_command_state::jumpto with the target name, "standard" in that
case. Perform its tasks in nft_create_target(), keep it only for bridge
family's special handling of watcher "targets".

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoextensions: libip6t_icmp: Add names for mld-listener types
Phil Sutter [Wed, 2 Aug 2023 09:31:56 +0000 (11:31 +0200)] 
extensions: libip6t_icmp: Add names for mld-listener types

Add the three names (plus one alias) just as in nftables.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1250
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agonft: move processing logic out of asserts
Jan Palus [Mon, 28 Dec 2020 09:59:42 +0000 (10:59 +0100)] 
nft: move processing logic out of asserts

[Phil: Introduce assert_nft_restart() to keep things clean, also add
       fallback returns to nft_action() and nft_prepare(), sanitizing
       things at least a bit.]

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1487
Signed-off-by: Jan Palus <atler@pld-linux.org>
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables-save.8: Start paragraphs in upper-case
Phil Sutter [Wed, 2 Aug 2023 00:06:00 +0000 (02:06 +0200)] 
man: iptables-save.8: Start paragraphs in upper-case

Also add a missing full stop.

Fixes: 117341ada43dd ("Added iptbles-restore and iptables-save manpages")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables-save.8: Fix --modprobe description
Phil Sutter [Wed, 2 Aug 2023 00:01:59 +0000 (02:01 +0200)] 
man: iptables-save.8: Fix --modprobe description

- Consistently use 'modprobe' as option argument name
- Add a reference to modprobe man page
- Put the path in italics and the command in bold

Fixes: fbb5639c02218 ("iptables-save: module loading corrections")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables-save.8: Clarify 'available tables'
Phil Sutter [Tue, 1 Aug 2023 23:55:08 +0000 (01:55 +0200)] 
man: iptables-save.8: Clarify 'available tables'

This appears to be confusing. Since a missing table is also not flushed
("restored") when feeding the dump into iptables-restore, such a restore
call may be considered incomplete.

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: Trivial: Missing space after comma
Phil Sutter [Tue, 1 Aug 2023 23:48:14 +0000 (01:48 +0200)] 
man: Trivial: Missing space after comma

Fixes: 6a79d78986c02 ("iptables: mention iptables-apply(8) in manpages")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables-restore.8: Start paragraphs in upper-case
Phil Sutter [Tue, 1 Aug 2023 23:40:17 +0000 (01:40 +0200)] 
man: iptables-restore.8: Start paragraphs in upper-case

Also add a missing full stop in one spot.

Fixes: 117341ada43dd ("Added iptbles-restore and iptables-save manpages")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables-restore.8: Put 'file' in italics in synopsis
Phil Sutter [Tue, 1 Aug 2023 23:37:09 +0000 (01:37 +0200)] 
man: iptables-restore.8: Put 'file' in italics in synopsis

The text has it this way already, be consistent.

Fixes: 081d57839e91e ("iptables-restore.8: file to read from can be specified as argument")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables-restore.8: Drop -W option from synopsis
Phil Sutter [Tue, 1 Aug 2023 23:34:51 +0000 (01:34 +0200)] 
man: iptables-restore.8: Drop -W option from synopsis

The description was dropped already, there is no benefit in still
listing it.

Fixes: 07e2107ef0cbc ("xshared: Implement xtables lock timeout using signals")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables-restore.8: Consistently document -w option
Phil Sutter [Tue, 1 Aug 2023 23:33:26 +0000 (01:33 +0200)] 
man: iptables-restore.8: Consistently document -w option

Use the same name for the option's argument.

Fixes: 65801d02a482b ("iptables-restore.8: document -w/-W options")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables-restore.8: Fix --modprobe description
Phil Sutter [Tue, 1 Aug 2023 23:27:11 +0000 (01:27 +0200)] 
man: iptables-restore.8: Fix --modprobe description

- Consistently use 'modprobe' as option argument name
- Add a reference to modprobe man page
- Put the path in italics, and the command in bold

Fixes: 8c46901ff5785 ("doc: document iptables-restore's -M option")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables.8: Trivial font fixes
Phil Sutter [Tue, 1 Aug 2023 22:49:03 +0000 (00:49 +0200)] 
man: iptables.8: Trivial font fixes

No content changes intended, just type commands in bold and the single
path reference in italics.

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: Use HTTPS for links to netfilter.org
Phil Sutter [Tue, 1 Aug 2023 22:41:38 +0000 (00:41 +0200)] 
man: Use HTTPS for links to netfilter.org

The browser is redirected there anyway, but who cares about such minor
details nowadays.

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables.8: Clarify --goto description
Phil Sutter [Tue, 1 Aug 2023 22:28:03 +0000 (00:28 +0200)] 
man: iptables.8: Clarify --goto description

Text speaks about behaviour of RETURN target when used in chains
redirected to using --goto instead of --jump, not the difference between
--jump option and "return".

Fixes: 17fc163babc34 ("add 'goto' support (Henrik Nordstrom <hno@marasystems.com>)")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables.8: Fix intra page reference
Phil Sutter [Tue, 1 Aug 2023 22:23:37 +0000 (00:23 +0200)] 
man: iptables.8: Fix intra page reference

When sections MATCH EXTENSIONS and TARGET EXTENSIONS were combined, the
reference could have been updated to specify the exact title.

Fixes: 4496801821c01 ("doc: deduplicate extension descriptions into a new manpage")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables.8: Trivial spelling fixes
Phil Sutter [Tue, 1 Aug 2023 22:05:45 +0000 (00:05 +0200)] 
man: iptables.8: Trivial spelling fixes

- Missing "and" as well as full stop
- Missing comma in enumeration
- Duplicate "previous"
- Confusions are avoided rather than simplified
- Missing space after comma

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoman: iptables.8: Extend exit code description
Phil Sutter [Tue, 1 Aug 2023 19:24:15 +0000 (21:24 +0200)] 
man: iptables.8: Extend exit code description

Codes 3 and 4 were missing.

Reported-by: Steven Barre <steven.barre@dxcas.com>
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1353
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agotests: libipt_icmp.t: Enable tests with numeric output
Phil Sutter [Tue, 1 Aug 2023 21:42:24 +0000 (23:42 +0200)] 
tests: libipt_icmp.t: Enable tests with numeric output

Unrelated to the question whether numeric (save) output is desired or
not, enable the tests and expect the known format.

Using --list without --numeric prints the names, BTW.

Fixes: 49d5b7277c7f2 ("extensions: libipt_icmp: add unit test")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agoextensions: libipt_icmp: Fix confusion between 255/255 and any
Phil Sutter [Tue, 1 Aug 2023 21:28:20 +0000 (23:28 +0200)] 
extensions: libipt_icmp: Fix confusion between 255/255 and any

Per definition, ICMP type "any" is type 255 and the full range of codes
(0-255). Save callback though ignored the actual code values, printing
"any" for every type 255 match. This at least confuses users as they
can't find their rule added as '--icmp-type 255/255' anymore.

It is not entirely clear what the fixed commit was trying to establish,
but the save output is certainly not correct (especially since print
callback gets things right).

Reported-by: Amelia Downs <adowns@vmware.com>
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1600
Fixes: fc9237da4e845 ("Fix '-p icmp -m icmp' issue (Closes: #37)")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoiptables-apply: Eliminate shellcheck warnings
Phil Sutter [Tue, 1 Aug 2023 14:56:42 +0000 (16:56 +0200)] 
iptables-apply: Eliminate shellcheck warnings

Actual warnings were only about use of '-a' in bracket expressions
(replace by '&&' pipeline) and the immediate evaluation of the variable
in trap command.

The remaining changes silence info-level messages: missing quoting
around variables, pointless '$' in arithmetic expressions, backticks
instead of $(...), missing '-r' parameter when calling read and an
awkward negated '-z' check.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoiptables-restore: Drop dead code
Phil Sutter [Thu, 13 Jul 2023 16:32:02 +0000 (18:32 +0200)] 
iptables-restore: Drop dead code

Handle initialization is guarded by 'in_table' boolean, so there can't
be a handle already (because the branch which unsets 'in_table' also
frees the handle).

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: shell: Fix and extend chain rename test
Phil Sutter [Fri, 28 Jul 2023 11:58:46 +0000 (13:58 +0200)] 
tests: shell: Fix and extend chain rename test

The old version exited unintentionally before testing ip6tables. Replace
it by a more complete variant testing for all tools, creating and
renaming of,chains with various illegal names instead of just renaming
to a clashing name.

Fixes: ed9cfe1b48526 ("tests: add initial save/restore test cases")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables: Improve invalid chain name detection
Phil Sutter [Fri, 28 Jul 2023 11:50:11 +0000 (13:50 +0200)] 
ebtables: Improve invalid chain name detection

Fix several issues:

- Most importantly, --new-chain command accepted any name. Introduce
  ebt_assert_valid_chain_name() for use with both --new-chain and
  --rename-chain.
- Restrict maximum name length to what legacy ebtables allows - this is
  a bit more than iptables-nft, subject to be unified.
- Like iptables, legacy ebtables rejects names prefixed by '-' or '!'.
- Use xs_has_arg() for consistency, keep the check for extra args for
  now.

Fixes: da871de2a6efb ("nft: bootstrap ebtables-compat")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years ago*tables: Reject invalid chain names when renaming
Phil Sutter [Fri, 21 Jul 2023 18:14:09 +0000 (20:14 +0200)] 
*tables: Reject invalid chain names when renaming

While given chain name was sanity checked with --new-chain command,
--rename-chain command allowed to choose an invalid name. Keep things
consistent by adding the missing check.

Fixes: e6869a8f59d77 ("reorganized tree after kernel merge")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years ago*tables-restore: Enforce correct counters syntax if present
Phil Sutter [Fri, 21 Jul 2023 17:40:30 +0000 (19:40 +0200)] 
*tables-restore: Enforce correct counters syntax if present

If '--counters' option was not given, restore parsers would ignore
anything following the policy word. Make them more strict, rejecting
anything in that spot which does not look like counter values even if
not restoring counters.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: Include sets in debug output
Phil Sutter [Sat, 15 Jul 2023 12:13:28 +0000 (14:13 +0200)] 
nft: Include sets in debug output

Rules referencing them are incomplete without, so add debug output on
the same level as for rules.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: Do not pass nft_rule_ctx to add_nft_among()
Phil Sutter [Fri, 14 Jul 2023 23:35:39 +0000 (01:35 +0200)] 
nft: Do not pass nft_rule_ctx to add_nft_among()

It is not used, must be a left-over from an earlier version of the fixed
commit.

Fixes: 4e95200ded923 ("nft-bridge: pass context structure to ops->add() to improve anonymous set support")
Signed-off-by: Phil Sutter <phil@nwl.cc>