summaryrefslogtreecommitdiffhomepage
path: root/server/rpki.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-05-10 09:00:50 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-05-10 23:13:21 +0900
commit691d80e5d160b82c8b4dd1d83c959ecdffad318f (patch)
tree52d9a238bde9dd525c63bf15b8ede84ab85d56fe /server/rpki.go
parent5fc0ac2731ebbe0e812d493e837007068989faa7 (diff)
make Path objects in rib read-only
Now you can read Path objects in rib safely. Nobody modifies them. GetRib() API doesn't need to clone the objects. With full routes, this avoid allocating temporary huge memory. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/rpki.go')
-rw-r--r--server/rpki.go24
1 files changed, 11 insertions, 13 deletions
diff --git a/server/rpki.go b/server/rpki.go
index 371fda4b..6356888a 100644
--- a/server/rpki.go
+++ b/server/rpki.go
@@ -112,6 +112,10 @@ func NewROAManager(as uint32) (*roaManager, error) {
return m, nil
}
+func (c *roaManager) enabled() bool {
+ return len(c.clientMap) != 0
+}
+
func (m *roaManager) SetAS(as uint32) error {
if m.AS != 0 {
return fmt.Errorf("AS was already configured")
@@ -570,21 +574,15 @@ func ValidatePath(ownAs uint32, tree *radix.Tree, cidr string, asPath *bgp.PathA
return validation
}
-func (c *roaManager) validate(pathList []*table.Path) {
- if len(c.clientMap) == 0 {
- // RPKI isn't enabled
- return
+func (c *roaManager) validate(path *table.Path) *table.Validation {
+ if len(c.clientMap) == 0 || path.IsWithdraw || path.IsEOR() {
+ // RPKI isn't enabled or invalid path
+ return nil
}
-
- for _, path := range pathList {
- if path.IsWithdraw || path.IsEOR() {
- continue
- }
- if tree, ok := c.Roas[path.GetRouteFamily()]; ok {
- v := ValidatePath(c.AS, tree, path.GetNlri().String(), path.GetAsPath())
- path.SetValidation(v)
- }
+ if tree, ok := c.Roas[path.GetRouteFamily()]; ok {
+ return ValidatePath(c.AS, tree, path.GetNlri().String(), path.GetAsPath())
}
+ return nil
}
type roaClient struct {