Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions hyperglass/models/parsing/frr.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class FRRNextHop(_FRRBase):

ip: str
afi: str
metric: int
metric: int = 0
accessible: bool
used: bool
used: bool = False


class FRRPeer(_FRRBase):
Expand Down Expand Up @@ -65,7 +65,15 @@ class FRRPath(_FRRBase):
def validate_path(cls, values):
"""Extract meaningful data from FRR response."""
new = values.copy()
new["aspath"] = values["aspath"]["segments"][0]["list"]
# Local prefixes (i.e. those in the same ASN) usually have
# no AS_PATH.
# Set AS_PATH to AS0 for now as we cannot ensure that the
# ASN for the prefix is the primary ASN.
if values["aspath"]["length"] != 0:
new["aspath"] = values["aspath"]["segments"][0]["list"]
else:
# TODO: Get an ASN that is reasonable (e.g. primary ASN)
new["aspath"] = [0]
community = values.get("community", {"list": []})
new["community"] = community["list"]
new["lastUpdate"] = values["lastUpdate"]["epoch"]
Expand Down
4 changes: 4 additions & 0 deletions hyperglass/plugins/_builtin/bgp_route_frr.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def parse_frr(output: t.Sequence[str]) -> "OutputDataModel":

_log.debug("Pre-parsed data", data=parsed)

# If empty (i.e. no route found), skip
if not parsed:
continue

validated = FRRBGPTable(**parsed)
bgp_table = validated.bgp_table()

Expand Down