diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-27 20:28:51 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-27 20:28:51 +0900 |
commit | a231a9e274fc66d1a7763a4d1d143f0563409c6a (patch) | |
tree | 116bb2e00459d452ee86fbe85e1e6cfec2981e83 /table/destination.go | |
parent | 1a96b48b49bb1d38b36aad1c6532e9228c6b27b2 (diff) |
table: fix ipv6 JSON reggression
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/destination.go')
-rw-r--r-- | table/destination.go | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/table/destination.go b/table/destination.go index 865ab03e..681e178f 100644 --- a/table/destination.go +++ b/table/destination.go @@ -867,11 +867,25 @@ func (ipv6d *IPv6Destination) getPrefix() net.IP { func (ipv6d *IPv6Destination) MarshalJSON() ([]byte, error) { prefix := ipv6d.getNlri().(*bgp.IPv6AddrPrefix).Prefix + idx := func() int { + for i, p := range ipv6d.DestinationDefault.knownPathList { + if p == ipv6d.DestinationDefault.getBestPath() { + return i + } + } + log.WithFields(log.Fields{ + "Topic": "Table", + "Key": prefix.String(), + }).Panic("no best path") + return 0 + }() return json.Marshal(struct { - Prefix string - Paths []Path + Prefix string + Paths []Path + BestPathIdx int }{ - Prefix: prefix.String(), - Paths: ipv6d.knownPathList, + Prefix: prefix.String(), + Paths: ipv6d.knownPathList, + BestPathIdx: idx, }) } |