diff options
author | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2018-12-22 16:33:37 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2018-12-23 19:29:23 +0900 |
commit | ababf3068c48d665e2d9d7816cbb521c74fc47c5 (patch) | |
tree | 2fc2f54823294768e88ca94eb7bdc4fb74da9259 /internal | |
parent | 5d008d7b7c22cab84d974cfb7a90a002b391538a (diff) |
make Add/Delete/ListPath APIs symmetric
- AddPath() with an api.Path object then DeletePath() works with the same api.Path object.
- ListPath() returns an api.Path object then DeletePath() works with the same api.Path object.
The above is guaranteed with and without PeerInfo (SourceAsn and SourceId).
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'internal')
-rw-r--r-- | internal/pkg/table/path.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/internal/pkg/table/path.go b/internal/pkg/table/path.go index 55748b08..eba0a6ec 100644 --- a/internal/pkg/table/path.go +++ b/internal/pkg/table/path.go @@ -146,7 +146,12 @@ type Path struct { IsWithdraw bool } +var localSource = &PeerInfo{} + func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pattrs []bgp.PathAttributeInterface, timestamp time.Time, noImplicitWithdraw bool) *Path { + if source == nil { + source = localSource + } if !isWithdraw && pattrs == nil { log.WithFields(log.Fields{ "Topic": "Table", @@ -323,7 +328,8 @@ func (path *Path) IsLocal() bool { } func (path *Path) IsIBGP() bool { - return path.GetSource().AS == path.GetSource().LocalAS + as := path.GetSource().AS + return (as == path.GetSource().LocalAS) && as != 0 } // create new PathAttributes @@ -380,9 +386,6 @@ func (path *Path) GetRouteFamily() bgp.RouteFamily { return bgp.AfiSafiToRouteFamily(path.OriginInfo().nlri.AFI(), path.OriginInfo().nlri.SAFI()) } -func (path *Path) SetSource(source *PeerInfo) { - path.OriginInfo().source = source -} func (path *Path) GetSource() *PeerInfo { return path.OriginInfo().source } |