diff options
-rw-r--r-- | config/bgp_configs.go | 7 | ||||
-rw-r--r-- | server/fsm.go | 2 | ||||
-rw-r--r-- | server/peer.go | 28 | ||||
-rw-r--r-- | server/peer_test.go | 2 | ||||
-rw-r--r-- | test/scenario_test/exabgp_test_conf/gobgpd.conf | 2 |
5 files changed, 19 insertions, 22 deletions
diff --git a/config/bgp_configs.go b/config/bgp_configs.go index 0aa1a18a..acac016c 100644 --- a/config/bgp_configs.go +++ b/config/bgp_configs.go @@ -16,7 +16,6 @@ package config import "net" -import "time" // typedef for typedef bgp:peer-type type PeerTypeDef int @@ -372,8 +371,8 @@ type BgpNeighborCommonStateType struct { // peer-state State uint32 // peer-uptime - Uptime time.Time - Downtime time.Time + Uptime int64 + Downtime int64 // BGP statistics // Open message input count @@ -385,7 +384,7 @@ type BgpNeighborCommonStateType struct { // Update message ouput count UpdateOut uint32 // Update message received time - UpdateRecvTime time.Time + UpdateRecvTime int64 // Keepalive input count KeepaliveIn uint32 // Keepalive output count diff --git a/server/fsm.go b/server/fsm.go index acc4e3ec..547eafb6 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -91,7 +91,7 @@ func (fsm *FSM) bgpMessageStateUpdate(MessageType uint8, isIn bool) { case bgp.BGP_MSG_UPDATE: if isIn { state.UpdateIn++ - state.UpdateRecvTime = time.Now() + state.UpdateRecvTime = time.Now().Unix() } else { state.UpdateOut++ } diff --git a/server/peer.go b/server/peer.go index ad8a72f7..4e8f4ae8 100644 --- a/server/peer.go +++ b/server/peer.go @@ -80,7 +80,7 @@ func NewPeer(g config.GlobalType, peer config.NeighborType, serverMsgCh chan *se } p.fsm = NewFSM(&g, &peer, p.acceptedConnCh) peer.BgpNeighborCommonState.State = uint32(bgp.BGP_FSM_IDLE) - peer.BgpNeighborCommonState.Downtime = time.Now() + peer.BgpNeighborCommonState.Downtime = time.Now().Unix() if peer.NeighborAddress.To4() != nil { p.rf = bgp.RF_IPv4_UC } else { @@ -143,7 +143,7 @@ func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) { }).Warn("ROUTE_REFRESH received but the capability wasn't advertised") } case bgp.BGP_MSG_UPDATE: - peer.peerConfig.BgpNeighborCommonState.UpdateRecvTime = time.Now() + peer.peerConfig.BgpNeighborCommonState.UpdateRecvTime = time.Now().Unix() body := m.Body.(*bgp.BGPUpdate) _, err := bgp.ValidateUpdateMsg(body, []bgp.RouteFamily{peer.rf}) if err != nil { @@ -366,10 +366,10 @@ func (peer *Peer) loop() error { if peer.peerConfig.BgpNeighborCommonState.State == uint32(bgp.BGP_FSM_ESTABLISHED) { pathList := peer.adjRib.GetOutPathList(peer.rf) peer.sendMessages(table.CreateUpdateMsgFromPaths(pathList)) - peer.fsm.peerConfig.BgpNeighborCommonState.Uptime = time.Now() + peer.fsm.peerConfig.BgpNeighborCommonState.Uptime = time.Now().Unix() peer.fsm.peerConfig.BgpNeighborCommonState.EstablishedCount++ } else { - peer.fsm.peerConfig.BgpNeighborCommonState.Downtime = time.Now() + peer.fsm.peerConfig.BgpNeighborCommonState.Downtime = time.Now().Unix() } sameState := true @@ -395,7 +395,7 @@ func (peer *Peer) loop() error { sameState = false if oldState == bgp.BGP_FSM_ESTABLISHED { t := time.Now() - if t.Sub(peer.fsm.peerConfig.BgpNeighborCommonState.Uptime) < FLOP_THRESHOLD { + if t.Sub(time.Unix(peer.fsm.peerConfig.BgpNeighborCommonState.Uptime, 0)) < FLOP_THRESHOLD { peer.fsm.peerConfig.BgpNeighborCommonState.Flops++ } peer.adjRib.DropAllIn(peer.rf) @@ -474,13 +474,13 @@ func (peer *Peer) MarshalJSON() ([]byte, error) { s := c.BgpNeighborCommonState - uptime := float64(0) - if !s.Uptime.IsZero() { - uptime = time.Now().Sub(s.Uptime).Seconds() + uptime := int64(0) + if s.Uptime != 0 { + uptime = int64(time.Now().Sub(time.Unix(s.Uptime, 0)).Seconds()) } - downtime := float64(0) - if !s.Downtime.IsZero() { - downtime = time.Now().Sub(s.Downtime).Seconds() + downtime := int64(0) + if s.Downtime != 0 { + downtime = int64(time.Now().Sub(time.Unix(s.Downtime, 0)).Seconds()) } advertized := uint32(0) @@ -506,9 +506,9 @@ func (peer *Peer) MarshalJSON() ([]byte, error) { RefreshMessageIn uint32 `json:"refresh_message_in"` DiscardedOut uint32 DiscardedIn uint32 - Uptime float64 `json:"uptime"` - Downtime float64 `json:"downtime"` - LastError string `json:"last_error"` + Uptime int64 `json:"uptime"` + Downtime int64 `json:"downtime"` + LastError string `json:"last_error"` Received uint32 Accepted uint32 Advertized uint32 diff --git a/server/peer_test.go b/server/peer_test.go index 9aa892dd..c3612a6e 100644 --- a/server/peer_test.go +++ b/server/peer_test.go @@ -512,7 +512,7 @@ func makePeer(globalConfig config.GlobalType, peerConfig config.NeighborType) *P p.fsm = NewFSM(&globalConfig, &peerConfig, p.acceptedConnCh) peerConfig.BgpNeighborCommonState.State = uint32(bgp.BGP_FSM_IDLE) - peerConfig.BgpNeighborCommonState.Downtime = time.Now() + peerConfig.BgpNeighborCommonState.Downtime = time.Now().Unix() if peerConfig.NeighborAddress.To4() != nil { p.rf = bgp.RF_IPv4_UC } else { diff --git a/test/scenario_test/exabgp_test_conf/gobgpd.conf b/test/scenario_test/exabgp_test_conf/gobgpd.conf index 27da5ba7..aa4c5d78 100644 --- a/test/scenario_test/exabgp_test_conf/gobgpd.conf +++ b/test/scenario_test/exabgp_test_conf/gobgpd.conf @@ -59,7 +59,6 @@ OpenOut = 0 UpdateIn = 0 UpdateOut = 0 - UpdateRecvTime = 0001-01-01T00:00:00Z KeepaliveIn = 0 KeepaliveOut = 0 NotifyIn = 0 @@ -123,7 +122,6 @@ OpenOut = 0 UpdateIn = 0 UpdateOut = 0 - UpdateRecvTime = 0001-01-01T00:00:00Z KeepaliveIn = 0 KeepaliveOut = 0 NotifyIn = 0 |