summaryrefslogtreecommitdiffhomepage
path: root/server/peer.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-17 00:51:40 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-17 00:51:40 +0900
commitac54c58e9d5466804f67c9aca32a23beaeb6882d (patch)
tree647602dbc839d2348f37fae1e23f0e9da8a298ba /server/peer.go
parentfe3a7e226622a58d746a199b96cc938c39f9445b (diff)
server: implement OutQ and Flops support
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r--server/peer.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/server/peer.go b/server/peer.go
index 9fa6961c..f928fc10 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -27,6 +27,10 @@ import (
"time"
)
+const (
+ FLOP_THRESHOLD = time.Second * 30
+)
+
type peerMsgType int
const (
@@ -282,7 +286,11 @@ func (peer *Peer) loop() error {
peer.fsm.peerConfig.BgpNeighborCommonState.EstablishedCount++
}
if oldState == bgp.BGP_FSM_ESTABLISHED {
- peer.fsm.peerConfig.BgpNeighborCommonState.Downtime = time.Now()
+ t := time.Now()
+ peer.fsm.peerConfig.BgpNeighborCommonState.Downtime = t
+ if t.Sub(peer.fsm.peerConfig.BgpNeighborCommonState.Uptime) < FLOP_THRESHOLD {
+ peer.fsm.peerConfig.BgpNeighborCommonState.Flops++
+ }
peer.adjRib.DropAllIn(peer.rf)
pm := &peerMsg{
msgType: PEER_MSG_PEER_DOWN,
@@ -383,6 +391,8 @@ func (peer *Peer) MarshalJSON() ([]byte, error) {
Received uint32
Accepted uint32
Advertized uint32
+ OutQ int
+ Flops uint32
}{
BgpState: f.state.String(),
@@ -404,6 +414,8 @@ func (peer *Peer) MarshalJSON() ([]byte, error) {
Received: uint32(peer.adjRib.GetInCount(peer.rf)),
Accepted: uint32(peer.adjRib.GetInCount(peer.rf)),
Advertized: uint32(peer.adjRib.GetOutCount(peer.rf)),
+ OutQ: len(peer.outgoing),
+ Flops: s.Flops,
}
return json.Marshal(p)