Commit 8bf8de4e authored by Tom Niget's avatar Tom Niget Committed by Tom Niget

demo: fix graph generation for empty prefixes

parent f484fc65
......@@ -94,6 +94,7 @@ class Re6stNode(nemu.Node):
def __init__(self, name, short):
super().__init__()
print("Re6stNode ctor %r %r" % (name, short))
self.name = name
self.short = short
self.Popen(('sysctl', '-q',
......@@ -427,11 +428,12 @@ def route_svg(ipv4, z=4, default=type('', (), {'short': None})):
g = graph[n] = defaultdict(list)
g: dict[tuple[Re6stNode, bool], list[Re6stNode]]
for r in n.get_routes():
print("route_svg: %r" % r)
if (r.prefix and r.prefix.startswith('10.42.') if ipv4 else
r.prefix is None or r.prefix.startswith('2001:db8:')):
try:
g[node_by_ll(r.nexthop)].append(
node_by_ll(r.prefix)[0] if r.prefix else default)
if r.prefix:
g[node_by_ll(r.nexthop)].append(node_by_ll(r.prefix)[0])
except KeyError:
pass
gv = ["digraph { splines = true; edge[color=grey, labelangle=0];"]
......@@ -452,7 +454,9 @@ def route_svg(ipv4, z=4, default=type('', (), {'short': None})):
p2: Re6stNode
l2: list[str] = []
arrowhead = 'none'
for r2 in sorted(r2.short for r2 in r):
print("r=%r" % r)
print("processing: " + ", ".join("%r" % ((r2.name, r2.short),) for r2 in r))
for r2 in sorted(r2.short if r2.short else "NONE" for r2 in r):
if r2:
if r2 == p2.short:
r2 = '<font color="grey">%s</font>' % r2
......
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