diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/fsm.go | 11 | ||||
-rw-r--r-- | server/peer.go | 22 |
2 files changed, 14 insertions, 19 deletions
diff --git a/server/fsm.go b/server/fsm.go index 872f8b8c..98c2518c 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -708,6 +708,12 @@ func (h *FSMHandler) opensent() (bgp.FSMState, FsmStateReason) { fsm.pConf.Timers.State.NegotiatedHoldTime = holdTime } + keepalive := fsm.pConf.Timers.Config.KeepaliveInterval + if n := fsm.pConf.Timers.State.NegotiatedHoldTime; n < myHoldTime { + keepalive = n / 3 + } + fsm.pConf.Timers.State.KeepaliveInterval = keepalive + msg := bgp.NewBGPKeepAliveMessage() b, _ := msg.Serialize() fsm.conn.Write(b) @@ -761,10 +767,7 @@ func keepaliveTicker(fsm *FSM) *time.Ticker { if negotiatedTime == 0 { return &time.Ticker{} } - sec := time.Second * time.Duration(fsm.pConf.Timers.Config.KeepaliveInterval) - if negotiatedTime < fsm.pConf.Timers.Config.HoldTime { - sec = time.Second * time.Duration(negotiatedTime) / 3 - } + sec := time.Second * time.Duration(fsm.pConf.Timers.State.KeepaliveInterval) if sec == 0 { sec = 1 } diff --git a/server/peer.go b/server/peer.go index 8c8f96d4..33621155 100644 --- a/server/peer.go +++ b/server/peer.go @@ -254,25 +254,17 @@ func (peer *Peer) ToApiStruct() *api.Peer { downtime = int64(time.Now().Sub(time.Unix(timer.State.Downtime, 0)).Seconds()) } - keepalive := uint32(0) - if t := timer.State.NegotiatedHoldTime; t != 0 { - if t < timer.Config.HoldTime { - keepalive = uint32(t / 3) - } else { - keepalive = uint32(timer.Config.KeepaliveInterval) - } - } - timerconf := &api.TimersConfig{ - ConnectRetry: uint64(timer.Config.ConnectRetry), - HoldTime: uint64(timer.Config.HoldTime), - KeepaliveInterval: uint64(keepalive), - MinimumAdvertisementInterval: uint64(timer.Config.MinimumAdvertisementInterval), + ConnectRetry: uint64(timer.Config.ConnectRetry), + HoldTime: uint64(timer.Config.HoldTime), + KeepaliveInterval: uint64(timer.Config.KeepaliveInterval), } timerstate := &api.TimersState{ - Uptime: uint64(uptime), - Downtime: uint64(downtime), + KeepaliveInterval: uint64(timer.State.KeepaliveInterval), + NegotiatedHoldTime: uint64(timer.State.NegotiatedHoldTime), + Uptime: uint64(uptime), + Downtime: uint64(downtime), } apitimer := &api.Timers{ |