Commit 7f0d2629 authored by Vitaly Lipatov's avatar Vitaly Lipatov

router: check for duplicate .list files across groups, document BIRD2

Duplicate .list basenames in different groups would share a routing table with conflicting gateways. Detect this early and abort. Also add BIRD2 BGP integration section to --help. Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent ce15dda0
......@@ -90,6 +90,20 @@ TABLE RESOLUTION:
Table number is auto-allocated in range 200-250 and registered in rt_tables.
ip rule pref = table_number × 10.
BIRD2 BGP INTEGRATION:
If BIRD2 is installed (birdc available), auto-generates
/etc/bird/route-tables.conf after each run. For each per-list table,
creates a protocol kernel (with learn) importing routes into a
per-list BIRD table, tagged with BGP community (65000:TABLE_NUM),
and a protocol pipe merging into master4/master6.
This allows egw to act as an iBGP route reflector, distributing
per-list routes to BGP clients. Clients filter by community to
receive only the lists they need.
Constants: BIRD_AS=65000, BIRD_CONF=/etc/bird/route-tables.conf
birdc configure is called only when the config actually changes.
EXAMPLES:
./route-update.sh # normal run
./route-update.sh --resolve -v # re-resolve DNS, verbose
......@@ -756,10 +770,35 @@ EOF
birdc configure >/dev/null 2>&1 && log "BIRD reconfigured" || log "WARNING: birdc configure failed"
}
# --- Check for duplicate .list files across groups ---
check_list_duplicates()
{
local routes_dir="$1" label="$2"
[ -d "$routes_dir" ] || return 0
local seen="" errors=0
for f in "$routes_dir"/*/*.list ; do
[ -f "$f" ] || continue
local bname=$(basename "$f")
local group=$(basename "$(dirname "$f")")
local prev=$(echo "$seen" | grep " ${bname} " | awk '{print $1}')
if [ -n "$prev" ] ; then
log "ERROR:$label $bname found in both $prev/ and $group/ — each .list must belong to one group only"
errors=$((errors + 1))
fi
seen="$seen${group} ${bname} "
done
return $errors
}
# --- Main ---
[ -n "$SHOW" ] && log "Dry-run mode (no changes will be made)"
[ -n "$VERBOSE" ] && log "Verbose mode, state_dir=$STATE_DIR"
dup_errors=0
check_list_duplicates "$ROUTES_DIR" "" || dup_errors=$((dup_errors + $?))
check_list_duplicates "$ROUTES6_DIR" " (v6)" || dup_errors=$((dup_errors + $?))
[ "$dup_errors" -gt 0 ] && fatal "Duplicate .list files detected — fix config before proceeding"
check_extra_dns
[ -n "$EXTRA_DNS" ] && vlog "Extra DNS: $EXTRA_DNS" || log "Extra DNS ($EXTRA_DNS_SERVER) unreachable, local resolver only"
......
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