Commit Graph

25 Commits

Author SHA1 Message Date
Daniel F. Dickinson c3a85b96de watchcat: use logical network to fix restart_interface
Watchcat was failing to restart layer-3 interfaces when in mode
'restart_iface'. The previously attempted fix made the situation
worse in that it resulted in layer 2 interfaces also failing to
start.

This was because we are passed the interface name (e.g. eth0,
l2p0, or br-lan), but ifup needs the logical network (e.g. 'lan'
which corresponds to the network device).

Update to use find_config from /lib/network/config.sh to find the
logical network from the interface name, and use ifup on the
logical network to restart the underlying interface(s) associated
with the logical network.

Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
2026-04-11 09:13:01 +03:00
Daniel F. Dickinson 14e0e9e737 watchcat: fix interface reset does not work
As reported in #23410 Network interface reset doesn't work as expected
on a Wireguard VPN interface and in #27927 lt2p interface won't reboot,
and mentioned in #27248, the current implementation of the option to
restart an interface when connectivity check fails for some period does
not result in an interface restart for all interface.

Notably 'virtual' interfaces such as Wireguard and L2TP do not restart.

The solution that works is to use `ifup <interface>` instead of only
changing the link status.

This commit is based on the one in #27248 by @rondoval, who unfortunately
has not updated the commit message as requested for half a year.

Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
2026-03-03 20:06:13 +02:00
Ivan Diaz 407617b786 luci-app-watchcat: revert unnecessary quoting in init script
The quoting added in r18 for pinghosts is not needed. Multi-host support
remains fully functional, but the extra quotes caused inconsistent argument
handling between /etc/init.d/watchcat and /usr/bin/watchcat.sh,
especially for single-IP configurations.

This revert removes the unnecessary quoting in the init script and LUCI,
restoring consistent behavior while keeping multiple ping hosts supported.

Fixes: #28100 (watchcat: error if only one address is specified in pinghosts)
Signed-off-by: Ivan Diaz <diaz.it@icloud.com>
2025-12-26 09:51:51 +01:00
Vasileios Anagnostopoulos 3f52746c79 watchcat: passing the interface in the ping_reboot
Although the watchcat_ping function also checked the iface variable, that
variable was never populated. As a result we could not check if there was
connectivity via a specific interface.

Signed-off-by: Vasileios Anagnostopoulos <anagnwstopoulos@hotmail.com>
2025-12-12 16:40:40 +01:00
Ivan Diaz dfe2967675 watchcat: set default value for mmifacename to prevent argument shift
Set mmifacename default to "null" instead of an empty string to avoid
argument displacement when the value is not defined. Also remove leftover
debug comments from previous commit.

Signed-off-by: Ivan Diaz <diaz.it@icloud.com>
2025-12-09 12:12:19 +01:00
Ivan Diaz 5dc13908b4 watchcat: fix argument handling and allow multiple ping hosts
The backend now correctly supports multiple IP addresses and avoids
argument shifting when mmifacename is empty.

Signed-off-by: Ivan Diaz <diaz.it@icloud.com>
2025-12-09 12:12:19 +01:00
Michal Kowalski 406adc5363 watchcat: fix broken ping invocation for no-address-family configuration
Fix for issue #19010

Signed-off-by: John Kohl <jtk.git@bostonpog.org>
Signed-off-by: Michal Kowalski <18610805+kofec@users.noreply.github.com>
2022-08-01 20:35:15 -04:00
John Kohl 5c96ee5b1b watchcat: add support to run a script
Signed-off-by: John Kohl <jtk.git@bostonpog.org>
2022-07-15 12:14:06 -07:00
John Kohl baed5531ef watchcat: add IP version selection support; fix bug with unlockbands
Signed-off-by: John Kohl <jtk.git@bostonpog.org>
2022-07-15 12:14:06 -07:00
Rozhuk Ivan 0238bcef19 utils/watchcat: restart failure time after network restart
Without this change these settings:
Mode: Restart Interface
Period: 30s
Check Interval: 5s
will do ping every 30s, if all pings are fail then
it try to take action every 5 second.

After apply this patch watchcat will try to send
ping every 5 second in next 30 sec before take action if
all pings are fail.

This is important for wireless uplinks like 3G/4G that
need some time to establish connection.

