diff options
-rwxr-xr-x | cli/gobgpcli | 1 | ||||
-rw-r--r-- | config/bgp_configs.go | 1 | ||||
-rw-r--r-- | server/peer.go | 14 |
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) |