diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-04-21 13:29:59 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-04-21 13:29:59 +0900 |
commit | 35efcd570d65a55cf059653ba153fdb360b71672 (patch) | |
tree | 9f7083e24b4074404afbac23d55ae37244f04b1d /server/rpki.go | |
parent | 7e1b1868193bb2a6bbf49d17f2af7dc1f6a962bf (diff) |
rpki: delete roa validation stream API
better to be implemented outside GoBGP.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/rpki.go')
-rw-r--r-- | server/rpki.go | 51 |
1 files changed, 10 insertions, 41 deletions
diff --git a/server/rpki.go b/server/rpki.go index 5b2218ff..5b4903e1 100644 --- a/server/rpki.go +++ b/server/rpki.go @@ -530,84 +530,53 @@ func (c *roaManager) handleGRPC(grpcReq *GrpcRequest) { } } -func validatePath(ownAs uint32, tree *radix.Tree, cidr string, asPath *bgp.PathAttributeAsPath) (config.RpkiValidationResultType, []*ROA) { +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, []*ROA{} + 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 { - return config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND, []*ROA{} + 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, []*ROA{} + return config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND } _, n, _ := net.ParseCIDR(cidr) ones, _ := n.Mask.Size() prefixLen := uint8(ones) _, b, _ := tree.LongestPrefix(table.IpToRadixkey(n.IP, prefixLen)) if b == nil { - return config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND, []*ROA{} + return config.RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND } - roaList := make([]*ROA, 0) - - result := config.RPKI_VALIDATION_RESULT_TYPE_INVALID bucket, _ := b.(*roaBucket) for _, r := range bucket.entries { if prefixLen > r.MaxLen { continue } if r.AS == as { - result = config.RPKI_VALIDATION_RESULT_TYPE_VALID + return config.RPKI_VALIDATION_RESULT_TYPE_VALID } - roaList = append(roaList, r) } - return result, roaList + return config.RPKI_VALIDATION_RESULT_TYPE_INVALID } -func (c *roaManager) validate(pathList []*table.Path, isMonitor bool) []*api.ROAResult { - results := make([]*api.ROAResult, 0) - if len(c.clientMap) == 0 { - return results - } +func (c *roaManager) validate(pathList []*table.Path) { for _, path := range pathList { - if path.IsWithdraw { + if path.IsWithdraw || path.IsEOR() { continue } if tree, ok := c.Roas[path.GetRouteFamily()]; ok { - r, roaList := validatePath(c.AS, tree, path.GetNlri().String(), path.GetAsPath()) - if isMonitor && path.Validation() != config.RpkiValidationResultType(r) { - apiRoaList := func() []*api.ROA { - apiRoaList := make([]*api.ROA, 0) - for _, r := range roaList { - apiRoaList = append(apiRoaList, r.toApiStruct()) - } - return apiRoaList - }() - rr := &api.ROAResult{ - Address: path.GetSource().Address.String(), - Timestamp: path.GetTimestamp().Unix(), - OriginAs: path.GetSourceAs(), - Prefix: path.GetNlri().String(), - OldResult: api.ROAResult_ValidationResult(path.Validation().ToInt()), - NewResult: api.ROAResult_ValidationResult(r.ToInt()), - Roas: apiRoaList, - } - if b := path.GetAsPath(); b != nil { - rr.AspathAttr, _ = b.Serialize() - } - results = append(results, rr) - } + r := validatePath(c.AS, tree, path.GetNlri().String(), path.GetAsPath()) path.SetValidation(config.RpkiValidationResultType(r)) } } - return results } type roaClient struct { |