Signed-off-by: Rozhuk Ivan <rozhuk.im@gmail.com>
2022-02-23 17:28:43 -08:00
Rosen Penev 933de68f3f watchcat: run through shfmt
Cosmetic fixes mainly.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-15 18:29:12 -07:00
Nicholas Smith 399279b363 watchcat: update to support procd
Signed-off-by: Nicholas Smith <nicholas@nbembedded.com>
2021-02-24 20:50:09 +10:00
Nicholas Smith 4974af70bd watchcat: add ability to restart interface + refactor
Signed-off-by: Nicholas Smith <nicholas@nbembedded.com>
2020-12-21 15:16:16 +10:00
Nicholas Smith a4ce06de1c watchcat: add support for specifying ping packet size
Signed-off-by: Nicholas Smith <nicholas@nbembedded.com>
2020-12-14 13:17:16 +10:00
Nicholas Smith ddd2729313 watchcat: refactor function names
Signed-off-by: Nicholas Smith <nicholas@nbembedded.com>
2020-12-14 13:16:58 +10:00
Vasily Trotzky 56b842f0b7 watchcat: add nopingtime option + refactoring
nopingtime UCI option rationale:
I want relatively fast reaction(i.e. 1m or 2m) for 'no internet' condition,
but i don't want my router to reboot every 1 minute if there is still no
internet after reboot.

initd_watchcat:
* add: nopingtime uci option support
* add: defaults to all non-critical options
* add: log warnings for non-critical errors(when option is missed and
default is applyed)
* fix: error handling and config_get defaults are somtimes in conflict
because of config_get defaults. They are gone now, error handling improved.
* fix: calling watchcat.sh with 'period' mode instead of 'ping'. Typo?
* fix: pingperiod default changed from period/20 to more reasonable period/5

watchcat.sh:
* add: nopingtime uci option support( sleep if uptime < nopingtime )
* remove: [ "$mode" = "allways" ] && mode="always" - not needed, already
done by initd_watchcat in load_watchcat() func
* add: echo 1 > /proc/sys/kernel/sysrq before sysrq-trigger
* refactor: eliminated once used not needed variables, code size reduced.

* PKG_RELEASE bumped up

Signed-off-by: Vasily Trotzky <trotzky.vas@gmail.com>
2020-11-19 14:50:39 +03:00
Nuno Goncalves 178a359275 watchcat: make compatible with updated busybox ash array handling
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2019-10-01 19:41:56 +02:00
Deng Qingfang 17496030e2 treewide: add missing PKGARCH:=all to non-binary packages
Packages such as Perl, Lua, shell scripts don't generate binary files.
Add PKGARCH:=all to them.

Signed-off-by: Deng Qingfang <dengqf6@mail2.sysu.edu.cn>
2019-03-30 17:11:50 +08:00
Nuno Goncalves bdddeedf2a watchcat: bump release due to 8e1e4d7d2d
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-12-21 16:39:52 +01:00
AaronA 8e1e4d7d2d Force a kill of the existing Processes to make sure they are left and the processes begin to stack up. 2017-11-02 21:52:00 +01:00
ascob 6065f01ffa watchcat: fix operation of mode 'always'
This patch fixes the watchcat init script in case of mode 'always'.
This mode just needs the config parameters: mode, period and forcedelay.
But a wrong check against the variable pingperiod, needed in the mode 'ping'
prevented mode 'always' to work properly.

Signed-off-by: Tobias Ilte <tobias.ilte@campus.tu-berlin.de>
2016-08-24 15:47:58 +02:00
Stefan Weil afbe8dcb87 utils/watchcat: Fix some typos (mostly found by codespell)
Note that this implies an API change (allways -> always).
The wrong spelling "allways" is still accepted for backward compatibility.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-04-30 09:46:34 +02:00
Stefan Weil b5738a3878 utils: Fix typos (found by codespell)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-03-26 09:53:01 +01:00
Roger d1d33eedaf add license
Signed-off-by: Roger D rogerdammit@gmail.com
2014-08-14 09:30:25 -05:00
Roger f749bd7237 watchcat: add with myself as maintainer
Signed-off-by: Roger D rogerdammit@gmail.com
2014-08-13 21:37:44 -05:00