diff options
author | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-01-21 20:14:49 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-26 20:41:08 +0900 |
commit | dafa0a31d73f49b6cd68e658f000da904565f36c (patch) | |
tree | 75bb21a4920f78ec7f5a4fdc70a79d13ee30f1ad /server/peer.go | |
parent | 3491d5214352586708444bcf41eca16f7ff1d3e6 (diff) |
fsm: check hold timer expiration and add test case for holdtimer expiration at Established state
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r-- | server/peer.go | 17 |
1 files changed, 15 insertions, 2 deletions
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)) |