summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-05-07 10:05:04 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-05-07 21:18:04 +0900
commitdc9fe2b1cc7db1a8d53d4f3553681b9531a4ff0e (patch)
tree27544a114f60c9a70571e62bb8d4526a01f6518d /server
parentcc42a3137cd8d09521b6776ba0f1d76c186f4713 (diff)
table: use shorter key for map of ipv4 and ipv6 prefixes
save about 100MB memory. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/server.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/server/server.go b/server/server.go
index 15b95073..e338fe53 100644
--- a/server/server.go
+++ b/server/server.go
@@ -2265,9 +2265,15 @@ func (s *BgpServer) ValidateRib(prefix string) error {
if t, ok := s.globalRib.Tables[rf]; ok {
dsts := t.GetDestinations()
if prefix != "" {
- _, p, _ := net.ParseCIDR(prefix)
- if dst := t.GetDestination(p.String()); dst != nil {
- dsts = map[string]*table.Destination{p.String(): dst}
+ addr, _, _ := net.ParseCIDR(prefix)
+ var nlri bgp.AddrPrefixInterface
+ if addr.To16() == nil {
+ nlri, _ = bgp.NewPrefixFromRouteFamily(bgp.AFI_IP, bgp.SAFI_UNICAST, prefix)
+ } else {
+ nlri, _ = bgp.NewPrefixFromRouteFamily(bgp.AFI_IP6, bgp.SAFI_UNICAST, prefix)
+ }
+ if dst := t.GetDestination(nlri); dst != nil {
+ dsts = map[string]*table.Destination{nlri.String(): dst}
}
}
for _, dst := range dsts {