]> git.ipfire.org Git - thirdparty/iptables.git/log
thirdparty/iptables.git
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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months agonft: More verbose extension comparison debugging
Phil Sutter [Fri, 21 Jul 2023 09:15:15 +0000 (11:15 +0200)] 
nft: More verbose extension comparison debugging

Dump extension data if it differs.

Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agonft: Special casing for among match in compare_matches()
Phil Sutter [Fri, 21 Jul 2023 11:14:36 +0000 (13:14 +0200)] 
nft: Special casing for among match in compare_matches()

When other extensions may have "garbage" appended to their data which
should not be considered for match comparison, among match is the
opposite in that it extends its data beyond the value in 'size' field.
Add special casing to cover for this, avoiding false-positive rule
comparison.

Fixes: 26753888720d8 ("nft: bridge: Rudimental among extension support")
Signed-off-by: Phil Sutter <phil@nwl.cc>
23 months agotests: shell: Sanitize nft-only/0009-needless-bitwise_0
Phil Sutter [Wed, 19 Jul 2023 12:58:11 +0000 (14:58 +0200)] 
tests: shell: Sanitize nft-only/0009-needless-bitwise_0

Some versions of awk (gawk-4.2.1-4.el8 in particular) also print the
non-debug ruleset listing's empty lines, causing the diff to fail. Catch
this by exiting upon seeing the first table heading. For the sake of
comparing bytecode, the actual ruleset listing is not interesting,
anyway.

Fixes: 0f7ea0390b336 ("tests/shell: Fix nft-only/0009-needless-bitwise_0")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft-bridge: pass context structure to ops->add() to improve anonymous set support
Pablo Neira Ayuso [Tue, 11 Jul 2023 20:06:44 +0000 (22:06 +0200)] 
nft-bridge: pass context structure to ops->add() to improve anonymous set support

Add context structure to improve bridge among support which creates an
anonymous set. This context structure specifies the command and it
allows to optionally store a anonymous set.

Use this context to generate native bytecode only if this is an
add/insert/replace command.

This fixes a dangling anonymous set that is created on rule removal.

Fixes: 26753888720d ("nft: bridge: Rudimental among extension support")
Reported-and-tested-by: Igor Raits <igor@gooddata.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2 years agoiptables: Fix handling of non-existent chains
Jacek Tomasiak [Mon, 19 Jun 2023 11:46:36 +0000 (13:46 +0200)] 
iptables: Fix handling of non-existent chains

Since 694612adf87 the "compatibility" check considers non-existent
chains as "incompatible". This broke some scripts which used calls
like `iptables -L CHAIN404` to test for chain existence and expect
"No chain/target/match by that name." in the output.

This patch changes the logic of `nft_is_table_compatible()` to
report non-existent chains as "compatible" which restores the old
behavior.

Fixes: 694612adf87 ("nft: Fix selective chain compatibility checks")
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1648
Signed-off-by: Jacek Tomasiak <jtomasiak@arista.com>
Signed-off-by: Jacek Tomasiak <jacek.tomasiak@gmail.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoiptables: Fix setting of ipv6 counters
Jacek Tomasiak [Mon, 19 Jun 2023 10:44:54 +0000 (12:44 +0200)] 
iptables: Fix setting of ipv6 counters

When setting counters using ip6tables-nft -c X Y the X and Y values were
not stored.

This is a fix based on 9baf3bf0e77dab6ca4b167554ec0e57b65d0af01 but
applied to the nft variant of ipv6 not the legacy.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1647
Fixes: 0391677c1a0b2 ("xtables: add IPv6 support")
Signed-off-by: Jacek Tomasiak <jtomasiak@arista.com>
Signed-off-by: Jacek Tomasiak <jacek.tomasiak@gmail.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoxshared: dissolve should_load_proto
Jan Engelhardt [Tue, 30 May 2023 16:11:09 +0000 (18:11 +0200)] 
xshared: dissolve should_load_proto

