You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(mikrotik): support RouterOS 7.21 wrapped/commented BGP output
RouterOS 7.21 emits BGP route detail differently over the looking-glass SSH
driver, which broke the structured parser:
- Active/best routes learned from a commented peer put the flag column and the
";;; comment" on a line of their own (afi=ip wraps to the next line), so the
"A" flag was lost and no best route was highlighted. Derive active/filtered
from the always-present "contribution=" field instead, falling back to the
flag column for ROS v6.
- Long ".communities" lists wrap across terminal-width lines; everything after
the wrap was silently dropped. De-wrap comma-separated lists before
tokenizing.
- The garbage cleaner stripped any legend-looking line without "=", which also
ate commented route flag lines. Match the "<char> - " legend shape instead.
- Parse the v7 dotted ".ext-communities" key.
Also restore the empty-BGP-table retry (4 attempts, 10s delay, MikroTik BGP
queries only) that re-runs when RouterOS answers before its routing table has
finished assembling.
Test fixtures use RFC 5737 (IPv4) documentation addresses and RFC 5398 example
ASNs only; no real network data.
Copy file name to clipboardExpand all lines: hyperglass/plugins/tests/test_bgp_route_mikrotik.py
+98-21Lines changed: 98 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,11 @@
1
1
"""MikroTik structured BGP route parsing tests.
2
2
3
-
The sample below is a trimmed, real `routing route print detail` capture from a
4
-
RouterOS 7.20.6 device (CCR2216), reduced to one active and one filtered route.
5
-
Long community lists are kept on a single line, matching what the device emits
6
-
to the looking-glass SSH driver (no terminal-width wrapping).
3
+
The samples below are synthetic captures shaped exactly like RouterOS
4
+
`routing route print detail` output, but scrubbed of any real network data: all
5
+
addresses use the RFC 5737 (IPv4) documentation ranges, autonomous-system
6
+
numbers use the RFC 5398 documentation range (64496-64511), and peer/interface
7
+
names are generic. Only the *structure* of the output is real, which is all the
8
+
parser cares about.
7
9
"""
8
10
9
11
# flake8: noqa
@@ -22,16 +24,18 @@
22
24
ift.TYPE_CHECKING:
23
25
fromhyperglass.stateimportHyperglassState
24
26
27
+
# One active and one filtered route, each emitted on a single (unwrapped) line,
28
+
# as a wide terminal would produce.
25
29
SAMPLE="""Flags: X - disabled, F - filtered, U - unreachable, A - active;
26
30
c - connect, s - static, r - rip, b - bgp, n - bgp-net, o - ospf, i - isis, d - dhcp, v - vpn, m - modem, a - ldp-address, l - ldp-mapping, g - slaac, y - bgp-mpls-vpn, e - evpn;
27
31
H - hw-offloaded; + - ecmp, B - blackhole
28
-
Ab afi=ip contribution=active dst-address=1.0.0.0/24 routing-table=main pref-src=192.0.2.1 gateway=196.60.8.198
# must not swallow the following key=value tokens.
94
+
WRAPPED_SAMPLE="""Flags: X - disabled, F - filtered, U - unreachable, A - active;
95
+
c - connect, s - static, r - rip, b - bgp, n - bgp-net, o - ospf, i - isis, d - dhcp, v - vpn, m - modem, a - ldp-address, l - ldp-mapping, g - slaac, y - bgp-mpls-vpn, e - evpn;
0 commit comments