summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-03-10 12:18:29 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-03-14 00:44:15 +0900
commit7d68855c86daa8fa8202f5cbdf585d9d8c1d3d21 (patch)
tree0bcc5384b45f7d5461c5a759413accda1b29b9de /server
parentce5917c0a8d6206fd1d70a5a476eb99e510fc9f6 (diff)
table: remove Destination's WithdrawnList and UpdatedPathList used for validation
Withdrawn pathes are kept to be referenced thus the memory for them are not freed. Nobody uses this so let's remove it. Paths in UpdatedPathList are also in KnownPathList so doesn't lead to memory leak. But remove it for simplicity. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/server.go93
1 files changed, 46 insertions, 47 deletions
diff --git a/server/server.go b/server/server.go
index 9588ecd5..ef10f1f6 100644
--- a/server/server.go
+++ b/server/server.go
@@ -589,8 +589,8 @@ func (server *BgpServer) dropPeerAllRoutes(peer *Peer, families []bgp.RouteFamil
options := &table.PolicyOptions{}
for _, rf := range families {
- dsts := server.globalRib.DeletePathsByPeer(peer.fsm.peerInfo, rf)
- server.validatePaths(dsts, true)
+ dsts, withdrawn := server.globalRib.DeletePathsByPeer(peer.fsm.peerInfo, rf)
+ server.validatePaths(nil, withdrawn, true)
if peer.isRouteServerClient() {
for _, targetPeer := range server.neighborMap {
if !targetPeer.isRouteServerClient() || targetPeer == peer || targetPeer.fsm.state != bgp.BGP_FSM_ESTABLISHED {
@@ -806,55 +806,54 @@ func (server *BgpServer) isRpkiMonitored() bool {
return false
}
-func (server *BgpServer) validatePaths(dsts []*table.Destination, peerDown bool) {
+func (server *BgpServer) validatePaths(newly, withdrawn []*table.Path, peerDown bool) {
isMonitor := server.isRpkiMonitored()
- for _, dst := range dsts {
- if isMonitor {
- rrList := make([]*api.ROAResult, 0, len(dst.WithdrawnList))
- for _, path := range dst.WithdrawnList {
- if path.Validation() == config.RPKI_VALIDATION_RESULT_TYPE_INVALID {
- reason := api.ROAResult_WITHDRAW
- if peerDown {
- reason = api.ROAResult_PEER_DOWN
- }
- rr := &api.ROAResult{
- Reason: reason,
- 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(path.Validation().ToInt()),
- }
- if b := path.GetAsPath(); b != nil {
- rr.AspathAttr, _ = b.Serialize()
- }
- rrList = append(rrList, rr)
+ if isMonitor {
+ rrList := make([]*api.ROAResult, 0, len(withdrawn))
+ for _, path := range withdrawn {
+ if path.Validation() == config.RPKI_VALIDATION_RESULT_TYPE_INVALID {
+ reason := api.ROAResult_WITHDRAW
+ if peerDown {
+ reason = api.ROAResult_PEER_DOWN
}
+ rr := &api.ROAResult{
+ Reason: reason,
+ 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(path.Validation().ToInt()),
+ }
+ if b := path.GetAsPath(); b != nil {
+ rr.AspathAttr, _ = b.Serialize()
+ }
+ rrList = append(rrList, rr)
}
- server.broadcastValidationResults(rrList)
}
- if vResults := server.roaManager.validate(dst.UpdatedPathList, isMonitor); isMonitor {
- for i, path := range dst.UpdatedPathList {
- old := func() config.RpkiValidationResultType {
- for _, withdrawn := range dst.WithdrawnList {
- if path.GetSource().Equal(withdrawn.GetSource()) {
- return withdrawn.Validation()
- }
+ server.broadcastValidationResults(rrList)
+ }
+
+ if vResults := server.roaManager.validate(newly, isMonitor); isMonitor {
+ for i, path := range newly {
+ old := func() config.RpkiValidationResultType {
+ for _, withdrawn := range withdrawn {
+ if path.GetSource().Equal(withdrawn.GetSource()) {
+ return withdrawn.Validation()
}
- return config.RPKI_VALIDATION_RESULT_TYPE_NONE
- }()
- vResults[i].OldResult = api.ROAResult_ValidationResult(old.ToInt())
- }
- rrList := make([]*api.ROAResult, 0, len(vResults))
- for _, rr := range vResults {
- invalid := api.ROAResult_ValidationResult(config.RPKI_VALIDATION_RESULT_TYPE_INVALID.ToInt())
- if rr.NewResult == invalid || rr.OldResult == invalid {
- rrList = append(rrList, rr)
}
+ return config.RPKI_VALIDATION_RESULT_TYPE_NONE
+ }()
+ vResults[i].OldResult = api.ROAResult_ValidationResult(old.ToInt())
+ }
+ rrList := make([]*api.ROAResult, 0, len(vResults))
+ for _, rr := range vResults {
+ invalid := api.ROAResult_ValidationResult(config.RPKI_VALIDATION_RESULT_TYPE_INVALID.ToInt())
+ if rr.NewResult == invalid || rr.OldResult == invalid {
+ rrList = append(rrList, rr)
}
- server.broadcastValidationResults(rrList)
}
+ server.broadcastValidationResults(rrList)
}
}
@@ -875,8 +874,8 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) ([]
}
moded = append(moded, server.RSimportPaths(targetPeer, pathList)...)
}
- dsts := rib.ProcessPaths(append(pathList, moded...))
- server.validatePaths(dsts, false)
+ dsts, newly, withdrawn := rib.ProcessPaths(append(pathList, moded...))
+ server.validatePaths(newly, withdrawn, false)
for _, targetPeer := range server.neighborMap {
if !targetPeer.isRouteServerClient() || targetPeer.fsm.state != bgp.BGP_FSM_ESTABLISHED || targetPeer.fsm.pConf.GracefulRestart.State.LocalRestarting {
continue
@@ -898,8 +897,8 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) ([]
pathList[idx] = server.policy.ApplyPolicy(table.GLOBAL_RIB_NAME, table.POLICY_DIRECTION_IMPORT, path, nil)
}
alteredPathList = pathList
- dsts := rib.ProcessPaths(pathList)
- server.validatePaths(dsts, false)
+ dsts, newly, withdrawn := rib.ProcessPaths(pathList)
+ server.validatePaths(newly, withdrawn, false)
sendPathList := make([]*table.Path, 0, len(dsts))
if server.bgpConfig.Global.Collector.Enabled {
sendPathList = pathList