cs->proto_used already tells whether -p foo was turned into an
implicit -m foo once, so I do not think should_load_proto() has a
reason to exist.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: use payload matching for layer 4 protocol
Pablo Neira Ayuso [Fri, 9 Jun 2023 10:30:30 +0000 (12:30 +0200)] 
nft: use payload matching for layer 4 protocol

This is an IPv4 header, which does not require the special handling
as in IPv6, use the payload matching instead of meta l4proto which
is slightly faster in this case.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoman: string: document BM false negatives
Jeremy Sowden [Sun, 11 Jun 2023 11:34:29 +0000 (12:34 +0100)] 
man: string: document BM false negatives

For non-linear skb's there's a possibility that the kernel's Boyer-Moore
text-search implementation may miss matches.  There's a warning about
this in the kernel source.  Include that warning in the man-page.

Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1390
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: check for source and destination address in first place
Pablo Neira Ayuso [Thu, 1 Jun 2023 19:28:28 +0000 (21:28 +0200)] 
nft: check for source and destination address in first place

When generating bytecode, check for source and destination address in
first place, then, check for the input and output device. In general,
the first expression in the rule is the most evaluated during the
evaluation process. These selectors are likely to show more variability
in rulesets.

 # iptables-nft -vv -I INPUT -s 1.2.3.4 -p tcp
  tcp opt -- in * out *  1.2.3.4  -> 0.0.0.0/0
table filter ip flags 0 use 0 handle 0
ip filter INPUT use 0 type filter hook input prio 0 policy accept packets 0 bytes 0
ip filter INPUT
  [ payload load 4b @ network header + 12 => reg 1 ]
  [ cmp eq reg 1 0x04030201 ]
  [ meta load l4proto => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ counter pkts 0 bytes 0 ]

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: ruleparse: Create family-specific source files
Phil Sutter [Fri, 21 Apr 2023 13:52:14 +0000 (15:52 +0200)] 
nft: ruleparse: Create family-specific source files

Extract the remaining nftnl rule parsing code from
nft-<family>.c sources into dedicated ones to complete the separation.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: Extract rule parsing callbacks from nft_family_ops
Phil Sutter [Wed, 29 Mar 2023 16:26:23 +0000 (18:26 +0200)] 
nft: Extract rule parsing callbacks from nft_family_ops

Introduce struct nft_ruleparse_ops holding the family-specific
expression parsers and integrate it into nft_family_ops for now.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: Introduce nft-ruleparse.{c,h}
Phil Sutter [Wed, 29 Mar 2023 15:53:11 +0000 (17:53 +0200)] 
nft: Introduce nft-ruleparse.{c,h}

Extract all code dealing with parsing from struct nftnl_rule into struct
iptables_command_state from nft-shared.c into a separate source file.

Basically this is nft_rule_to_iptables_command_state() and the functions
it calls, plus family-independent parsers called from family-specific
callbacks.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoxshared: Fix parsing of option arguments in same word
Phil Sutter [Fri, 28 Apr 2023 12:41:08 +0000 (14:41 +0200)] 
xshared: Fix parsing of option arguments in same word

When merging commandline parsers, a decision between 'argv[optind - 1]'
and 'optarg' had to be made in some spots. While the implementation of
check_inverse() required the former, use of the latter allows for the
common syntax of '--opt=arg' or even '-oarg' as 'optarg' will point at
the suffix while 'argv[optind - 1]' will just point at the following
option.

Fix the mess by making check_inverse() update optarg pointer if needed
so calling code may refer to and always correct 'optarg'.

Fixes: 0af80a91b0a98 ("nft: Merge xtables-arp-standalone.c into xtables-standalone.c")
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1677
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoarptables: Don't omit standard matches if inverted
Phil Sutter [Fri, 28 Apr 2023 12:37:47 +0000 (14:37 +0200)] 
arptables: Don't omit standard matches if inverted

Inverted --h-len and --h-type matches were omitted from output by
accident if they matched on their standard value.

Fixes: 84331e3ed3f8e ("arptables-nft: Don't print default h-len/h-type values")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoarptables: Fix parsing of inverted 'arp operation' match
Phil Sutter [Fri, 28 Apr 2023 12:33:43 +0000 (14:33 +0200)] 
arptables: Fix parsing of inverted 'arp operation' match

