summaryrefslogtreecommitdiffhomepage
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
parentfe3a7e226622a58d746a199b96cc938c39f9445b (diff)
server: implement OutQ and Flops support
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rwxr-xr-xcli/gobgpcli1
-rw-r--r--config/bgp_configs.go1
-rw-r--r--server/peer.go14
3 files changed, 15 insertions, 1 deletions
diff --git a/cli/gobgpcli b/cli/gobgpcli
index a6fdfd5a..bbb70503 100755
--- a/cli/gobgpcli
+++ b/cli/gobgpcli
@@ -96,6 +96,7 @@ class Show(object):
print("BGP neighbor is {:s}, remote AS {:d}".format(n["conf"]["remote_ip"], n["conf"]["remote_as"]))
print(" BGP version 4, remote router ID {:s}".format(n["conf"]["id"]))
print(" BGP state = {:s}, up for {:s}".format(n["info"]["bgp_state"], str(timedelta(seconds=n["info"]["uptime"]))))
+ print(" BGP OutQ = {:d}, Flops = {:d}".format(n["info"]["OutQ"], n["info"]["Flops"]))
print(" Neighbor capabilities:")
allcap = set(n["conf"]["RemoteCap"]) | set(n["conf"]["LocalCap"])
for i in sorted(allcap):
diff --git a/config/bgp_configs.go b/config/bgp_configs.go
index ca2bafd2..c994faac 100644
--- a/config/bgp_configs.go
+++ b/config/bgp_configs.go
@@ -417,6 +417,7 @@ type BgpNeighborCommonStateType struct {
EstablishedCount uint32
// Dropped
DroppedCount uint32
+ Flops uint32
}
//struct for container transport-options
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)