diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-18 16:04:13 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-18 16:04:13 +0900 |
commit | ec278710f10c2cae7d6b3e393aa957edfd536181 (patch) | |
tree | cb8e6ec6c38ceab014d98d3ab95f159bc9d10411 /server/fsm.go | |
parent | a9e55d3bd75fd5dd633fee1ff2c9d45d6d6447ee (diff) |
server: support idlehold time after reset
After resetting a peer, the peer will remain idle for idlehold time
(by default 30 seconds). It can be configured via
IdleHoldTImeAfterReset.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/fsm.go')
-rw-r--r-- | server/fsm.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/server/fsm.go b/server/fsm.go index af6718ca..5c93fce6 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -44,6 +44,7 @@ type FSM struct { state bgp.FSMState passiveConn *net.TCPConn passiveConnCh chan *net.TCPConn + idleHoldTime float64 } func (fsm *FSM) bgpMessageStateUpdate(MessageType uint8, isIn bool) { @@ -139,13 +140,27 @@ func (h *FSMHandler) Stop() error { func (h *FSMHandler) idle() bgp.FSMState { fsm := h.fsm - // TODO: support idle hold timer if fsm.keepaliveTicker != nil { fsm.keepaliveTicker.Stop() fsm.keepaliveTicker = nil } - return bgp.BGP_FSM_ACTIVE + + idleHoldTimer := time.NewTimer(time.Second * time.Duration(fsm.idleHoldTime)) + for { + select { + case <-h.t.Dying(): + return 0 + case <-idleHoldTimer.C: + log.WithFields(log.Fields{ + "Topic": "Peer", + "Key": fsm.peerConfig.NeighborAddress, + "Duration": fsm.idleHoldTime, + }).Debug("IdleHoldTimer expired") + fsm.idleHoldTime = 0 + return bgp.BGP_FSM_ACTIVE + } + } } func (h *FSMHandler) active() bgp.FSMState { |