summaryrefslogtreecommitdiffhomepage
path: root/table/destination.go
diff options
context:
space:
mode:
Diffstat (limited to 'table/destination.go')
-rw-r--r--table/destination.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/table/destination.go b/table/destination.go
index a79daa2b..23c5c00f 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -1005,3 +1005,28 @@ func NewEVPNDestination(nlri bgp.AddrPrefixInterface) *EVPNDestination {
//need Processing
return EVPNDestination
}
+
+func (evpnd *EVPNDestination) MarshalJSON() ([]byte, error) {
+ nlri := evpnd.getNlri().(*bgp.EVPNNLRI)
+ idx := func() int {
+ for i, p := range evpnd.DestinationDefault.knownPathList {
+ if p == evpnd.DestinationDefault.getBestPath() {
+ return i
+ }
+ }
+ log.WithFields(log.Fields{
+ "Topic": "Table",
+ "Key": nlri.String(),
+ }).Panic("no best path")
+ return 0
+ }()
+ return json.Marshal(struct {
+ Prefix string
+ Paths []Path
+ BestPathIdx int
+ }{
+ Prefix: nlri.String(),
+ Paths: evpnd.knownPathList,
+ BestPathIdx: idx,
+ })
+}