Commit 4a16d1c8 authored by Vitaly Lipatov's avatar Vitaly Lipatov

router: fix alloc_table vlog polluting table variable, ensure .tmp file exists

alloc_table vlog was captured by $() into _table variable, breaking route loading for newly allocated tables. Redirect vlog to stderr. Also pre-create resolved.new.tmp to avoid "file not found" on empty resolve. Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent baf359fe
......@@ -160,7 +160,7 @@ alloc_table()
while [ $num -le 250 ] ; do
if ! echo "$used" | grep -q "^${num}$" ; then
[ -z "$SHOW" ] && echo "$num $name" >> /etc/iproute2/rt_tables
vlog "Allocated table $num for $name"
vlog "Allocated table $num for $name" >&2
echo "$num"
return
fi
......@@ -406,14 +406,15 @@ resolve_list_file()
fi
vlog "$_tag$_label resolving..."
> "$_resolved_new.tmp"
if grep -v '^#' "$_f" | grep -q '[a-zA-Z]' ; then
cat_expanded "$_f" | grep -v '^#' | grep -v '^$' | $_resolve_func | \
grep -v '^#' | grep -v '^$' > "$_resolved_new.tmp"
grep -v '^#' | grep -v '^$' >> "$_resolved_new.tmp"
else
if [ "$_ipcmd" = "ip -6" ] ; then
grep -v '^#' "$_f" | grep -v '^$' | grep ':' > "$_resolved_new.tmp"
grep -v '^#' "$_f" | grep -v '^$' | grep ':' >> "$_resolved_new.tmp" || true
else
grep -v '^#' "$_f" | grep -v '^$' > "$_resolved_new.tmp"
grep -v '^#' "$_f" | grep -v '^$' >> "$_resolved_new.tmp"
fi
fi
sed 's|/32$||' "$_resolved_new.tmp" | sort -u > "$_resolved_new"
......
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