diff options
-rwxr-xr-x | cli/gobgpcli | 1 | ||||
-rw-r--r-- | config/bgp_configs.go | 3 | ||||
-rw-r--r-- | server/fsm.go | 12 | ||||
-rw-r--r-- | server/peer.go | 32 |
4 files changed, 32 insertions, 16 deletions
diff --git a/cli/gobgpcli b/cli/gobgpcli index de3e7109..5c2cec20 100755 --- a/cli/gobgpcli +++ b/cli/gobgpcli @@ -129,6 +129,7 @@ class Show(object): print(" Updates: {:>10d} {:>10d}".format(n["info"]["update_message_out"], n["info"]["update_message_in"])) print(" Keepalives: {:>10d} {:>10d}".format(n["info"]["keepalive_message_out"], n["info"]["keepalive_message_in"])) print(" Route Refesh: {:>10d} {:>10d}".format(n["info"]["refresh_message_out"], n["info"]["refresh_message_in"])) + print(" Discarded: {:>10d} {:>10d}".format(n["info"]["DiscardedOut"], n["info"]["DiscardedIn"])) print(" Total: {:>10d} {:>10d}".format(n["info"]["total_message_out"], n["info"]["total_message_in"])) print("") return 0 diff --git a/config/bgp_configs.go b/config/bgp_configs.go index dee0b9a5..99995cdc 100644 --- a/config/bgp_configs.go +++ b/config/bgp_configs.go @@ -403,6 +403,9 @@ type BgpNeighborCommonStateType struct { // Dynamic Capability output count DynamicCapOut uint32 + DiscardedOut uint32 + DiscardedIn uint32 + TotalIn uint32 TotalOut uint32 diff --git a/server/fsm.go b/server/fsm.go index 0488fa8b..a8c41e9c 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -92,6 +92,12 @@ func (fsm *FSM) bgpMessageStateUpdate(MessageType uint8, isIn bool) { } else { state.RefreshOut++ } + default: + if isIn { + state.DiscardedIn++ + } else { + state.DiscardedOut++ + } } } @@ -255,6 +261,7 @@ func (h *FSMHandler) recvMessageWithError() error { hd := &bgp.BGPHeader{} err = hd.DecodeFromBytes(headerBuf) if err != nil { + h.fsm.bgpMessageStateUpdate(0, true) log.WithFields(log.Fields{ "Topic": "Peer", "Key": h.fsm.peerConfig.NeighborAddress, @@ -276,7 +283,10 @@ func (h *FSMHandler) recvMessageWithError() error { var fmsg *fsmMsg m, err := bgp.ParseBGPBody(hd, bodyBuf) if err == nil { + h.fsm.bgpMessageStateUpdate(m.Header.Type, true) err = bgp.ValidateBGPMessage(m) + } else { + h.fsm.bgpMessageStateUpdate(0, true) } if err != nil { log.WithFields(log.Fields{ @@ -293,8 +303,6 @@ func (h *FSMHandler) recvMessageWithError() error { MsgType: FSM_MSG_BGP_MESSAGE, MsgData: m, } - h.fsm.bgpMessageStateUpdate(m.Header.Type, true) - if h.fsm.state == bgp.BGP_FSM_ESTABLISHED { if m.Header.Type == bgp.BGP_MSG_KEEPALIVE || m.Header.Type == bgp.BGP_MSG_UPDATE { h.holdTimer.Reset(time.Second * time.Duration(h.fsm.negotiatedHoldTime)) diff --git a/server/peer.go b/server/peer.go index ca10c1db..d04947fa 100644 --- a/server/peer.go +++ b/server/peer.go @@ -428,20 +428,22 @@ func (peer *Peer) MarshalJSON() ([]byte, error) { } p["info"] = struct { - BgpState string `json:"bgp_state"` - FsmEstablishedTransitions uint32 `json:"fsm_established_transitions"` - TotalMessageOut uint32 `json:"total_message_out"` - TotalMessageIn uint32 `json:"total_message_in"` - UpdateMessageOut uint32 `json:"update_message_out"` - UpdateMessageIn uint32 `json:"update_message_in"` - KeepAliveMessageOut uint32 `json:"keepalive_message_out"` - KeepAliveMessageIn uint32 `json:"keepalive_message_in"` - OpenMessageOut uint32 `json:"open_message_out"` - OpenMessageIn uint32 `json:"open_message_in"` - NotificationOut uint32 `json:"notification_out"` - NotificationIn uint32 `json:"notification_in"` - RefreshMessageOut uint32 `json:"refresh_message_out"` - RefreshMessageIn uint32 `json:"refresh_message_in"` + BgpState string `json:"bgp_state"` + FsmEstablishedTransitions uint32 `json:"fsm_established_transitions"` + TotalMessageOut uint32 `json:"total_message_out"` + TotalMessageIn uint32 `json:"total_message_in"` + UpdateMessageOut uint32 `json:"update_message_out"` + UpdateMessageIn uint32 `json:"update_message_in"` + KeepAliveMessageOut uint32 `json:"keepalive_message_out"` + KeepAliveMessageIn uint32 `json:"keepalive_message_in"` + OpenMessageOut uint32 `json:"open_message_out"` + OpenMessageIn uint32 `json:"open_message_in"` + NotificationOut uint32 `json:"notification_out"` + NotificationIn uint32 `json:"notification_in"` + RefreshMessageOut uint32 `json:"refresh_message_out"` + RefreshMessageIn uint32 `json:"refresh_message_in"` + DiscardedOut uint32 + DiscardedIn uint32 Uptime float64 `json:"uptime"` Downtime float64 `json:"downtime"` LastError string `json:"last_error"` @@ -466,6 +468,8 @@ func (peer *Peer) MarshalJSON() ([]byte, error) { NotificationIn: s.NotifyIn, RefreshMessageOut: s.RefreshOut, RefreshMessageIn: s.RefreshIn, + DiscardedOut: s.DiscardedOut, + DiscardedIn: s.DiscardedIn, Uptime: uptime, Downtime: downtime, Received: uint32(peer.adjRib.GetInCount(peer.rf)), |