<feed xmlns='http://www.w3.org/2005/Atom'>
<title>firewall4/tests/03_rules, branch master</title>
<subtitle>OpenWrt nftables firewall</subtitle>
<id>https://git.openwrt.org/project/firewall4/atom?h=master</id>
<link rel='self' href='https://git.openwrt.org/project/firewall4/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/firewall4/'/>
<updated>2026-11-02T23:25:34Z</updated>
<entry>
<title>fw4: support multiple ipset references per rule and redirect</title>
<updated>2026-11-02T23:25:34Z</updated>
<author>
<name>Philipp Raschdorff</name>
</author>
<published>2026-10-17T20:01:40Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/firewall4/commit/?id=7f34d9e0e6786174693d7bc6f9f9da05488ae5ae'/>
<id>urn:sha1:7f34d9e0e6786174693d7bc6f9f9da05488ae5ae</id>
<content type='text'>
The `list ipset` option has AND semantics: all listed references are AND-ed into one nft rule.

Co-Authored-By: Claude Fable 5.1 &lt;noreply@anthropic.com&gt;
Signed-off-by: Philipp Raschdorff &lt;p.raschdorff@googlemail.com&gt;
[shorten comment]
Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
<entry>
<title>fw4: reject unknown tokens in ipset references</title>
<updated>2026-11-02T23:15:59Z</updated>
<author>
<name>Philipp Raschdorff</name>
</author>
<published>2026-10-17T20:01:42Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/firewall4/commit/?id=daf6cf607cab1efbefca5715c9f781979c3664ba'/>
<id>urn:sha1:daf6cf607cab1efbefca5715c9f781979c3664ba</id>
<content type='text'>
parse_setmatch() ignores every token after the set name that is not a
direction (`src`, `dst`, `dest`). `option ipset 'setA setB'` is
therefore accepted as a reference to setA only, and the rule silently
matches fewer conditions than configured. With list support for the
option this mistake becomes likely.

Reject the value if it has more than three tokens or a token that is
not a direction. An invalid value drops the section with the usual
"specifies invalid value" warning (fail-closed).

This is a behaviour change: a configuration that relied on unknown
tokens being ignored loses the affected rule after the update. For an
ACCEPT rule that closes access; for a DROP or REJECT rule it removes
the block, which is the opposite of fail-closed. Both cases are reported
with a warning, but nothing else draws attention to them. If that risk
is considered too high, the alternative is to keep accepting the
reference and only warn about the ignored tokens; this patch is
submitted separately so that it can be discussed and dropped on its
own.

Co-Authored-By: Claude Fable 5.1 &lt;noreply@anthropic.com&gt;
Signed-off-by: Philipp Raschdorff &lt;p.raschdorff@googlemail.com&gt;
</content>
</entry>
<entry>
<title>ruleset: Add snat_port support for MASQUERADE</title>
<updated>2026-11-02T23:15:59Z</updated>
<author>
<name>HSXX</name>
</author>
<published>2025-10-21T11:43:23Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/firewall4/commit/?id=5474da96eb4432c363768a8b254a2a088acf8b9f'/>
<id>urn:sha1:5474da96eb4432c363768a8b254a2a088acf8b9f</id>
<content type='text'>
Currently, MASQUERADE in firewall4 does not support setting snat_port and directly reports an error without creating rules. This modification enables MASQUERADE to support setting snat_port.

Signed-off-by: HSXX &lt;513733973@qq.com&gt;
[folded fix: keep the masquerade branch alongside the npt prefix_map branch]
Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
<entry>
<title>ruleset: avoid no-op port translation in dnat</title>
<updated>2026-11-02T23:15:59Z</updated>
<author>
<name>Andris PE</name>
</author>
<published>2025-10-17T11:38:00Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/firewall4/commit/?id=613198bebd0b6e24b98bb9f8d39c7e12f7ceac0f'/>
<id>urn:sha1:613198bebd0b6e24b98bb9f8d39c7e12f7ceac0f</id>
<content type='text'>
Correct rport null propagation
 moving compensatory conditional to reflection snat rule only.
