From dafa0a31d73f49b6cd68e658f000da904565f36c Mon Sep 17 00:00:00 2001 From: Hiroshi Yokoi Date: Wed, 21 Jan 2015 20:14:49 +0900 Subject: fsm: check hold timer expiration and add test case for holdtimer expiration at Established state Signed-off-by: FUJITA Tomonori --- server/peer.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'server/peer.go') diff --git a/server/peer.go b/server/peer.go index 3e264fbb..bc8bb10c 100644 --- a/server/peer.go +++ b/server/peer.go @@ -49,7 +49,7 @@ type Peer struct { t tomb.Tomb globalConfig config.GlobalType peerConfig config.NeighborType - acceptedConnCh chan *net.TCPConn + acceptedConnCh chan net.Conn serverMsgCh chan *serverMsg peerMsgCh chan *peerMsg fsm *FSM @@ -69,7 +69,7 @@ func NewPeer(g config.GlobalType, peer config.NeighborType, serverMsgCh chan *se p := &Peer{ globalConfig: g, peerConfig: peer, - acceptedConnCh: make(chan *net.TCPConn), + acceptedConnCh: make(chan net.Conn), serverMsgCh: serverMsgCh, peerMsgCh: peerMsgCh, capMap: make(map[bgp.BGPCapabilityCode]bgp.ParameterCapabilityInterface), @@ -119,6 +119,19 @@ func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) { } } + // calculate HoldTime + // RFC 4271 P.13 + // a BGP speaker MUST calculate the value of the Hold Timer + // by using the smaller of its configured Hold Time and the Hold Time + // received in the OPEN message. + holdTime := float64(body.HoldTime) + myHoldTime := peer.fsm.peerConfig.Timers.HoldTime + if holdTime > myHoldTime { + peer.fsm.negotiatedHoldTime = holdTime + } else { + peer.fsm.negotiatedHoldTime = myHoldTime + } + case bgp.BGP_MSG_ROUTE_REFRESH: pathList := peer.adjRib.GetOutPathList(peer.rf) peer.sendMessages(table.CreateUpdateMsgFromPaths(pathList)) -- cgit v1.2.3