diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-09-30 16:20:32 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-09-30 16:20:32 +0900 |
commit | bbdfde029d269b89c557dbd852dbc1c8e377ce38 (patch) | |
tree | 7570321a32dd04cbe19bab09831509d5887dbe62 /server | |
parent | eaa7810893c10d2768e61306e38859e80da01111 (diff) |
peer: add accepted route counter
cut time of gobgp neighbor command
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/peer.go | 13 | ||||
-rw-r--r-- | server/server.go | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/server/peer.go b/server/peer.go index 3b0bd44b..a36c44a2 100644 --- a/server/peer.go +++ b/server/peer.go @@ -43,6 +43,7 @@ type Peer struct { outgoing chan *bgp.BGPMessage inPolicies []*policy.Policy defaultInPolicy config.DefaultPolicyType + accepted uint32 importPolicies []*policy.Policy defaultImportPolicy config.DefaultPolicyType exportPolicies []*policy.Policy @@ -291,13 +292,11 @@ func (peer *Peer) ToApiStruct() *api.Peer { advertized := uint32(0) 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)) // FIXME: we should store 'accepted' in memory - accepted += uint32(len(peer.ApplyPolicy(POLICY_DIRECTION_IN, peer.adjRib.GetInPathList(rf)))) } } @@ -331,7 +330,7 @@ func (peer *Peer) ToApiStruct() *api.Peer { Uptime: uptime, Downtime: downtime, Received: received, - Accepted: accepted, + Accepted: peer.accepted, Advertized: advertized, OutQ: uint32(len(peer.outgoing)), Flops: s.Flops, @@ -443,6 +442,9 @@ func (peer *Peer) ApplyPolicy(d PolicyDirection, paths []*table.Path) []*table.P switch result { case policy.ROUTE_TYPE_ACCEPT: newpaths = append(newpaths, newpath) + if d == POLICY_DIRECTION_IN { + peer.accepted += 1 + } case policy.ROUTE_TYPE_REJECT: log.WithFields(log.Fields{ "Topic": "Peer", @@ -454,3 +456,8 @@ func (peer *Peer) ApplyPolicy(d PolicyDirection, paths []*table.Path) []*table.P } return newpaths } + +func (peer *Peer) DropAll(rf bgp.RouteFamily) { + peer.adjRib.DropAll(rf) + peer.accepted = 0 +} diff --git a/server/server.go b/server/server.go index 9d444a32..f4777e8e 100644 --- a/server/server.go +++ b/server/server.go @@ -733,7 +733,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *fsmMsg, incoming chan * } for _, rf := range peer.configuredRFlist() { - peer.adjRib.DropAll(rf) + peer.DropAll(rf) } msgs = append(msgs, server.dropPeerAllRoutes(peer)...) |