From 08c1d47e64373ae6a7b879f71df372574d85d470 Mon Sep 17 00:00:00 2001 From: Simon Marsh Date: Sat, 22 Jun 2019 22:52:38 +0100 Subject: [PATCH] Correct AS path prepend count in bgpmap (Sileht pull request #53) https://github.com/sileht/bird-lg/pull/53/files --- lg.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lg.py b/lg.py index 924059a..7be6010 100644 --- a/lg.py +++ b/lg.py @@ -534,7 +534,13 @@ def show_bgpmap(): hop_label = "" for _as in asmap: if _as == previous_as: - prepend_as[_as] = prepend_as.get(_as, 1) + 1 + if not prepend_as.get(_as, None): + prepend_as[_as] = {} + if not prepend_as[_as].get(host, None): + prepend_as[_as][host] = {} + if not prepend_as[_as][host].get(asmap[0], None): + prepend_as[_as][host][asmap[0]] = 1 + prepend_as[_as][host][asmap[0]] += 1 continue if not hop: @@ -573,7 +579,9 @@ def show_bgpmap(): node.set_shape("box") for _as in prepend_as: - graph.add_edge(pydot.Edge(*(_as, _as), label=" %dx" % prepend_as[_as], color="grey", fontcolor="grey")) + for n in set([ n for h, d in prepend_as[_as].iteritems() for p, n in d.iteritems() ]): + graph.add_edge(pydot.Edge(*(_as, _as), label=" %dx" % n, color="grey", fontcolor="grey")) + fmt = request.args.get('fmt', 'png') #response = Response("
" + graph.create_dot() + "
")