diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-04-27 11:03:53 +0000 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-04-27 15:20:53 +0000 |
commit | e735b2b1cfdc7dd3ea9f1f324ab9158fc7f19802 (patch) | |
tree | 6c8d1aa4177ef367ee061b22fe0254a44a7a81ff /table | |
parent | 87a951546c43cb70ad3a03ec42de7cead8d25d72 (diff) |
table: add AS loop detection
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r-- | table/path.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/table/path.go b/table/path.go index 62a98aab..29d8a92d 100644 --- a/table/path.go +++ b/table/path.go @@ -35,6 +35,7 @@ type Path interface { GetRouteFamily() bgp.RouteFamily setSource(source *PeerInfo) GetSource() *PeerInfo + GetSourceAs() uint32 GetNexthop() net.IP SetNexthop(net.IP) setWithdraw(withdraw bool) @@ -224,6 +225,22 @@ func (pd *PathDefault) GetSource() *PeerInfo { return pd.source } +func (pd *PathDefault) GetSourceAs() uint32 { + _, attr := pd.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH) + if attr != nil { + asPathParam := attr.(*bgp.PathAttributeAsPath).Value + if len(asPathParam) == 0 { + return 0 + } + asPath := asPathParam[len(asPathParam)-1].(*bgp.As4PathParam) + if asPath.Num == 0 { + return 0 + } + return asPath.AS[asPath.Num-1] + } + return 0 +} + func (pd *PathDefault) GetNexthop() net.IP { _, attr := pd.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP) if attr != nil { |