connection_manager.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. package nebula
  2. import (
  3. "bytes"
  4. "context"
  5. "encoding/binary"
  6. "fmt"
  7. "log/slog"
  8. "net/netip"
  9. "sync"
  10. "sync/atomic"
  11. "time"
  12. "github.com/rcrowley/go-metrics"
  13. "github.com/slackhq/nebula/cert"
  14. "github.com/slackhq/nebula/config"
  15. "github.com/slackhq/nebula/header"
  16. )
  17. type trafficDecision int
  18. const (
  19. doNothing trafficDecision = 0
  20. deleteTunnel trafficDecision = 1 // delete the hostinfo on our side, do not notify the remote
  21. closeTunnel trafficDecision = 2 // delete the hostinfo and notify the remote
  22. swapPrimary trafficDecision = 3
  23. migrateRelays trafficDecision = 4
  24. tryRehandshake trafficDecision = 5
  25. sendTestPacket trafficDecision = 6
  26. )
  27. type connectionManager struct {
  28. // relayUsed holds which relay localIndexs are in use
  29. relayUsed map[uint32]struct{}
  30. relayUsedLock *sync.RWMutex
  31. hostMap *HostMap
  32. trafficTimer *LockingTimerWheel[uint32]
  33. intf *Interface
  34. punchy *Punchy
  35. // Configuration settings
  36. checkInterval time.Duration
  37. pendingDeletionInterval time.Duration
  38. inactivityTimeout atomic.Int64
  39. dropInactive atomic.Bool
  40. metricsTxPunchy metrics.Counter
  41. l *slog.Logger
  42. }
  43. func newConnectionManagerFromConfig(l *slog.Logger, c *config.C, hm *HostMap, p *Punchy) *connectionManager {
  44. cm := &connectionManager{
  45. hostMap: hm,
  46. l: l,
  47. punchy: p,
  48. relayUsed: make(map[uint32]struct{}),
  49. relayUsedLock: &sync.RWMutex{},
  50. metricsTxPunchy: metrics.GetOrRegisterCounter("messages.tx.punchy", nil),
  51. }
  52. cm.reload(c, true)
  53. c.RegisterReloadCallback(func(c *config.C) {
  54. cm.reload(c, false)
  55. })
  56. return cm
  57. }
  58. func (cm *connectionManager) reload(c *config.C, initial bool) {
  59. if initial {
  60. cm.checkInterval = time.Duration(c.GetInt("timers.connection_alive_interval", 5)) * time.Second
  61. cm.pendingDeletionInterval = time.Duration(c.GetInt("timers.pending_deletion_interval", 10)) * time.Second
  62. // We want at least a minimum resolution of 500ms per tick so that we can hit these intervals
  63. // pretty close to their configured duration.
  64. // The inactivity duration is checked each time a hostinfo ticks through so we don't need the wheel to contain it.
  65. minDuration := min(time.Millisecond*500, cm.checkInterval, cm.pendingDeletionInterval)
  66. maxDuration := max(cm.checkInterval, cm.pendingDeletionInterval)
  67. cm.trafficTimer = NewLockingTimerWheel[uint32](minDuration, maxDuration)
  68. }
  69. if initial || c.HasChanged("tunnels.inactivity_timeout") {
  70. old := cm.getInactivityTimeout()
  71. cm.inactivityTimeout.Store((int64)(c.GetDuration("tunnels.inactivity_timeout", 10*time.Minute)))
  72. if !initial {
  73. cm.l.Info("Inactivity timeout has changed",
  74. "oldDuration", old,
  75. "newDuration", cm.getInactivityTimeout(),
  76. )
  77. }
  78. }
  79. if initial || c.HasChanged("tunnels.drop_inactive") {
  80. old := cm.dropInactive.Load()
  81. cm.dropInactive.Store(c.GetBool("tunnels.drop_inactive", false))
  82. if !initial {
  83. cm.l.Info("Drop inactive setting has changed",
  84. "oldBool", old,
  85. "newBool", cm.dropInactive.Load(),
  86. )
  87. }
  88. }
  89. }
  90. func (cm *connectionManager) getInactivityTimeout() time.Duration {
  91. return (time.Duration)(cm.inactivityTimeout.Load())
  92. }
  93. func (cm *connectionManager) In(h *HostInfo) {
  94. h.in.Store(true)
  95. }
  96. func (cm *connectionManager) Out(h *HostInfo) {
  97. h.out.Store(true)
  98. }
  99. func (cm *connectionManager) RelayUsed(localIndex uint32) {
  100. cm.relayUsedLock.RLock()
  101. // If this already exists, return
  102. if _, ok := cm.relayUsed[localIndex]; ok {
  103. cm.relayUsedLock.RUnlock()
  104. return
  105. }
  106. cm.relayUsedLock.RUnlock()
  107. cm.relayUsedLock.Lock()
  108. cm.relayUsed[localIndex] = struct{}{}
  109. cm.relayUsedLock.Unlock()
  110. }
  111. // getAndResetTrafficCheck returns if there was any inbound or outbound traffic within the last tick and
  112. // resets the state for this local index
  113. func (cm *connectionManager) getAndResetTrafficCheck(h *HostInfo, now time.Time) (bool, bool) {
  114. in := h.in.Swap(false)
  115. out := h.out.Swap(false)
  116. if in || out {
  117. h.lastUsed = now
  118. }
  119. return in, out
  120. }
  121. // AddTrafficWatch must be called for every new HostInfo.
  122. // We will continue to monitor the HostInfo until the tunnel is dropped.
  123. func (cm *connectionManager) AddTrafficWatch(h *HostInfo) {
  124. if h.out.Swap(true) == false {
  125. cm.trafficTimer.Add(h.localIndexId, cm.checkInterval)
  126. cm.intf.pmtudManager.OnTunnelUp(h)
  127. }
  128. }
  129. func (cm *connectionManager) Start(ctx context.Context) {
  130. clockSource := time.NewTicker(cm.trafficTimer.t.tickDuration)
  131. defer clockSource.Stop()
  132. p := []byte("")
  133. nb := make([]byte, 12, 12)
  134. out := make([]byte, mtu)
  135. for {
  136. select {
  137. case <-ctx.Done():
  138. return
  139. case now := <-clockSource.C:
  140. cm.trafficTimer.Advance(now)
  141. for {
  142. localIndex, has := cm.trafficTimer.Purge()
  143. if !has {
  144. break
  145. }
  146. cm.doTrafficCheck(localIndex, p, nb, out, now)
  147. }
  148. }
  149. }
  150. }
  151. func (cm *connectionManager) doTrafficCheck(localIndex uint32, p, nb, out []byte, now time.Time) {
  152. decision, hostinfo, primary := cm.makeTrafficDecision(localIndex, now)
  153. switch decision {
  154. case deleteTunnel:
  155. cm.intf.pmtudManager.OnTunnelDown(hostinfo)
  156. if cm.hostMap.DeleteHostInfo(hostinfo) {
  157. // Only clearing the lighthouse cache if this is the last hostinfo for this vpn ip in the hostmap
  158. cm.intf.lightHouse.DeleteVpnAddrs(hostinfo.vpnAddrs)
  159. }
  160. case closeTunnel:
  161. cm.intf.sendCloseTunnel(hostinfo)
  162. cm.intf.closeTunnel(hostinfo)
  163. case swapPrimary:
  164. cm.swapPrimary(hostinfo, primary)
  165. case migrateRelays:
  166. cm.migrateRelayUsed(hostinfo, primary)
  167. case tryRehandshake:
  168. cm.tryRehandshake(hostinfo)
  169. case sendTestPacket:
  170. // Defer to pmtud if it has a confirmed PMTU > floor for this peer:
  171. // the probe at the confirmed size verifies both liveness AND that
  172. // the discovered PMTU still fits, so we don't burn a separate test
  173. // packet on top of it. If pmtud declines (disabled, peer unsupported,
  174. // or no confirmed size yet) we fall back to the regular test.
  175. if !cm.intf.pmtudManager.MaybeProbeAsTest(hostinfo) {
  176. cm.intf.SendMessageToHostInfo(header.Test, header.TestRequest, hostinfo, p, nb, out)
  177. }
  178. }
  179. cm.resetRelayTrafficCheck(hostinfo)
  180. }
  181. func (cm *connectionManager) resetRelayTrafficCheck(hostinfo *HostInfo) {
  182. if hostinfo != nil {
  183. cm.relayUsedLock.Lock()
  184. defer cm.relayUsedLock.Unlock()
  185. // No need to migrate any relays, delete usage info now.
  186. for _, idx := range hostinfo.relayState.CopyRelayForIdxs() {
  187. delete(cm.relayUsed, idx)
  188. }
  189. }
  190. }
  191. func (cm *connectionManager) migrateRelayUsed(oldhostinfo, newhostinfo *HostInfo) {
  192. relayFor := oldhostinfo.relayState.CopyAllRelayFor()
  193. for _, r := range relayFor {
  194. existing, ok := newhostinfo.relayState.QueryRelayForByIp(r.PeerAddr)
  195. var index uint32
  196. var relayFrom netip.Addr
  197. var relayTo netip.Addr
  198. switch {
  199. case ok:
  200. switch existing.State {
  201. case Established, PeerRequested, Disestablished:
  202. // This relay already exists in newhostinfo, then do nothing.
  203. continue
  204. case Requested:
  205. // The relay exists in a Requested state; re-send the request
  206. index = existing.LocalIndex
  207. switch r.Type {
  208. case TerminalType:
  209. relayFrom = cm.intf.myVpnAddrs[0]
  210. relayTo = existing.PeerAddr
  211. case ForwardingType:
  212. relayFrom = existing.PeerAddr
  213. relayTo = newhostinfo.vpnAddrs[0]
  214. default:
  215. // should never happen
  216. panic(fmt.Sprintf("Migrating unknown relay type: %v", r.Type))
  217. }
  218. }
  219. case !ok:
  220. cm.relayUsedLock.RLock()
  221. if _, relayUsed := cm.relayUsed[r.LocalIndex]; !relayUsed {
  222. // The relay hasn't been used; don't migrate it.
  223. cm.relayUsedLock.RUnlock()
  224. continue
  225. }
  226. cm.relayUsedLock.RUnlock()
  227. // The relay doesn't exist at all; create some relay state and send the request.
  228. var err error
  229. index, err = AddRelay(cm.l, newhostinfo, cm.hostMap, r.PeerAddr, nil, r.Type, Requested)
  230. if err != nil {
  231. cm.l.Error("failed to migrate relay to new hostinfo", "error", err)
  232. continue
  233. }
  234. switch r.Type {
  235. case TerminalType:
  236. relayFrom = cm.intf.myVpnAddrs[0]
  237. relayTo = r.PeerAddr
  238. case ForwardingType:
  239. relayFrom = r.PeerAddr
  240. relayTo = newhostinfo.vpnAddrs[0]
  241. default:
  242. // should never happen
  243. panic(fmt.Sprintf("Migrating unknown relay type: %v", r.Type))
  244. }
  245. }
  246. // Send a CreateRelayRequest to the peer.
  247. req := NebulaControl{
  248. Type: NebulaControl_CreateRelayRequest,
  249. InitiatorRelayIndex: index,
  250. }
  251. switch newhostinfo.GetCert().Certificate.Version() {
  252. case cert.Version1:
  253. if !relayFrom.Is4() {
  254. cm.l.Error("can not migrate v1 relay with a v6 network because the relay is not running a current nebula version")
  255. continue
  256. }
  257. if !relayTo.Is4() {
  258. cm.l.Error("can not migrate v1 relay with a v6 remote network because the relay is not running a current nebula version")
  259. continue
  260. }
  261. b := relayFrom.As4()
  262. req.OldRelayFromAddr = binary.BigEndian.Uint32(b[:])
  263. b = relayTo.As4()
  264. req.OldRelayToAddr = binary.BigEndian.Uint32(b[:])
  265. case cert.Version2:
  266. req.RelayFromAddr = netAddrToProtoAddr(relayFrom)
  267. req.RelayToAddr = netAddrToProtoAddr(relayTo)
  268. default:
  269. newhostinfo.logger(cm.l).Error("Unknown certificate version found while attempting to migrate relay")
  270. continue
  271. }
  272. msg, err := req.Marshal()
  273. if err != nil {
  274. cm.l.Error("failed to marshal Control message to migrate relay", "error", err)
  275. } else {
  276. cm.intf.SendMessageToHostInfo(header.Control, 0, newhostinfo, msg, make([]byte, 12), make([]byte, mtu))
  277. cm.l.Info("send CreateRelayRequest",
  278. "relayFrom", req.RelayFromAddr,
  279. "relayTo", req.RelayToAddr,
  280. "initiatorRelayIndex", req.InitiatorRelayIndex,
  281. "responderRelayIndex", req.ResponderRelayIndex,
  282. "vpnAddrs", newhostinfo.vpnAddrs,
  283. )
  284. }
  285. }
  286. }
  287. func (cm *connectionManager) makeTrafficDecision(localIndex uint32, now time.Time) (trafficDecision, *HostInfo, *HostInfo) {
  288. // Read lock the main hostmap to order decisions based on tunnels being the primary tunnel
  289. cm.hostMap.RLock()
  290. defer cm.hostMap.RUnlock()
  291. hostinfo := cm.hostMap.Indexes[localIndex]
  292. if hostinfo == nil {
  293. cm.l.Debug("Not found in hostmap", "localIndex", localIndex)
  294. return doNothing, nil, nil
  295. }
  296. if cm.isInvalidCertificate(now, hostinfo) {
  297. return closeTunnel, hostinfo, nil
  298. }
  299. primary := cm.hostMap.Hosts[hostinfo.vpnAddrs[0]]
  300. mainHostInfo := true
  301. if primary != nil && primary != hostinfo {
  302. mainHostInfo = false
  303. }
  304. // Check for traffic on this hostinfo
  305. inTraffic, outTraffic := cm.getAndResetTrafficCheck(hostinfo, now)
  306. // A hostinfo is determined alive if there is incoming traffic
  307. if inTraffic {
  308. decision := doNothing
  309. if cm.l.Enabled(context.Background(), slog.LevelDebug) {
  310. hostinfo.logger(cm.l).Debug("Tunnel status",
  311. "tunnelCheck", m{"state": "alive", "method": "passive"},
  312. )
  313. }
  314. hostinfo.pendingDeletion.Store(false)
  315. if mainHostInfo {
  316. decision = tryRehandshake
  317. } else {
  318. if cm.shouldSwapPrimary(hostinfo) {
  319. decision = swapPrimary
  320. } else {
  321. // migrate the relays to the primary, if in use.
  322. decision = migrateRelays
  323. }
  324. }
  325. cm.trafficTimer.Add(hostinfo.localIndexId, cm.checkInterval)
  326. if !outTraffic {
  327. // Send a punch packet to keep the NAT state alive
  328. cm.sendPunch(hostinfo)
  329. }
  330. return decision, hostinfo, primary
  331. }
  332. if hostinfo.pendingDeletion.Load() {
  333. // We have already sent a test packet and nothing was returned, this hostinfo is dead
  334. hostinfo.logger(cm.l).Info("Tunnel status",
  335. "tunnelCheck", m{"state": "dead", "method": "active"},
  336. )
  337. return deleteTunnel, hostinfo, nil
  338. }
  339. decision := doNothing
  340. if hostinfo != nil && hostinfo.ConnectionState != nil && mainHostInfo {
  341. if !outTraffic {
  342. inactiveFor, isInactive := cm.isInactive(hostinfo, now)
  343. if isInactive {
  344. // Tunnel is inactive, tear it down
  345. hostinfo.logger(cm.l).Info("Dropping tunnel due to inactivity",
  346. "inactiveDuration", inactiveFor,
  347. "primary", mainHostInfo,
  348. )
  349. return closeTunnel, hostinfo, primary
  350. }
  351. // If we aren't sending or receiving traffic then its an unused tunnel and we don't to test the tunnel.
  352. // Just maintain NAT state if configured to do so.
  353. cm.sendPunch(hostinfo)
  354. cm.trafficTimer.Add(hostinfo.localIndexId, cm.checkInterval)
  355. return doNothing, nil, nil
  356. }
  357. if cm.punchy.GetTargetEverything() {
  358. // This is similar to the old punchy behavior with a slight optimization.
  359. // We aren't receiving traffic but we are sending it, punch on all known
  360. // ips in case we need to re-prime NAT state
  361. cm.sendPunch(hostinfo)
  362. }
  363. if cm.l.Enabled(context.Background(), slog.LevelDebug) {
  364. hostinfo.logger(cm.l).Debug("Tunnel status",
  365. "tunnelCheck", m{"state": "testing", "method": "active"},
  366. )
  367. }
  368. // Send a test packet to trigger an authenticated tunnel test, this should suss out any lingering tunnel issues
  369. decision = sendTestPacket
  370. } else {
  371. if cm.l.Enabled(context.Background(), slog.LevelDebug) {
  372. hostinfo.logger(cm.l).Debug("Hostinfo sadness")
  373. }
  374. }
  375. hostinfo.pendingDeletion.Store(true)
  376. cm.trafficTimer.Add(hostinfo.localIndexId, cm.pendingDeletionInterval)
  377. return decision, hostinfo, nil
  378. }
  379. func (cm *connectionManager) isInactive(hostinfo *HostInfo, now time.Time) (time.Duration, bool) {
  380. if cm.dropInactive.Load() == false {
  381. // We aren't configured to drop inactive tunnels
  382. return 0, false
  383. }
  384. inactiveDuration := now.Sub(hostinfo.lastUsed)
  385. if inactiveDuration < cm.getInactivityTimeout() {
  386. // It's not considered inactive
  387. return inactiveDuration, false
  388. }
  389. // The tunnel is inactive
  390. return inactiveDuration, true
  391. }
  392. func (cm *connectionManager) shouldSwapPrimary(current *HostInfo) bool {
  393. // The primary tunnel is the most recent handshake to complete locally and should work entirely fine.
  394. // If we are here then we have multiple tunnels for a host pair and neither side believes the same tunnel is primary.
  395. // Let's sort this out.
  396. // Only one side should swap because if both swap then we may never resolve to a single tunnel.
  397. // vpn addr is static across all tunnels for this host pair so lets
  398. // use that to determine if we should consider swapping.
  399. if current.vpnAddrs[0].Compare(cm.intf.myVpnAddrs[0]) < 0 {
  400. // Their primary vpn addr is less than mine. Do not swap.
  401. return false
  402. }
  403. crt := cm.intf.pki.getCertState().getCertificate(current.ConnectionState.myCert.Version())
  404. if crt == nil {
  405. //my cert was reloaded away. We should definitely swap from this tunnel
  406. return true
  407. }
  408. // If this tunnel is using the latest certificate then we should swap it to primary for a bit and see if things
  409. // settle down.
  410. return bytes.Equal(current.ConnectionState.myCert.Signature(), crt.Signature())
  411. }
  412. func (cm *connectionManager) swapPrimary(current, primary *HostInfo) {
  413. cm.hostMap.Lock()
  414. // Make sure the primary is still the same after the write lock. This avoids a race with a rehandshake.
  415. if cm.hostMap.Hosts[current.vpnAddrs[0]] == primary {
  416. cm.hostMap.unlockedMakePrimary(current)
  417. }
  418. cm.hostMap.Unlock()
  419. }
  420. // isInvalidCertificate decides if we should destroy a tunnel.
  421. // returns true if pki.disconnect_invalid is true and the certificate is no longer valid.
  422. // Blocklisted certificates will skip the pki.disconnect_invalid check and return true.
  423. func (cm *connectionManager) isInvalidCertificate(now time.Time, hostinfo *HostInfo) bool {
  424. remoteCert := hostinfo.GetCert()
  425. if remoteCert == nil {
  426. return false //don't tear down tunnels for handshakes in progress
  427. }
  428. caPool := cm.intf.pki.GetCAPool()
  429. err := caPool.VerifyCachedCertificate(now, remoteCert)
  430. if err == nil {
  431. return false //cert is still valid! yay!
  432. } else if err == cert.ErrBlockListed { //avoiding errors.Is for speed
  433. // Block listed certificates should always be disconnected
  434. hostinfo.logger(cm.l).Info("Remote certificate is blocked, tearing down the tunnel",
  435. "error", err,
  436. "fingerprint", remoteCert.Fingerprint,
  437. )
  438. return true
  439. } else if cm.intf.disconnectInvalid.Load() {
  440. hostinfo.logger(cm.l).Info("Remote certificate is no longer valid, tearing down the tunnel",
  441. "error", err,
  442. "fingerprint", remoteCert.Fingerprint,
  443. )
  444. return true
  445. } else {
  446. //if we reach here, the cert is no longer valid, but we're configured to keep tunnels from now-invalid certs open
  447. return false
  448. }
  449. }
  450. func (cm *connectionManager) sendPunch(hostinfo *HostInfo) {
  451. if !cm.punchy.GetPunch() {
  452. // Punching is disabled
  453. return
  454. }
  455. if cm.intf.lightHouse.IsAnyLighthouseAddr(hostinfo.vpnAddrs) {
  456. // Do not punch to lighthouses, we assume our lighthouse update interval is good enough.
  457. // In the event the update interval is not sufficient to maintain NAT state then a publicly available lighthouse
  458. // would lose the ability to notify us and punchy.respond would become unreliable.
  459. return
  460. }
  461. if cm.punchy.GetTargetEverything() {
  462. hostinfo.remotes.ForEach(cm.hostMap.GetPreferredRanges(), func(addr netip.AddrPort, preferred bool) {
  463. cm.metricsTxPunchy.Inc(1)
  464. cm.intf.outside.WriteTo([]byte{1}, addr)
  465. })
  466. } else if hostinfo.remote.IsValid() {
  467. cm.metricsTxPunchy.Inc(1)
  468. cm.intf.outside.WriteTo([]byte{1}, hostinfo.remote)
  469. }
  470. }
  471. func (cm *connectionManager) tryRehandshake(hostinfo *HostInfo) {
  472. cs := cm.intf.pki.getCertState()
  473. curCrt := hostinfo.ConnectionState.myCert
  474. curCrtVersion := curCrt.Version()
  475. myCrt := cs.getCertificate(curCrtVersion)
  476. if myCrt == nil {
  477. cm.l.Info("Re-handshaking with remote",
  478. "vpnAddrs", hostinfo.vpnAddrs,
  479. "version", curCrtVersion,
  480. "reason", "local certificate removed",
  481. )
  482. cm.intf.handshakeManager.StartHandshake(hostinfo.vpnAddrs[0], nil)
  483. return
  484. }
  485. peerCrt := hostinfo.ConnectionState.peerCert
  486. if peerCrt != nil && curCrtVersion < peerCrt.Certificate.Version() {
  487. // if our certificate version is less than theirs, and we have a matching version available, rehandshake?
  488. if cs.getCertificate(peerCrt.Certificate.Version()) != nil {
  489. cm.l.Info("Re-handshaking with remote",
  490. "vpnAddrs", hostinfo.vpnAddrs,
  491. "version", curCrtVersion,
  492. "peerVersion", peerCrt.Certificate.Version(),
  493. "reason", "local certificate version lower than peer, attempting to correct",
  494. )
  495. cm.intf.handshakeManager.StartHandshake(hostinfo.vpnAddrs[0], func(hh *HandshakeHostInfo) {
  496. hh.initiatingVersionOverride = peerCrt.Certificate.Version()
  497. })
  498. return
  499. }
  500. }
  501. if !bytes.Equal(curCrt.Signature(), myCrt.Signature()) {
  502. cm.l.Info("Re-handshaking with remote",
  503. "vpnAddrs", hostinfo.vpnAddrs,
  504. "reason", "local certificate is not current",
  505. )
  506. cm.intf.handshakeManager.StartHandshake(hostinfo.vpnAddrs[0], nil)
  507. return
  508. }
  509. if curCrtVersion < cs.initiatingVersion {
  510. cm.l.Info("Re-handshaking with remote",
  511. "vpnAddrs", hostinfo.vpnAddrs,
  512. "reason", "current cert version < pki.initiatingVersion",
  513. )
  514. cm.intf.handshakeManager.StartHandshake(hostinfo.vpnAddrs[0], nil)
  515. return
  516. }
  517. }