diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-01-24 06:15:31 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-01-24 06:15:31 -0800 |
commit | bc025e40a5b85c110de1d834e500318466361339 (patch) | |
tree | ec4dfe881b6a7554c0364e4c0951c61a29f49ee2 /server | |
parent | 0986a67e07aaa4253403f392a98b0ec483c5562c (diff) |
rpki: softreset delete all related ROAs
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/rpki.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server/rpki.go b/server/rpki.go index cf05b011..ef6ec47f 100644 --- a/server/rpki.go +++ b/server/rpki.go @@ -138,6 +138,30 @@ func newROAManager(as uint32, servers []config.RpkiServer) (*roaManager, error) return m, nil } +func (m *roaManager) deleteAllROA(network string) { + for _, tree := range m.roas { + deleteKeys := make([]string, 0, tree.Len()) + tree.Walk(func(s string, v interface{}) bool { + b, _ := v.(*roaBucket) + newEntries := make([]*roa, 0, len(b.entries)) + for _, r := range b.entries { + if r.Src != network { + newEntries = append(newEntries, r) + } + } + if len(newEntries) > 0 { + b.entries = newEntries + } else { + deleteKeys = append(deleteKeys, s) + } + return false + }) + for _, key := range deleteKeys { + tree.Delete(key) + } + } +} + func (m *roaManager) operate(op api.Operation, address string) error { for network, client := range m.clientMap { add, _ := splitHostPort(network) @@ -150,6 +174,7 @@ func (m *roaManager) operate(op api.Operation, address string) error { client.reset() case api.Operation_SOFTRESET: client.softReset() + m.deleteAllROA(network) } return nil } |