Skip to content

Raise fw4 open-file limit - #1870

Open
gsanchietti wants to merge 1 commit into
mainfrom
issue1869
Open

Raise fw4 open-file limit#1870
gsanchietti wants to merge 1 commit into
mainfrom
issue1869

Conversation

@gsanchietti

@gsanchietti gsanchietti commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

On firewalls with many port forwards and zones, applying the firewall
configuration failed part way through. The incomplete rules were then
discarded, so the firewall kept its previous rules while the command still
reported success — changes appeared to work but did not take effect.

Building the rules holds one file open per rule template until the whole set
is finished, which exceeds the limit of 1024 open files. The patch raises that
limit in /sbin/fw4, the single place every reload goes through (boot,
hotplug, API, manual runs).

PKG_RELEASE is bumped too, so the rebuilt package counts as an upgrade and
can be shipped to existing installations without releasing a new image.

Related issue: #1869

How to test

Issue #1869 has a script that builds a firewall configuration large enough to
trigger the problem. On a test machine, run it and then fw4 reload:

  • current release: fails with No file descriptors available, and the new
    rules are not applied (nft list table inet fw4 | grep -c "dnat ip to" is
    unchanged)
  • with this patch: completes, and all 264 rules are loaded

Note fw4 reload exits 0 in both cases, so check the printed output rather
than the exit status.

To test on a real machine:

cat > /etc/apk/repositories.d/98-overrides.list << "EOF"
set -default repo_channel=pr1870
set -default version=8.8.0-pr1870.342.20260806142738.91c2eae
EOF
apk update
apk upgrade firewall4
fw4 reload <- error must be gone

Still to confirm

Whether the distfeed.nethesis.it subscription mirror carries the base
feed. If it only mirrors nethsecurity, subscription units would need a new
image and this should get the needs image label.

Applying a large firewall configuration failed part way through and
the new rules were silently discarded, leaving the previous ones
active while the command still reported success.

Building the rules holds one file open per rule template until the
whole set is finished, so a large configuration exceeds the limit of
1024 open files. A 320-section configuration needs about 1060.

PKG_RELEASE is bumped so the rebuilt package is a visible upgrade and
can reach existing installations without a new image.

Refs #1869

Assisted-by: Claude Code:claude-sonnet-5
@gsanchietti
gsanchietti marked this pull request as ready for review August 7, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant