diff options
Diffstat (limited to 'server/fsm.go')
-rw-r--r-- | server/fsm.go | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/server/fsm.go b/server/fsm.go index 7df4b632..9377b5a8 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -37,11 +37,12 @@ const ( ) type FsmMsg struct { - MsgType FsmMsgType - MsgSrc string - MsgDst string - MsgData interface{} - PathList []*table.Path + MsgType FsmMsgType + MsgSrc string + MsgDst string + MsgData interface{} + PathList []*table.Path + timestamp time.Time } const ( @@ -470,7 +471,6 @@ func (h *FSMHandler) recvMessageWithError() error { return err } - var fmsg *FsmMsg m, err := bgp.ParseBGPBody(hd, bodyBuf) if err == nil { h.fsm.bgpMessageStateUpdate(m.Header.Type, true) @@ -478,6 +478,12 @@ func (h *FSMHandler) recvMessageWithError() error { } else { h.fsm.bgpMessageStateUpdate(0, true) } + fmsg := &FsmMsg{ + MsgType: FSM_MSG_BGP_MESSAGE, + MsgSrc: h.fsm.pConf.NeighborConfig.NeighborAddress.String(), + MsgDst: h.fsm.pConf.Transport.TransportConfig.LocalAddress.String(), + timestamp: time.Now(), + } if err != nil { log.WithFields(log.Fields{ "Topic": "Peer", @@ -485,19 +491,9 @@ func (h *FSMHandler) recvMessageWithError() error { "State": h.fsm.state, "error": err, }).Warn("malformed BGP message") - fmsg = &FsmMsg{ - MsgType: FSM_MSG_BGP_MESSAGE, - MsgSrc: h.fsm.pConf.NeighborConfig.NeighborAddress.String(), - MsgDst: h.fsm.pConf.Transport.TransportConfig.LocalAddress.String(), - MsgData: err, - } + fmsg.MsgData = err } else { - fmsg = &FsmMsg{ - MsgType: FSM_MSG_BGP_MESSAGE, - MsgSrc: h.fsm.pConf.NeighborConfig.NeighborAddress.String(), - MsgDst: h.fsm.pConf.Transport.TransportConfig.LocalAddress.String(), - MsgData: m, - } + fmsg.MsgData = m if h.fsm.state == bgp.BGP_FSM_ESTABLISHED { switch m.Header.Type { case bgp.BGP_MSG_UPDATE: @@ -513,7 +509,7 @@ func (h *FSMHandler) recvMessageWithError() error { } else { // FIXME: we should use the original message for bmp/mrt table.UpdatePathAttrs4ByteAs(body) - fmsg.PathList = table.ProcessMessage(m, h.fsm.peerInfo) + fmsg.PathList = table.ProcessMessage(m, h.fsm.peerInfo, fmsg.timestamp) policyMutex.RLock() h.fsm.peer.ApplyPolicy(table.POLICY_DIRECTION_IN, fmsg.PathList) policyMutex.RUnlock() |