From fb83e41aebfa0b51c5e454d1f77870513d47e82d Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Wed, 20 Apr 2016 17:49:29 +0900 Subject: rpki: use the own AS number if asPath is empty Signed-off-by: FUJITA Tomonori --- server/rpki.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/server/rpki.go b/server/rpki.go index 5b4903e1..cb785901 100644 --- a/server/rpki.go +++ b/server/rpki.go @@ -532,20 +532,23 @@ func (c *roaManager) handleGRPC(grpcReq *GrpcRequest) { func validatePath(ownAs uint32, tree *radix.Tree, cidr string, asPath *bgp.PathAttributeAsPath) config.RpkiValidationResultType { var as uint32 - if asPath == nil || len(asPath.Value) == 0 { - return config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND - } - asParam := asPath.Value[len(asPath.Value)-1].(*bgp.As4PathParam) - switch asParam.Type { - case bgp.BGP_ASPATH_ATTR_TYPE_SEQ: - if len(asParam.AS) == 0 { + + if len(asPath.Value) == 0 { + as = ownAs + } else { + asParam := asPath.Value[len(asPath.Value)-1].(*bgp.As4PathParam) + switch asParam.Type { + case bgp.BGP_ASPATH_ATTR_TYPE_SEQ: + if len(asParam.AS) == 0 { + as = ownAs + } else { + as = asParam.AS[len(asParam.AS)-1] + } + case bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET, bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SEQ: + as = ownAs + default: return config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND } - as = asParam.AS[len(asParam.AS)-1] - case bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET, bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SEQ: - as = ownAs - default: - return config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND } _, n, _ := net.ParseCIDR(cidr) ones, _ := n.Mask.Size() -- cgit v1.2.3