The wrong bit was set in 'invflags', probably due to copy'n'paste from
the previous case.

Fixes: 84909d171585d ("xtables: bootstrap ARP compatibility layer for nftables")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft-shared: Drop unused include
Phil Sutter [Wed, 29 Mar 2023 14:22:16 +0000 (16:22 +0200)] 
nft-shared: Drop unused include

Code does not refer to struct xt_comment_info anymore.

Fixes: 3bb497c61d743 ("xtables: Fix for deleting rules with comment")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoutils: nfbpf_compile: Replace pcap_compile_nopcap()
Phil Sutter [Fri, 21 Apr 2023 13:53:43 +0000 (15:53 +0200)] 
utils: nfbpf_compile: Replace pcap_compile_nopcap()

The function is deprecated. Eliminate the warning by use of
pcap_open_dead(), pcap_compile() and pcap_close() just how
pcap_compile_nopcap() is implemented internally in libpcap.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: shell: Test for false-positive rule check
Phil Sutter [Wed, 5 Apr 2023 11:18:24 +0000 (13:18 +0200)] 
tests: shell: Test for false-positive rule check

Rule comparison in legacy ip6tables was broken by commit eb2546a846776
("xshared: Share make_delete_mask() between ip{,6}tables"): A part of
the rules' data was masked out for comparison by accident.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables-nft: add broute table emulation
Florian Westphal [Tue, 4 Apr 2023 09:45:44 +0000 (11:45 +0200)] 
ebtables-nft: add broute table emulation

Use new 'meta broute set 1' to emulate -t broute.  If '-t broute' is given,
automatically translate -j DROP to 'meta broute set 1 accept' internally.

Reverse translation zaps the broute and pretends verdict was DROP.

Note that BROUTING is internally handled via PREROUTING, i.e. 'redirect'
and 'nat' targets are not available, they will need to be emulated via
nft expressions.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoinclude: update nf_tables uapi header
Florian Westphal [Tue, 4 Apr 2023 09:45:43 +0000 (11:45 +0200)] 
include: update nf_tables uapi header

Taken from nf-next.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agobuild: use pkg-config for libpcap
Alyssa Ross [Sun, 2 Apr 2023 23:29:40 +0000 (23:29 +0000)] 
build: use pkg-config for libpcap

If building statically, with libpcap built with libnl support, linking
will fail, as the compiler won't be able to find the libnl symbols
since static libraries don't contain dependency information.  To fix
this, use pkg-config to find the flags for linking libpcap, since the
pkg-config files contain the neccesary dependency information.

autoconf will add code to the configure script for initializing
pkg-config the first time it seems PKG_CHECK_MODULES, so make the
libnfnetlink check the first one in the script, so the initialization
code is run unconditionally.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoip6tables: Fix checking existence of rule
Markus Boehme [Mon, 3 Apr 2023 21:13:47 +0000 (23:13 +0200)] 
ip6tables: Fix checking existence of rule

Pass the proper entry size when creating a match mask for checking the
existence of a rule. Failing to do so causes wrong results.

Reported-by: Jonathan Caicedo <jonathan@jcaicedo.com>
Fixes: eb2546a846776 ("xshared: Share make_delete_mask() between ip{,6}tables")
Signed-off-by: Markus Boehme <markubo@amazon.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoiptables-test.py: make explicit use of python3
Arturo Borrero Gonzalez [Sat, 14 Jan 2023 20:59:47 +0000 (21:59 +0100)] 
iptables-test.py: make explicit use of python3

In most distros 'python' means python2, which is not available anywhere.
This is a problem when, for example, building the Debian package. This
script is called as part of the build but 'python' is not available.

Mention python3 explictly. The script runs just fine in python3.

Signed-off-by: Arturo Borrero Gonzalez <arturo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
2 years agoiptables-nft: remove unused function argument
Florian Westphal [Wed, 15 Mar 2023 07:33:39 +0000 (08:33 +0100)] 
iptables-nft: remove unused function argument

