summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/table/roa.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2019-10-25 20:33:59 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-10-25 20:38:33 +0900
commitb4e2d9e440a4eb6d3091a7c586d2e55b69ec968a (patch)
tree68af74b393dda96a33d47a995b8c3f12680e51e2 /internal/pkg/table/roa.go
parent6e81f596b1e924337470417cf1e3faa3260308da (diff)
table: replace radix with crit-bit algo for longer-prefixes search
faster and less memory usage. Now go-radix has gone. Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'internal/pkg/table/roa.go')
-rw-r--r--internal/pkg/table/roa.go18
1 files changed, 1 insertions, 17 deletions
diff --git a/internal/pkg/table/roa.go b/internal/pkg/table/roa.go
index 4d8aeb04..f4ff0aa2 100644
--- a/internal/pkg/table/roa.go
+++ b/internal/pkg/table/roa.go
@@ -172,22 +172,6 @@ func (rt *ROATable) DeleteAll(network string) {
}
}
-func pathToIPNet(path *Path) *net.IPNet {
- switch T := path.GetNlri().(type) {
- case *bgp.IPAddrPrefix:
- return &net.IPNet{
- IP: net.IP(T.Prefix.To4()),
- Mask: net.CIDRMask(int(T.Length), 32),
- }
- case *bgp.IPv6AddrPrefix:
- return &net.IPNet{
- IP: net.IP(T.Prefix.To16()),
- Mask: net.CIDRMask(int(T.Length), 128),
- }
- }
- return nil
-}
-
func (rt *ROATable) Validate(path *Path) *Validation {
if path.IsWithdraw || path.IsEOR() {
// RPKI isn't enabled or invalid path
@@ -229,7 +213,7 @@ func (rt *ROATable) Validate(path *Path) *Validation {
}
}
- r := pathToIPNet(path)
+ r := nlriToIPNet(path.GetNlri())
prefixLen, _ := r.Mask.Size()
var bucket *roaBucket
tree.WalkMatch(r, func(r *net.IPNet, v interface{}) bool {