Repository navigation
Conversation
With no 'inet fw4' table (firewall not loaded, or firewall3 installed in place of firewall4), pbr failed to start without saying why: - nft_check_element() read the table with 'nft list table inet fw4 2>&1', so nft's error text made the table look present, and the chain checks failed on it instead. Drop stderr, and skip the chain checks when the table itself is missing: one error, "Default fw4 table 'fw4' is missing". - When the environment check failed, start_service() returned null, so its errors stayed in state.errors: the log showed only "Loading environment [x]", "FAILED TO START" and a hint to check the nft file, while status and the WebUI showed nothing. Return the errors instead; emit_procd_shell() writes them into the service data, so service_started() logs them and the WebUI shows them. The new retryOnBoot flag keeps the boot-mode retry the wrapper set up for a null result. The nft hint is printed only when no error explains the failure. The orphan-set reaper reads the same 'nft list table inet fw4 2>/dev/null' command, so the fixtures of tests 08 and 14 gain the dstnat and mangle_* chains every fw4 table has. New test 02_config/12_fw4_table_missing: 7/7 with the fix, 2/7 without. Tested on x86 OpenWrt 25.12 with 1.2.4-r2 (stop pbr, delete the fw4 table, start pbr): before, no reason anywhere; after, "ERROR: Default fw4 table 'fw4' is missing!" in the log, the error in the service data, and the boot-mode retry trigger still set. A normal restart is unchanged. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Erik Conijn <egc112@msn.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With no
inet fw4table (the firewall is not loaded, orfirewall(fw3) has replacedfirewall4), pbr fails to start without saying why. Reported on the forum: https://forum.openwrt.org/t/policy-based-routing-pbr-package-discussion/140639/3143 (that box runs firewall3).Two bugs:
nft_check_element()readsnft list table inet fw4 2>&1, so with no table nft's error text is the dump, and a non-empty dump counts as "table present". The chain checks then fail on it instead: three "Default fw4 chain 'mangle_…' is missing" errors (four with a DNS or Tor policy) for what is really one missing table. 1.2.2 has the same2>&1.start_service()returnsnull, and the errors stay instate.errors. Measured on x86 OpenWrt 25.12 with stock 1.2.4-r2 (stop pbr,nft delete table inet fw4, start pbr), the whole output is:statussays "not active", the service data in procd is empty, so the WebUI shows nothing either, and the nft hint points the wrong way. The same holds for every environment check failure (e.g. ip-full missing).Fix
nft.uc: read the table with2>/dev/null.pbr.uc: skip the chain checks when the table itself is missing (one error, not three or four). When the environment check fails, return{ errors, warnings, retryOnBoot }instead ofnull;emit_procd_shell()writes the errors into the service data, soservice_started()logs them and the WebUI shows them. The "Check the output of nft -c -f" hint is printed only when no error explains the failure.init.d/pbr:_pbr_retry_on_bootkeeps the boot-mode retry (interface.*.uptrigger) that the wrapper set up for anullresult, so a check that fails briefly still recovers on the next interface event.No new message codes, so no compat bump: luci-app-pbr 1.2.4 already has
errorDefaultFw4TableMissinganderrorDefaultFw4ChainMissing. The "service disabled" path is unchanged (it prints its own message).Tests
popen~nft_list_table_inet_fw4_2_1.txtis renamed for the new command line.nft list table inet fw4 2>/dev/null, so the per-test fixtures of03_nft_rules/08and14now also feed the health check; they gain thedstnatandmangle_*chains every fw4 table has.02_config/12_fw4_table_missing: one table error, no chain errors,retryOnBoot, and the error plus_pbr_retry_on_boot='1'in the emitted procd shell. 7/7 with the fix, 2/7 without.tests/run_tests.sh: 76/76.check-ucode-syntax.shwith ucode 85922056 (25.12): 17/17.Hardware
Same router and procedure as above, with the patched files:
and
ubus call service list '{"name":"pbr"}'holds[ { "code": "errorDefaultFw4TableMissing", "info": "fw4" } ]; "Setting trigger (on_boot) ✓" is still printed. A normal restart is unchanged (active, no errors). Note for anyone reproducing: use stop / delete / start, notrestart, because pbr's stop reloads fw4 and recreates the table.The analysis, the patch, the tests and the hardware runs were done with the help of an LLM (Claude); I reviewed the result.