I have encountered a strange problem that is reproducible on 6.49.13 and 7.16.1:
I have a route in my routing table as so:
Code: Select all
[akliouev@tat] > /ip route print detail where comment="foo.bar.com"
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, B - blackhole, U - unreachable, P - prohibit
0 A S ;;; foo.bar.com
dst-address=1.2.3.4/32 gateway=10.20.30.40 gateway-status=10.20.30.40 recursive via 172.20.7.254 ether5 distance=1 scope=30 target-scope=10
[akliouev@tat] >
Code: Select all
[akliouev@tat] > :local foo [ip route find where comment="foo.bar.com"]; put $foo;
*8a
Code: Select all
[akliouev@tat] > :local foo [ip route find where comment="foo.bar.baz"]; put $foo; /ip route set $foo comment="new comment here"
The same approach fails when attempted from a script. Here's an example:
Code: Select all
:local anchors {
{"1.2.3.4/32";"1";"main";"foo.bar.baz"}
{"0.0.0.0/0";"1";"rtab-direct";"direct DGW"}
}
:foreach a in=$anchors do={
:local route ($a->0)
:local distance ($a->1)
:local table ($a->2)
:local comment ($a->3)
:log info [:typeof $route]
:log info $route
:log info [:typeof $distance]
:log info $distance
:log info [:typeof $table]
:log info $table
:log info [:typeof $comment]
:log info $comment
:local routes [/ip route find where comment="$comment"]
:log info "Routes: $routes"
}
Code: Select all
11:30:50 script,info str
11:30:50 script,info 1.2.3.4/32
11:30:50 script,info str
11:30:50 script,info 1
11:30:50 script,info str
11:30:50 script,info main
11:30:50 script,info str
11:30:50 script,info foo.bar.baz
11:30:50 script,info Routes: *201C406C;Routes: *201C4024;Routes: *201C4078;Routes: *800000BA;Routes: *201C4084;Routes: *2
01C400C;Routes: *201C4018;Routes: *800000BB
11:30:50 script,info str
11:30:50 script,info 0.0.0.0/0
11:30:50 script,info str
11:30:50 script,info 1
11:30:50 script,info str
11:30:50 script,info rtab-direct
11:30:50 script,info str
11:30:50 script,info direct DGW
11:30:50 script,info Routes: *201C406C;Routes: *201C4024;Routes: *201C4078;Routes: *800000BA;Routes: *201C4084;Routes: *2
01C400C;Routes: *201C4018;Routes: *800000BB
Can anyone point out what am I doing wrong?