diff options
Diffstat (limited to 'table')
-rw-r--r-- | table/destination.go | 13 | ||||
-rw-r--r-- | table/path.go | 10 |
2 files changed, 10 insertions, 13 deletions
diff --git a/table/destination.go b/table/destination.go index f6ee4030..e602deb0 100644 --- a/table/destination.go +++ b/table/destination.go @@ -96,6 +96,13 @@ func NewDestinationDefault(nlri bgp.AddrPrefixInterface) *DestinationDefault { func (dd *DestinationDefault) MarshalJSON() ([]byte, error) { prefix := dd.getNlri().(*bgp.NLRInfo).Prefix + for _, p := range dd.knownPathList { + if p == dd.getBestPath() { + p.setBest(true) + } else { + p.setBest(false) + } + } return json.Marshal(struct { Prefix string Paths []Path @@ -135,9 +142,6 @@ func (dd *DestinationDefault) getBestPath() Path { func (dd *DestinationDefault) setBestPath(path Path) { dd.bestPath = path - if path != nil { - path.setBest(true) - } } func (dd *DestinationDefault) getOldBestPath() Path { @@ -146,9 +150,6 @@ func (dd *DestinationDefault) getOldBestPath() Path { func (dd *DestinationDefault) setOldBestPath(path Path) { dd.oldBestPath = path - if path != nil { - path.setBest(false) - } } func (dd *DestinationDefault) getKnownPathList() []Path { diff --git a/table/path.go b/table/path.go index 78fa111c..f2926cf3 100644 --- a/table/path.go +++ b/table/path.go @@ -70,7 +70,6 @@ func NewPathDefault(rf bgp.RouteFamily, source *PeerInfo, nlri bgp.AddrPrefixInt path.nexthop = nexthop path.withdraw = isWithdraw path.medSetByTargetNeighbor = medSetByTargetNeighbor - path.isBest = false return path } @@ -94,15 +93,12 @@ func (pd *PathDefault) MarshalJSON() ([]byte, error) { Network string Nexthop string Attrs []bgp.PathAttributeInterface - //Metric string - //origin string - Best string + Best string }{ Network: prefix.String() + "/" + fmt.Sprint(prefixLen), Nexthop: pd.nexthop.String(), - //Metric: fmt.Sprint(med), - Attrs: pd.getPathAttrs(), - Best: fmt.Sprint(pd.isBest), + Attrs: pd.getPathAttrs(), + Best: fmt.Sprint(pd.isBest), }) } |