diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-09 04:50:10 +0000 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-09 04:50:10 +0000 |
commit | 978c6a3df0f08756511e42c1f2c28b3cb7bd0f1d (patch) | |
tree | 698d466791ff5fdcd0c42adaa98a90dc6bd42249 | |
parent | f7540b7715bf8e3be66aa79dca519c5032f34233 (diff) |
server: ignore stale fsm messages
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | server/fsm.go | 9 | ||||
-rw-r--r-- | server/server.go | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/server/fsm.go b/server/fsm.go index 0f3e5538..3ae70856 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -100,6 +100,7 @@ type FsmMsg struct { PathList []*table.Path timestamp time.Time payload []byte + Version uint } type FsmOutgoingMsg struct { @@ -134,6 +135,8 @@ func (s AdminState) String() string { } } +var fsmVersion uint + type FSM struct { t tomb.Tomb gConf *config.Global @@ -154,6 +157,7 @@ type FSM struct { peerInfo *table.PeerInfo policy *table.RoutingPolicy gracefulRestartTimer *time.Timer + version uint } func (fsm *FSM) bgpMessageStateUpdate(MessageType uint8, isIn bool) { @@ -212,6 +216,7 @@ func NewFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingP } pConf.State.SessionState = config.IntToSessionStateMap[int(bgp.BGP_FSM_IDLE)] pConf.Timers.State.Downtime = time.Now().Unix() + fsmVersion++ fsm := &FSM{ gConf: gConf, pConf: pConf, @@ -226,6 +231,7 @@ func NewFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingP peerInfo: table.NewPeerInfo(gConf, pConf), policy: policy, gracefulRestartTimer: time.NewTimer(time.Hour), + version: fsmVersion, } fsm.gracefulRestartTimer.Stop() fsm.t.Go(fsm.connectLoop) @@ -606,6 +612,7 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) { MsgType: FSM_MSG_BGP_MESSAGE, MsgSrc: h.fsm.pConf.Config.NeighborAddress, MsgData: err, + Version: h.fsm.version, } return fmsg, err } @@ -628,6 +635,7 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) { MsgType: FSM_MSG_BGP_MESSAGE, MsgSrc: h.fsm.pConf.Config.NeighborAddress, timestamp: now, + Version: h.fsm.version, } if err != nil { log.WithFields(log.Fields{ @@ -1278,6 +1286,7 @@ func (h *FSMHandler) loop() error { MsgType: FSM_MSG_STATE_CHANGE, MsgSrc: fsm.pConf.Config.NeighborAddress, MsgData: nextState, + Version: h.fsm.version, } h.stateCh <- e } diff --git a/server/server.go b/server/server.go index 4810378e..d8e1d7c8 100644 --- a/server/server.go +++ b/server/server.go @@ -235,6 +235,10 @@ func (server *BgpServer) Serve() { log.Warn("Can't find the neighbor ", e.MsgSrc) return } + if e.Version != peer.fsm.version { + log.Debug("FSM Version inconsistent") + return + } m := server.handleFSMMessage(peer, e) if len(m) > 0 { senderMsgs = append(senderMsgs, m...) |