From 4867124319c179d2a573d465a5dff2845176fb99 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Tue, 23 Jun 2015 11:13:40 +0900 Subject: table: add Equal() method to compare PeerInfo this patch fixes the wrong behavior shown below $ gobgp global rib add 10.0.0.0/24 $ gobgp global rib del 10.0.0.0/24 $ gobgp global rib Network Next Hop AS_PATH Age Attrs *> 10.0.0.0/24 0.0.0.0 65000 00:05:48 [{Origin: IGP}] since we used to compare path's source by PeerInfo's pointer, locally originated routes is considered as a different route even if they have same prefix. this patch introduce Equal() method to compare PeerInfo's content and fix this wrong behavior. Signed-off-by: ISHIDA Wataru --- table/path.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'table/path.go') diff --git a/table/path.go b/table/path.go index 05a54aaa..c095ab24 100644 --- a/table/path.go +++ b/table/path.go @@ -54,6 +54,7 @@ type Path interface { Clone(IsWithdraw bool) Path getTimestamp() time.Time setTimestamp(t time.Time) + isLocal() bool ToApiStruct() *api.Path MarshalJSON() ([]byte, error) } @@ -180,6 +181,14 @@ func (pd *PathDefault) setTimestamp(t time.Time) { pd.timestamp = t } +func (pd *PathDefault) isLocal() bool { + var ret bool + if pd.source.Address == nil { + ret = true + } + return ret +} + func (pd *PathDefault) ToApiStruct() *api.Path { pathAttrs := func(arg []bgp.PathAttributeInterface) []*api.PathAttr { ret := make([]*api.PathAttr, 0, len(arg)) -- cgit v1.2.3