summaryrefslogtreecommitdiffhomepage
path: root/server/fsm.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-02-16 09:51:36 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-02-16 09:51:36 +0900
commit979fdad86cac0ba67851cd2cf28582f32be2f838 (patch)
treea1162b286173f7f24e227261de976509dd1d85fe /server/fsm.go
parent4e1edd39c2333af217d8972ad8c1b7b0556c93cc (diff)
server: support discarded counters
fujita@ubuntu:~/git/gobgp$ ./cli/gobgpcli show neighbor 10.0.255.7 BGP neighbor is 10.0.255.7, remote AS 65070 BGP version 4, remote router ID 192.168.0.7 BGP state = BGP_FSM_ACTIVE, up for 0:00:01.982115 BGP OutQ = 0, Flops = 4 Neighbor capabilities: MULTIPROTOCOL: advertised and received ROUTE_REFRESH: advertised FOUR_OCTET_AS_NUMBER: advertised and received Message statistics: Sent Rcvd Opens: 4 4 Notifications: 4 0 Updates: 8 0 Keepalives: 4 4 Route Refesh: 0 0 Discarded: 0 4 Total: 20 12 Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/fsm.go')
-rw-r--r--server/fsm.go12
1 files changed, 10 insertions, 2 deletions
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))