Emit shorthand rules if user did not specify redirect target port
This saves 2 bytecodes in rule and kernel does not do no-op port
rewrite.
V2 Adjust tests to cover more cases/code paths
V3 Adjust uci example to reflect default of not changing dport

Signed-off-by: Andris PE &lt;neandris@gmail.com&gt;
[folded fix: merge redirect test expectations with #104 and update ubus reflection expectations]
Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
<entry>
<title>firewall4: enable mac ranges for rule</title>
<updated>2026-11-02T23:15:59Z</updated>
<author>
<name>Christian Korber</name>
</author>
<published>2025-10-02T10:16:15Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/firewall4/commit/?id=ba2ae80a48c6287abea6da954c6cec10f58bfff4'/>
<id>urn:sha1:ba2ae80a48c6287abea6da954c6cec10f58bfff4</id>
<content type='text'>
nft supports handling mac ranges and therefore this commit changes fw4
to support that feature. The src_mac is now allowed to be a range of two
addresses. If no range is given, the old logic is applied.

So this is now possible:
```
option src_mac '00:11:AA:00:00:00-00:11:AA:FF:FF:FF'
```
In addition to the original:
```
option src_mac '00:11:AA:00:00:00'
```

This is done by changing the regex to parse for an additional MAC address
if '-' is matched after the first MAC address.

Negative matching using exclamation mark is supported.

Signed-off-by: Christian Korber &lt;ck@dev.tdt.de&gt;
[folded fix: reject malformed MAC ranges without a dash and add test coverage]
Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
<entry>
<title>redirect: preserve destination ipsets in NAT reflection</title>
<updated>2026-11-02T23:15:59Z</updated>
<author>
<name>Tigran Melikyan</name>
</author>
<published>2026-09-14T06:33:57Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/firewall4/commit/?id=3ab89e865b0dcc26fb1520abb8d9e2cba0615ba3'/>
<id>urn:sha1:3ab89e865b0dcc26fb1520abb8d9e2cba0615ba3</id>
<content type='text'>
DNAT port forwards can use destination ipsets to select multiple public
IP addresses. Reflection drops the ipset match and, when src_dip is unset,
uses the WAN addresses instead. Forwards sharing a port then overlap and
send LAN traffic to the host from the first rule. Public addresses found
only in the ipset do not work with reflection at all.

Keep supported destination ipset matches in reflection DNAT rules. Use
the set to select public addresses, retaining src_dip as an additional
constraint when configured. Reflection SNAT still matches the internal
destination address and port.

Extend 07_redirect with two forwards sharing TCP/UDP port 443, each using
its own destination ipset and internal host. Check the generated DNAT and
reflection rules, including SNAT without the public-address ipset.

Signed-off-by: Tigran Melikyan &lt;opensource@cyberhayq.am&gt;
[folded fix: adapt reflection ipset handling to the multi-set representation]
Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
<entry>
<title>fw4: fix parsing of repeated separators in ipset references</title>
<updated>2026-11-02T22:46:36Z</updated>
<author>
<name>Philipp Raschdorff</name>
</author>
<published>2026-10-17T20:01:38Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/firewall4/commit/?id=ffa015c64f06280d7e76e532fad20868c9947f10'/>
<id>urn:sha1:ffa015c64f06280d7e76e532fad20868c9947f10</id>
<content type='text'>
parse_setmatch() split the direction tokens after the set name at single
spaces or commas. A value like `'set  src'` (two spaces) therefore
produced an empty token at index 0, the `src` landed at index 1 and
applied to the wrong set field.

Split at runs of separators and drop empty tokens, so `'set  src'` and
`'set, src'` mean the same as `'set src'`. Unknown tokens are still
ignored as before.

Co-Authored-By: Claude Fable 5.1 &lt;noreply@anthropic.com&gt;
Signed-off-by: Philipp Raschdorff &lt;p.raschdorff@googlemail.com&gt;
</content>
</entry>
<entry>
<title>fw4: fix misleading family conflict message</title>
<updated>2026-11-02T22:46:36Z</updated>
<author>
<name>Philipp Raschdorff</name>
</author>
<published>2026-10-17T20:01:36Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/firewall4/commit/?id=b8a32285c25264771622f0761e44a1974c1823a4'/>
<id>urn:sha1:b8a32285c25264771622f0761e44a1974c1823a4</id>
<content type='text'>
infer_family() remembers which referenced object restricted a section
to one address family in order to name it when a later object
conflicts. It stored `obj.desc`, a property none of the referenced
objects (zones, sets, subnets, helpers) has, so `by` was always null
and the fallback message claimed the section itself was restricted:

  Section @redirect[0] (Redirect #1) is restricted to IPv6 but
  referenced source zone is IPv4 only, skipping

although the restriction came from another referenced object. Store the
description passed alongside the object instead, so the message names
it:

  Section @redirect[0] (Redirect #1) references IPv4 only source zone
  but is restricted to IPv6 by rewrite IP, skipping

Sections with an explicit `option family` keep the former wording, which
is correct for them. One test expectation changes accordingly.

Co-Authored-By: Claude Fable 5.1 &lt;noreply@anthropic.com&gt;
Signed-off-by: Philipp Raschdorff &lt;p.raschdorff@googlemail.com&gt;
</content>
</entry>
<entry>
<title>fw4: skip protocols a referenced port set does not apply to</title>
<updated>2026-11-02T22:46:36Z</updated>
<author>
<name>Philipp Raschdorff</name>
</author>
<published>2026-10-17T20:01:35Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/firewall4/commit/?id=466e78ee25a710c07a75ee8c061f355be0f8fcbf'/>
<id>urn:sha1:466e78ee25a710c07a75ee8c061f355be0f8fcbf</id>
<content type='text'>
A rule or redirect with several protocols, e.g. `proto 'tcp icmp'`, that
references a set with a port field (`inet_service`) passed the TCP/UDP
check because one of the protocols has ports. For the other protocol
map_setmatch() returned null, the set match was emitted with an empty
field list and the rule came out as

  meta l4proto icmp  @ports counter jump accept_to_lan comment "..."

which is invalid nft syntax: `fw4 check` failed and the whole ruleset
did not load.

Skip the protocol the set does not apply to, with a warning naming the
set and the protocol, and keep the rule for the remaining protocols. A
rule whose only protocol lacks ports is still rejected as before.

Co-Authored-By: Claude Fable 5.1 &lt;noreply@anthropic.com&gt;
Signed-off-by: Philipp Raschdorff &lt;p.raschdorff@googlemail.com&gt;
</content>
</entry>
<entry>
<title>fw4: honour negated protocol matches in rules</title>
<updated>2026-10-28T13:07:03Z</updated>
<author>
<name>John Crispin</name>
</author>
<published>2026-10-18T08:34:14Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/firewall4/commit/?id=384d1a9a2f414e599ffa62aa8b916ea6e455971c'/>
<id>urn:sha1:384d1a9a2f414e599ffa62aa8b916ea6e455971c</id>
<content type='text'>
parse_protocol() records a leading '!' in the invert flag, but the rule
template ignores it, so "option proto '!tcp'" silently renders as a
match on TCP. Emit "meta l4proto !=" for a negated protocol. A negated
list such as '!tcpudp' or '!tcp !udp' matches none of its protocols, so
it becomes a single rule against the whole set instead of one rule per
protocol. A rule that mixes negated and plain protocols, negates 'all',
or combines a negated protocol with port, ICMP type or port set matches
is refused with a warning.

Signed-off-by: John Crispin &lt;john@phrozen.org&gt;
</content>
</entry>
</feed>
