Commit 0b135bf0 authored by Vitaly Lipatov's avatar Vitaly Lipatov

route-update.sh: detect lost routes/rules on hash-mismatch path

The routes/rules existence check only ran when the hash matched. When the hash changed (e.g. DNS availability) but resolved IPs were unchanged, routes were not reloaded even if empty in kernel. Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 0d13a4a8
...@@ -322,6 +322,16 @@ process_routes() ...@@ -322,6 +322,16 @@ process_routes()
vlog "[$name]$label state: force=$FORCE resolve=$RESOLVE hash_exists=$([ -f "$STATE_DIR/$state/hash" ] && echo yes || echo no)" vlog "[$name]$label state: force=$FORCE resolve=$RESOLVE hash_exists=$([ -f "$STATE_DIR/$state/hash" ] && echo yes || echo no)"
fi fi
# Detect routes/rules lost even when hash changed (e.g. DNS availability)
if [ -z "$FORCE" ] && [ -z "$need_reload" ] ; then
local cur_rules=$($ipcmd -N rule show | grep -c "lookup $table")
local cur_routes=$($ipcmd route show table "$table" 2>/dev/null | grep -c '^[^[:space:]]')
if [ "$cur_rules" = "0" ] || [ "$cur_routes" = "0" ] ; then
need_reload=1
log "[$name]$label Rules/routes lost, forcing reload"
fi
fi
# Skip re-resolve if only gateway/options changed (lists unchanged) # Skip re-resolve if only gateway/options changed (lists unchanged)
local resolved_new="$STATE_DIR/$state/resolved.new" local resolved_new="$STATE_DIR/$state/resolved.new"
if [ -z "$FORCE" ] && [ -z "$RESOLVE" ] && [ -f "$STATE_DIR/$state/lists_hash" ] && [ -f "$STATE_DIR/$state/resolved" ] ; then if [ -z "$FORCE" ] && [ -z "$RESOLVE" ] && [ -f "$STATE_DIR/$state/lists_hash" ] && [ -f "$STATE_DIR/$state/resolved" ] ; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment