summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-13 23:28:29 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-13 23:28:29 +0900
commit529bec9f5c907bb9b93c6e5c7287b6985ff1ee03 (patch)
tree159e4b5b013a49139a169ad2e61d47c0ae930119
parent78ec2585b7f8c1cb4f20d9c0283b3251b30669d3 (diff)
table: fix best path presentation
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--table/destination.go13
-rw-r--r--table/path.go10
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),
})
}