openwrt / openwrt/firewall4

/usr/share/nftables.d/chain-post will not get included if corresponding chain is not used in /etc/config/firewall

Open
#82 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
ucode
Stars
27
Forks
37
PR merge metrics
No merged PRs in 30d

Description

I'm building a (hopefully) reusable package to add support to firewall expectations using conntrackd -- helpers essentially. I notice that when I am placing a chain in a directory that matches a "standard" table (e.g srcnat_zone), and if the zone doesn't itself have any rules, the included rules do not get rendered.

This is despite the misleading message that Automatically including '/usr/share/nftables.d/chain-post/srcnat_zone/X.nft is printed when running /etc/init.d/firewall reload.

I dug into the code and it seems like the chains are rendered only if there's a corresponding set of rules in /etc/config/firewall. Should fw4 also emit the chain if an include requests to insert rules into a chain? I'll be happy to work on a patch if this is desirable.

I've been able to workaround this by using the table-post hook instead -- but I would imagine more granular includes would be advantageous.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the /usr/share/nftables.d/chain-post/ include path and /etc/init.d/firewall reload, then trace the fw4 code that decides whether a standard chain is rendered. Reproduce the srcnat_zone case with no matching rules in /etc/config/firewall; done means the requested chain-post include is rendered rather than only reported as automatically included.

Written by the indexing model from the issue text.

Assessment

Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.