summaryrefslogtreecommitdiffhomepage
path: root/server/peer.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-10-21 09:50:39 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-10-21 09:50:39 +0900
commita1a86cd2127cd30c7781563ac8e00257f1214779 (patch)
tree381c83dfb7d1d452a605a3dcfae562923678c902 /server/peer.go
parentec8c83d950c25a6b6d8b75655f9c48907dc9afd8 (diff)
table: make AdjRib API take slice of RouteFamily
Make the code simpler Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r--server/peer.go24
1 files changed, 11 insertions, 13 deletions
diff --git a/server/peer.go b/server/peer.go
index b5a62b88..ea1d8098 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -115,11 +115,9 @@ func (peer *Peer) updateAccepted(accepted uint32) {
func (peer *Peer) getAccepted(rfList []bgp.RouteFamily) []*table.Path {
var pathList []*table.Path
- for _, rf := range rfList {
- for _, path := range peer.adjRib.GetInPathList(rf) {
- if path.Filtered == false {
- pathList = append(pathList, path)
- }
+ for _, path := range peer.adjRib.GetInPathList(rfList) {
+ if path.Filtered == false {
+ pathList = append(pathList, path)
}
}
return pathList
@@ -205,7 +203,7 @@ func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) ([]*table.Path, bool, []*b
break
}
if _, ok := peer.capMap[bgp.BGP_CAP_ROUTE_REFRESH]; ok {
- pathList = peer.adjRib.GetOutPathList(rf)
+ pathList = peer.adjRib.GetOutPathList([]bgp.RouteFamily{rf})
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
@@ -327,12 +325,11 @@ func (peer *Peer) ToApiStruct() *api.Peer {
received := uint32(0)
accepted := uint32(0)
if f.state == bgp.BGP_FSM_ESTABLISHED {
- for _, rf := range peer.configuredRFlist() {
- advertized += uint32(peer.adjRib.GetOutCount(rf))
- received += uint32(peer.adjRib.GetInCount(rf))
- }
+ rfList := peer.configuredRFlist()
+ advertized = uint32(peer.adjRib.GetOutCount(rfList))
+ received = uint32(peer.adjRib.GetInCount(rfList))
if peer.staleAccepted {
- accepted = uint32(len(peer.getAccepted(peer.configuredRFlist())))
+ accepted = uint32(len(peer.getAccepted(rfList)))
peer.updateAccepted(accepted)
} else {
accepted = peer.accepted
@@ -464,8 +461,9 @@ func (peer *Peer) ApplyPolicy(d table.PolicyDirection, paths []*table.Path) ([]*
return newpaths, filteredPaths
}
-func (peer *Peer) DropAll(rf bgp.RouteFamily) {
- peer.adjRib.DropAll(rf)
+func (peer *Peer) DropAll(rfList []bgp.RouteFamily) {
+ peer.adjRib.DropIn(rfList)
+ peer.adjRib.DropOut(rfList)
peer.staleAccepted = false
peer.accepted = 0
}