Skip to content

Commit

Permalink
fastdp: Do not reset heartbeat timer for non-confirmed connections
Browse files Browse the repository at this point in the history
It is possible to receive FastDatapathCryptoInitSARemote control plane
message before Confirm'ing a connection. In such case, resetting
heartbeatTimer leads to null pointer dereference, as the timer is
initialized during Confirm'ation.

In this situation, skipping the reset is non-harmful, because
Confirm'ing will reset it.

NB: the reset to 0 should only happen after establishing the connection
on both ends.
  • Loading branch information
brb committed Mar 2, 2017
1 parent 125f3cf commit 7c84e24
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions router/fastdp.go
Expand Up @@ -577,8 +577,8 @@ type fastDatapathForwarder struct {
confirmed bool
remoteAddr *net.UDPAddr
heartbeatInterval time.Duration
heartbeatTimer *time.Timer
heartbeatTimeout *time.Timer
heartbeatTimer *time.Timer // for sending
heartbeatTimeout *time.Timer // for receiving
ackedHeartbeat bool
stopChan chan struct{}
stopped bool
Expand Down Expand Up @@ -856,7 +856,9 @@ func (fwd *fastDatapathForwarder) handleCryptoInitSARemote(msg []byte) {
return
}

if !fwd.isOutboundIPSecEstablished {
// FastDatapathCryptoInitSARemote can be received before Confirm'ing
// connection, thus before InitSALocal.
if fwd.confirmed && !fwd.isOutboundIPSecEstablished {
fwd.isOutboundIPSecEstablished = true
fwd.heartbeatTimer.Reset(0)
}
Expand Down

0 comments on commit 7c84e24

Please sign in to comment.