diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-29 11:25:29 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-29 11:38:27 +0900 |
commit | b05da5ddc9c9f78de5883c9dc8f94fa531688085 (patch) | |
tree | 194c77cd46aeaaa54e754f6f989f761194ce4e9a /server | |
parent | 0ce9409f1768f5b4a0bc4b3e3e5593ca773056fa (diff) |
server: add negotiated holdtime/keepalive-interval in api struct
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
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{ |