Skip to content

watchcat: fix interface resolution race - #30464

Open
danielfdickinson wants to merge 2 commits into
openwrt:masterfrom
danielfdickinson:pr-watchcat-fix-interface-resolution-race
Open

watchcat: fix interface resolution race#30464
danielfdickinson wants to merge 2 commits into
openwrt:masterfrom
danielfdickinson:pr-watchcat-fix-interface-resolution-race

Conversation

@danielfdickinson

@danielfdickinson danielfdickinson commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

📦 Package Details

Maintainer: @danielfdickinson @dhrm1k

Description:
Fixes the interface resolution race described in #30463:

  • Add interface trigger handling in watchcat.init
  • Log when raw interface trigger is activated by any interface coming up
  • Move helper functions to separate file
  • Update Makefile to install new functions file

While we are at it (to help reduce code errors):

We use shellcheck even though it is pedantic to assist in reducing
errors. Therefore, we add shellcheck directives to silence false
positives. We keep changes minimal as some shellcheck suggestions
result in watchcat failing to function properly.

Also make formatting shmt clean (using -ln=bash due to ash constructs
that shfmt 3.8.0 does not accept for posix shells including busybox).

Closes: #30463


🧪 Run Testing Details

  • OpenWrt Version: OpenWrt SNAPSHOT r36072-f1a3f07139
  • OpenWrt Target/Subtarget: mediatek/filogic
  • OpenWrt Device: OpenWrt One

✅ Formalities

  • I have reviewed the CONTRIBUTING.md file for detailed contributing guidelines.

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit checks

  • a8a55c4 "watchcat: silence shellcheck false positives" — also adds . /lib/functions/watchcat.sh to watchcat.init, which is a functional change rather than a shellcheck directive, and that file is only created in 024a578. At this commit the init script sources a path that does not exist; move the line into the second commit.

Generated by Claude Code

Comment thread utils/watchcat/files/watchcat.init Outdated
Comment thread utils/watchcat/files/watchcat.sh.functions
Comment thread utils/watchcat/files/watchcat.init Outdated
Comment thread utils/watchcat/files/watchcat.init Outdated
@danielfdickinson
danielfdickinson force-pushed the pr-watchcat-fix-interface-resolution-race branch from 024a578 to 3aabd7d Compare September 7, 2026 11:14

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 new commits.


Generated by Claude Code

Comment thread utils/watchcat/files/watchcat.init Outdated
Comment thread utils/watchcat/files/watchcat.init Outdated
Comment thread utils/watchcat/files/watchcat.init Outdated
@danielfdickinson
danielfdickinson force-pushed the pr-watchcat-fix-interface-resolution-race branch from 3aabd7d to 9cc45a1 Compare September 7, 2026 11:42

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 new commits; no new issues found.


Generated by Claude Code

@danielfdickinson
danielfdickinson force-pushed the pr-watchcat-fix-interface-resolution-race branch 2 times, most recently from 6dbb915 to fa0daef Compare September 7, 2026 17:23

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 new commits.


Generated by Claude Code

Comment thread utils/watchcat/files/watchcat.init Outdated
We use shellcheck even though it is pedantic to assist in reducing
errors. Therefore, we add shellcheck directives to silence false
positives. We keep changes minimal as some shellcheck suggestions
result in watchcat failing to function properly.

Also make formatting shmt clean (using -ln=bash due to ash constructs
that shfmt 3.8.0 does not accept for posix shells including busybox).

Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
- Add interface trigger handling in watchcat.init
- Log when raw interface trigger is activated by any interface coming up
- Move helper functions to separate file
- Update Makefile to install new functions file

Closes: openwrt#30463

Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
@danielfdickinson
danielfdickinson force-pushed the pr-watchcat-fix-interface-resolution-race branch from fa0daef to 8618635 Compare September 8, 2026 11:29
@GamaBurst

Copy link
Copy Markdown

Tested on the device from #30463. Works.

OpenWrt 25.12.5 r33051-f5dae5ece4, mediatek/filogic, OpenWrt One. Applied watchcat.init, watchcat.sh and watchcat.sh.functions from the PR branch at 8618635 onto a running watchcat-1-r25 install. Config: mode='restart_iface', interface='@wan', DHCP WAN on eth0.

Cold boot:

16:34:28 daemon.warn watchcat[4170]: Could not resolve interface "@wan" for pinging.
16:34:28 daemon.warn watchcat[4170]: Could not resolve interface "@wan" for restart.
16:34:34 daemon.notice watchcat[5324]: Restarting due to an interface up with any unresolved interface.

The race still happens at 16:34:28 as expected, but the raw trigger fires 6 seconds later when wan comes up and restarts the service. The resulting daemon logs no warning, so both ping_iface and restart_iface resolved. Exposure drops from permanent to a few seconds, and the log line makes the sequence self-explanatory.

PROCD_RELOAD_DELAY is 1000 on this build, so the raw trigger argument order is fine here.

Note for anyone else looking: procd's service list does not expose triggers, so the boot log is the only way to see which branch was taken.

I applied the files directly rather than building the package, so this run says nothing about the current build failures.

@danielfdickinson

Copy link
Copy Markdown
Contributor Author

@GamaBurst Thank you! The build failures are an issue with the infrastructure, based on my reading of them. There have been intermittent issues of this kind for quite some time now, so some PRs are green and others red even when there are no issues, although one has to read the red logs to be sure.

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 new commits; no new issues found.


Generated by Claude Code

@BKPepe
BKPepe requested a lite review from Copilot September 9, 2026 11:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

watchcat: interface resolution races netifd at boot, leaving the daemon permanently misconfigured

4 participants