diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2018-02-27 09:49:35 +0900 |
---|---|---|
committer | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2018-04-03 09:16:41 +0900 |
commit | 264bd0ca126bf721687764332a01315d56e5b671 (patch) | |
tree | 05a0eb911e99fcba2a621fde34f6fc749f130d1d /server | |
parent | a25522edddf05653bef26c5ff220f34f7354791f (diff) |
packet/bgp: Getter functions for AS segment
This patch adds getter functions for the segment type and AS list of
each segment without using type assertion.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server')
-rw-r--r-- | server/fsm.go | 6 | ||||
-rw-r--r-- | server/rpki.go | 9 |
2 files changed, 8 insertions, 7 deletions
diff --git a/server/fsm.go b/server/fsm.go index 2c2128cb..c121c85f 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -677,10 +677,10 @@ func getPathAttrFromBGPUpdate(m *bgp.BGPUpdate, typ bgp.BGPAttrType) bgp.PathAtt return nil } -func hasOwnASLoop(ownAS uint32, limit int, aspath *bgp.PathAttributeAsPath) bool { +func hasOwnASLoop(ownAS uint32, limit int, asPath *bgp.PathAttributeAsPath) bool { cnt := 0 - for _, i := range aspath.Value { - for _, as := range i.(*bgp.As4PathParam).AS { + for _, param := range asPath.Value { + for _, as := range param.GetAS() { if as == ownAS { cnt++ if cnt > limit { diff --git a/server/rpki.go b/server/rpki.go index 8f286930..75f25409 100644 --- a/server/rpki.go +++ b/server/rpki.go @@ -511,13 +511,14 @@ func ValidatePath(ownAs uint32, tree *radix.Tree, cidr string, asPath *bgp.PathA if asPath == nil || len(asPath.Value) == 0 { as = ownAs } else { - asParam := asPath.Value[len(asPath.Value)-1].(*bgp.As4PathParam) - switch asParam.Type { + param := asPath.Value[len(asPath.Value)-1] + switch param.GetType() { case bgp.BGP_ASPATH_ATTR_TYPE_SEQ: - if len(asParam.AS) == 0 { + asList := param.GetAS() + if len(asList) == 0 { as = ownAs } else { - as = asParam.AS[len(asParam.AS)-1] + as = asList[len(asList)-1] } case bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET, bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SEQ: as = ownAs |