diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-05-29 19:42:47 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-05-29 19:42:47 +0900 |
commit | ebb2c9727a4002ab1b90d43485caf9b30937f372 (patch) | |
tree | 7350e1b4f716decbce984f2895ad6972b1e6714e | |
parent | ae80d1bf8628655acc46bf044265fea73a2e9a76 (diff) |
table: fix to compare new best path with old best path
The current code uses Path.Equal(), which just check out if pathes are
idential. However, it doesn't work for two cloned pathes of a path
(soft update in case).
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | table/path.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/table/path.go b/table/path.go index eefc2780..77b811d1 100644 --- a/table/path.go +++ b/table/path.go @@ -835,5 +835,21 @@ func (path *Path) GetOrigin() (uint8, error) { } func (lhs *Path) Equal(rhs *Path) bool { - return lhs == rhs + if rhs == nil { + return false + } + + if lhs.GetSource() != rhs.GetSource() { + return false + } + + pattrs := func(arg []bgp.PathAttributeInterface) []byte { + ret := make([]byte, 0) + for _, a := range arg { + aa, _ := a.Serialize() + ret = append(ret, aa...) + } + return ret + } + return bytes.Equal(pattrs(lhs.GetPathAttrs()), pattrs(rhs.GetPathAttrs())) } |