Not used, all callers pass NULL.

Signed-off-by: Florian Westphal <fw@strlen.de>
2 years agoiptables-nft: make builtin tables static
Florian Westphal [Tue, 14 Mar 2023 21:44:53 +0000 (22:44 +0100)] 
iptables-nft: make builtin tables static

Only used in nft.c.

Signed-off-by: Florian Westphal <fw@strlen.de>
2 years agoxtables-eb: fix crash when opts isn't reallocated
Florian Westphal [Tue, 14 Mar 2023 21:36:50 +0000 (22:36 +0100)] 
xtables-eb: fix crash when opts isn't reallocated

opts may point to statically allocated memory.
This fixes abort() from libc.

Signed-off-by: Florian Westphal <fw@strlen.de>
2 years agonft-restore: Fix for deletion of new, referenced rule
Phil Sutter [Tue, 28 Feb 2023 17:09:25 +0000 (18:09 +0100)] 
nft-restore: Fix for deletion of new, referenced rule

Combining multiple corner-cases here:

* Insert a rule before another new one which is not the first. Triggers
  NFTNL_RULE_ID assignment of the latter.

* Delete the referenced new rule in the same batch again. Causes
  overwriting of the previously assigned RULE_ID.

Consequently, iptables-nft-restore fails during *insert*, because the
reference is dangling.

Reported-by: Eric Garver <eric@garver.life>
Fixes: 760b35b46e4cc ("nft: Fix for add and delete of same rule in single batch")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Tested-by: Eric Garver <eric@garver.life>
2 years agoinclude: Add missing linux/netfilter/xt_LOG.h
Phil Sutter [Wed, 22 Feb 2023 15:36:16 +0000 (16:36 +0100)] 
include: Add missing linux/netfilter/xt_LOG.h

When merging IP-version-specific LOG extensions, a dependency to that
header was introduced without caching it. Fix this and drop the now
unused ip{,6}t_LOG.h files.

Reported-by: Thomas Devoogdt <thomas@devoogdt.com>
Fixes: 87e4f1bf0b87b ("extensions: libip*t_LOG: Merge extensions")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoxt_sctp: add the missing chunk types in sctp_help
Xin Long [Tue, 21 Feb 2023 17:19:42 +0000 (12:19 -0500)] 
xt_sctp: add the missing chunk types in sctp_help

Add the missing chunk types in sctp_help(), so that the help cmd can
display these chunk types as below:

  # iptables -p sctp --help

  chunktypes - ... I_DATA RE_CONFIG PAD ... I_FORWARD_TSN ALL NONE

Fixes: 6b04d9c34e25 ("xt_sctp: support a couple of new chunk types")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoxtables-translate: Support insert with index
Phil Sutter [Fri, 3 Feb 2023 17:25:21 +0000 (18:25 +0100)] 
xtables-translate: Support insert with index

Translation is pretty simple due to nft's 'insert rule ... index'
support. Testing the translation is sadly not: index 1 vanishes (as it
should), higher indexes are rejected in replay mode since no rules
previously exist.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables: ip and ip6 matches depend on protocol match
Phil Sutter [Fri, 3 Feb 2023 19:08:09 +0000 (20:08 +0100)] 
ebtables: ip and ip6 matches depend on protocol match

This is consistent with legacy ebtables, also avoids invalid
combinations like '-p IPv6 --ip-source 1.2.3.4'.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libebt_ip: Translation has to match on ether type
Phil Sutter [Fri, 3 Feb 2023 16:37:40 +0000 (17:37 +0100)] 
extensions: libebt_ip: Translation has to match on ether type

On one hand, nft refuses th expression in bridge family if layer3
protocol has not been assured by a previous match. On the other, ebt_ip
kernel module will only match on IPv4 packets, so there might be a
functional change in the translation versus the original.

Instead of just always emitting an 'ether type' match, decide whether
it's actually needed - explicit "ip <something>" payload matches (or
icmp ones) cause implicit creation of a match on IPv4 by nft.

