From 529bec9f5c907bb9b93c6e5c7287b6985ff1ee03 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 13 Jan 2015 23:28:29 +0900 Subject: table: fix best path presentation Signed-off-by: FUJITA Tomonori --- table/destination.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'table/destination.go') 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 { -- cgit v1.2.3