Commit 41bffb6b authored by Vitaly Lipatov's avatar Vitaly Lipatov

route-update: flush table when .list moves between groups

When a .list is moved between groups whose `gateway` files differ in metric semantics (e.g., failover→multipath), the previous code only deleted state and kept the table. This caused stale routes with the old `metric N` to coexist with newly loaded multipath routes, because `ip route replace` keyed on dst+metric and treated them as distinct entries. Two related changes: - cleanup_state's "moved" branch now flushes the table before the new group loads it, so the table starts clean. - cleanup_state is invoked before process_routes so the flushes happen prior to the new group's load (otherwise a flush after load would wipe out the just-installed routes). Co-Authored-By: 's avatarClaude Opus 4.7 (1M context) <noreply@anthropic.com>
parent c5663ba3
...@@ -976,7 +976,10 @@ cleanup_state() ...@@ -976,7 +976,10 @@ cleanup_state()
[ -f "$list_state/table" ] && read -r t < "$list_state/table" [ -f "$list_state/table" ] && read -r t < "$list_state/table"
if [ -n "$moved_to" ] ; then if [ -n "$moved_to" ] ; then
local new_group=$(basename "$(dirname "$moved_to")") local new_group=$(basename "$(dirname "$moved_to")")
log "List $lname moved from $name to $new_group, removing old state (keeping table $t)" log "List $lname moved from $name to $new_group, flushing table $t for clean reload"
if [ -z "$SHOW" ] && [ -n "$t" ] ; then
$ipcmd route flush table "$t" 2>/dev/null
fi
else else
log "Cleaning orphaned state for $name/$lname (table $t)" log "Cleaning orphaned state for $name/$lname (table $t)"
if [ -z "$SHOW" ] && [ -n "$t" ] ; then if [ -z "$SHOW" ] && [ -n "$t" ] ; then
...@@ -1175,9 +1178,13 @@ check_list_duplicates "$ROUTES6_DIR" " (v6)" || dup_errors=$((dup_errors + $?)) ...@@ -1175,9 +1178,13 @@ check_list_duplicates "$ROUTES6_DIR" " (v6)" || dup_errors=$((dup_errors + $?))
check_extra_dns check_extra_dns
[ -n "$EXTRA_DNS" ] && vlog "Extra DNS: $EXTRA_DNS" || log "Extra DNS ($EXTRA_DNS_SERVER) unreachable, local resolver only" [ -n "$EXTRA_DNS" ] && vlog "Extra DNS: $EXTRA_DNS" || log "Extra DNS ($EXTRA_DNS_SERVER) unreachable, local resolver only"
# Cleanup runs FIRST so that flushes for moved/orphaned lists happen
# before the new group reloads its routes (avoids stale metric'd routes
# coexisting with newly loaded multipath routes when a list moves between
# groups whose gateway configs differ).
cleanup_state
process_routes "$ROUTES_DIR" get_ipv4_list_bulk "ip" "" process_routes "$ROUTES_DIR" get_ipv4_list_bulk "ip" ""
process_routes "$ROUTES6_DIR" get_ipv6_list_bulk "ip -6" " (v6)" process_routes "$ROUTES6_DIR" get_ipv6_list_bulk "ip -6" " (v6)"
cleanup_state
generate_bird_config generate_bird_config
generate_web_json generate_web_json
......
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