Fixes: 03ecffe6c2cc0 ("ebtables-compat: add initial translations")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libebt_ip: Do not use 'ip dscp' for translation
Phil Sutter [Fri, 3 Feb 2023 17:58:36 +0000 (18:58 +0100)] 
extensions: libebt_ip: Do not use 'ip dscp' for translation

Converting from TOS field match to DSCP one is irreversible, so replay
testing is not possible. Use a raw payload expression to produce
something that translates 1:1 back into an 'ip' match.

Fixes: 03ecffe6c2cc0 ("ebtables-compat: add initial translations")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libebt_redirect: Fix for wrong syntax in translation
Phil Sutter [Tue, 31 Jan 2023 22:32:50 +0000 (23:32 +0100)] 
extensions: libebt_redirect: Fix for wrong syntax in translation

Meta key comes before 'set' in meta statement.

Fixes: 24ce7465056ae ("ebtables-compat: add redirect match extension")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: libebt_redirect: Fix target translation
Phil Sutter [Tue, 31 Jan 2023 21:28:24 +0000 (22:28 +0100)] 
extensions: libebt_redirect: Fix target translation

While EBT_ACCEPT is the default verdict for ebtables targets, omitting
it from translation implicitly converts it into 'continue'. Omit the
non-default EBT_CONTINUE instead.

Fixes: 24ce7465056ae ("ebtables-compat: add redirect match extension")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: xlate: Print file names even if specified
Phil Sutter [Wed, 1 Feb 2023 00:49:37 +0000 (01:49 +0100)] 
tests: xlate: Print file names even if specified

Since the script now supports running for multiple files given on
command line, do not skip printing a status line for each.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: xlate: Properly split input in replay mode
Phil Sutter [Fri, 3 Feb 2023 17:48:33 +0000 (18:48 +0100)] 
tests: xlate: Properly split input in replay mode

Source command may contain quotes, using shlex.split() does the right
thing there.

Fixes: 7705b2daa3bdc ("tests: xlate: Use --check to verify replay")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft-shared: Simplify using nft_create_match()
Phil Sutter [Thu, 16 Feb 2023 21:24:16 +0000 (22:24 +0100)] 
nft-shared: Simplify using nft_create_match()

Perform the nft_family_ops::parse_match call from inside
nft_create_match(). It frees callers from having to access the match
itself.
Then return a pointer to match data instead of the match itself.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft-shared: Use nft_create_match() in one more spot
Phil Sutter [Thu, 16 Feb 2023 21:05:24 +0000 (22:05 +0100)] 
nft-shared: Use nft_create_match() in one more spot

By dropping the per-family 'cs->matches' selection (which is the default
anyway), code becomes identical to the function's body.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft-shared: Lookup matches in iptables_command_state
Phil Sutter [Thu, 16 Feb 2023 20:55:54 +0000 (21:55 +0100)] 
nft-shared: Lookup matches in iptables_command_state

Some matches may turn into multiple nft statements (naturally or via
translation). Such statements must parse into a single extension again
in order to rebuild the rule as it was.

Introduce nft_find_match_in_cs() to iterate through the lists and drop
tcp/udp port match caching in struct nft_xt_ctx which is not needed
anymore.

Note: Match reuse is not enabled unconditionally for all matches,
because iptables supports having multiple instances of the same
extension.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: CLUSTERIP: Drop test file
Phil Sutter [Sat, 11 Feb 2023 07:32:49 +0000 (08:32 +0100)] 
tests: CLUSTERIP: Drop test file

The extension was removed from kernel, do not test for it anymore. Keep
the code alive though, to not break existing setups.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: xlate: Support testing multiple individual files
Phil Sutter [Wed, 25 Jan 2023 12:52:48 +0000 (13:52 +0100)] 
tests: xlate: Support testing multiple individual files

Simple use-case: run xlate-test for ebtables-nft:

| % ./xlate-test.py extensions/libebt_*.txlate

