Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
4
Merge Requests
4
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
re6stnet
Commits
a10f9e1d
Commit
a10f9e1d
authored
Jun 18, 2024
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demo: fix graph generation for empty prefixes
parent
3a2f806a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
demo/demo
demo/demo
+9
-13
No files found.
demo/demo
View file @
a10f9e1d
...
...
@@ -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',
...
...
@@ -428,13 +429,12 @@ def route_svg(ipv4, z=4, default=type('', (), {'short': None})):
graph: dict[Re6stNode, dict[tuple[Re6stNode, bool], list[Re6stNode]]] = {}
for n in nodes:
g = graph[n] = defaultdict(list)
g: dict[tuple[Re6stNode, bool], list[Re6stNode]]
for r in n.get_routes():
if (r.prefix and r.prefix.startswith('10.42.') if ipv4 else
r.prefix is None or r.prefix.startswith('2001:db8:')):
for route in n.get_routes():
if (route.prefix and route.prefix.startswith('10.42.') if ipv4 else
route.prefix is None or route.prefix.startswith('2001:db8:')):
try:
g[node_by_ll(r.nexthop)].append(
node_by_ll(r.prefix)[0] if r.prefix else default
)
if route.prefix:
g[node_by_ll(route.nexthop)].append(node_by_ll(route.prefix)[0]
)
except KeyError:
pass
gv = ["digraph { splines = true; edge[color=grey, labelangle=0];"]
...
...
@@ -442,20 +442,16 @@ def route_svg(ipv4, z=4, default=type('', (), {'short': None})):
a = 2 * math.pi / N
edges = set()
for i, n in enumerate(nodes):
i: int
gv.append('%s[pos="%s,%s!"];'
% (n.name, z * math.cos(a * i), z * math.sin(a * i)))
l = []
for p, r in graph[n].items():
p: tuple[Re6stNode, bool]
r: list[Re6stNode]
j: int = abs(nodes.index(p[0]) - i)
j = abs(nodes.index(p[0]) - i)
l.append((min(j, N - j), p, r))
for j, (_, (p2, t), r) in enumerate(sorted(l, key=lambda x: x[0])):
p2: Re6stNode
l2: list[str] = []
l2 = []
arrowhead = 'none'
for r2 in sorted(r2.short for r2 in r):
for r2 in sorted(r2.short
or ''
for r2 in r):
if r2:
if r2 == p2.short:
r2 = '
<font
color=
"grey"
>
%s
</font>
' % r2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment