diff options
-rw-r--r-- | table/destination.go | 2 | ||||
-rw-r--r-- | table/path.go | 17 | ||||
-rw-r--r-- | table/table_manager.go | 2 |
3 files changed, 19 insertions, 2 deletions
diff --git a/table/destination.go b/table/destination.go index dc6e073f..704cc865 100644 --- a/table/destination.go +++ b/table/destination.go @@ -92,7 +92,7 @@ func (dd *Destination) ToApiStruct() *api.Destination { idx := func() int { for i, p := range dd.knownPathList { - if p == dd.GetBestPath() { + if dd.GetBestPath().Equal(p) { return i } } diff --git a/table/path.go b/table/path.go index 0b8f732a..1fd15308 100644 --- a/table/path.go +++ b/table/path.go @@ -16,6 +16,8 @@ package table import ( + "bytes" + "encoding/json" "fmt" log "github.com/Sirupsen/logrus" "github.com/osrg/gobgp/api" @@ -456,3 +458,18 @@ func (path *Path) SetMed(med int64, doReplace bool) error { } return nil } + +func (lhs *Path) Equal(rhs *Path) bool { + if rhs == nil { + return false + } else if lhs == rhs { + return true + } + f := func(p *Path) []byte { + s := p.ToApiStruct() + s.Age = 0 + buf, _ := json.Marshal(s) + return buf + } + return bytes.Equal(f(lhs), f(rhs)) +} diff --git a/table/table_manager.go b/table/table_manager.go index f94eab9e..4a692d23 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -151,7 +151,7 @@ func (manager *TableManager) calculate(destinationList []*Destination) ([]*Path, destination.setBestPathReason(reason) currentBestPath := destination.GetBestPath() - if newBestPath != nil && currentBestPath == newBestPath { + if newBestPath != nil && newBestPath.Equal(currentBestPath) { // best path is not changed log.WithFields(log.Fields{ "Topic": "table", |