The script interpreted all parameters as a single file.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables-translate: Print flush command after parsing is finished
Phil Sutter [Thu, 26 Jan 2023 02:27:16 +0000 (03:27 +0100)] 
ebtables-translate: Print flush command after parsing is finished

Otherwise, bad calls like 'ebtables-translate -F -F' produce wrong
output instead of an error message.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables-translate: Ignore '-j CONTINUE'
Phil Sutter [Thu, 26 Jan 2023 02:07:33 +0000 (03:07 +0100)] 
ebtables-translate: Ignore '-j CONTINUE'

It is default behaviour. Does not hurt here, but reducing diff to
xtables-eb.c can't hurt.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables-translate: Use OPT_* from xshared.h
Phil Sutter [Thu, 26 Jan 2023 01:59:59 +0000 (02:59 +0100)] 
ebtables-translate: Use OPT_* from xshared.h

Same as commit db420e268735e ("ebtables: Merge OPT_* flags with xshared
ones") but also introduce 'table_set' as a replacement for OPT_TABLE.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables-translate: Drop exec_style
Phil Sutter [Thu, 26 Jan 2023 01:43:31 +0000 (02:43 +0100)] 
ebtables-translate: Drop exec_style

Apply the changes from commit 816bd1fdecb63 ("ebtables-nft: remove
exec_style") to ebtables-translate, too.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables: Refuse unselected targets' options
Phil Sutter [Wed, 25 Jan 2023 01:01:56 +0000 (02:01 +0100)] 
ebtables: Refuse unselected targets' options

Unlike legacy, ebtables-nft would allow e.g.:

| -t nat -A PREROUTING --to-dst fe:ed:00:00:ba:be

While the result is correct, it may mislead users into believing
multiple targets are possible per rule. Better follow legacy's behaviour
and reject target options unless they have been "enabled" by a previous
'-j' option.

To achieve this, one needs to distinguish targets from watchers also
attached to 'xtables_targets' and otherwise behaving like regular
matches. Introduce XTABLES_EXT_WATCHER to mark the two.

The above works already, but error messages are misleading when using
the now unsupported syntax since target options have been merged
already. Solve this by not pre-loading the targets at all, code will
just fall back to loading ad '-j' parsing time as iptables does.

Note how this also fixes for 'counter' statement being in wrong position
of ebtables-translate output.

Fixes: fe97f60e5d2a9 ("ebtables-compat: add watchers support")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoProper fix for "unknown argument" error message
Phil Sutter [Wed, 25 Jan 2023 00:51:43 +0000 (01:51 +0100)] 
Proper fix for "unknown argument" error message

While commit 1b8210f848631 kind of fixed the corner-case of invalid
short-options packed with others, it broke error reporting for
long-options. Revert it and deploy a proper solution:

When passing an invalid short-option, e.g. 'iptables -vaL', getopt_long
sets the variable 'optopt' to the invalid character's value. Use it for
reporting instead of optind if set.

To distinguish between invalid options and missing option arguments,
ebtables-translate optstring needs adjustment.

Fixes: 1b8210f848631 ("ebtables: Fix error message for invalid parameters")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoetc: Drop xtables.conf
Phil Sutter [Tue, 17 Jan 2023 15:38:43 +0000 (16:38 +0100)] 
etc: Drop xtables.conf

The file is not used since the commit this one fixes. Also it wasn't
installed until recently, when commit 3822a992bc277 ("Makefile: Fix for
'make distcheck'") added it in the wrong spot in an attempt to reduce
differences between tarballs generated by 'make tarball' and 'make
dist'.

While being at it, drop stale xtables_config_main() prototype from
xtables-multi.h.

Fixes: 06fd5e46d46f7 ("xtables: Drop support for /etc/xtables.conf")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoextensions: NAT: Fix for -Werror=format-security
Phil Sutter [Thu, 12 Jan 2023 13:38:44 +0000 (14:38 +0100)] 
extensions: NAT: Fix for -Werror=format-security

Have to pass either a string literal or format string to xt_xlate_add().

Fixes: f30c5edce0413 ("extensions: Merge SNAT, DNAT, REDIRECT and MASQUERADE")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoconfigure: Bump version for 1.8.9 release v1.8.9
Phil Sutter [Tue, 10 Jan 2023 16:46:43 +0000 (17:46 +0100)] 
configure: Bump version for 1.8.9 release

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoMakefile: Replace brace expansion
Phil Sutter [Tue, 10 Jan 2023 16:27:42 +0000 (17:27 +0100)] 
Makefile: Replace brace expansion

According to bash(1), it is not supported by "historical versions of
sh". Dash seems to be such a historical version.

Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
Fixes: 3822a992bc277 ("Makefile: Fix for 'make distcheck'")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoebtables-translate: Install symlink
Phil Sutter [Thu, 22 Dec 2022 16:14:34 +0000 (17:14 +0100)] 
ebtables-translate: Install symlink

Make this officially a tool, we have enough test coverage in place. Also
update xtables-translate.8 to mention it at least and generate
ebtables-translate.8 which points to it.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agogitignore: Ignore generated ip6tables man pages
Phil Sutter [Thu, 22 Dec 2022 16:19:05 +0000 (17:19 +0100)] 
gitignore: Ignore generated ip6tables man pages

Fixes: 127eadee563e4 ("Makefile: Generate ip6tables man pages on the fly")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agogitignore: Ignore utils/nfsynproxy
Phil Sutter [Thu, 22 Dec 2022 16:23:49 +0000 (17:23 +0100)] 
gitignore: Ignore utils/nfsynproxy

Fixes: 9e6928f037823 ("utils: add nfsynproxy tool")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: Reject tcp/udp extension without proper protocol match
Phil Sutter [Thu, 22 Dec 2022 14:58:27 +0000 (15:58 +0100)] 
nft: Reject tcp/udp extension without proper protocol match

Internally, 'th' expression is used, which works but matches both
protocols. Since users won't expect '-m tcp --dport 1' to match UDP
packets, catch missing/wrong '-p' argument.

Fixes: c034cf31dd1a9 ("nft: prefer native expressions instead of udp match")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: Make rule parsing errors fatal
Phil Sutter [Thu, 15 Dec 2022 15:17:35 +0000 (16:17 +0100)] 
nft: Make rule parsing errors fatal

Finish parsing the rule, thereby printing all potential problems and
abort the program.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: Increase rule parser strictness
Phil Sutter [Thu, 15 Dec 2022 14:08:01 +0000 (15:08 +0100)] 
nft: Increase rule parser strictness

Catch more unexpected conditions.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoarptables: Check the mandatory ar_pln match
Phil Sutter [Thu, 15 Dec 2022 15:06:11 +0000 (16:06 +0100)] 
arptables: Check the mandatory ar_pln match

This match is added by nft_arp_add() to every rule with same value, so
when parsing just check it is as expected and otherwise ignore it. This
allows to treat matches on all other offsets/lengths as error.

Fixes: 84909d171585d ("xtables: bootstrap ARP compatibility layer for nftables")
Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agonft: Parse icmp header matches
Phil Sutter [Thu, 15 Dec 2022 12:20:21 +0000 (13:20 +0100)] 
nft: Parse icmp header matches

These were previously ignored.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agoMakefile.am: Integrate testsuites
Phil Sutter [Sat, 15 Oct 2022 10:25:28 +0000 (12:25 +0200)] 
Makefile.am: Integrate testsuites

Support calling 'make check' in topdir to run all three testsuites.
While updating .gitignore, also add 'configure~' my autotools create and
the tags file.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2 years agotests: Adjust testsuite return codes to automake guidelines
Phil Sutter [Sat, 15 Oct 2022 09:43:01 +0000 (11:43 +0200)] 
tests: Adjust testsuite return codes to automake guidelines

As per the manual[1]:

"When no test protocol is in use, an exit status of 0 from a test script
will denote a success, an exit status of 77 a skipped test, an exit
status of 99 a hard error, and any other exit status will denote a
failure."

[1] https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html

Signed-off-by: Phil Sutter <phil@nwl.cc>