outside.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. package nebula
  2. import (
  3. "encoding/binary"
  4. "errors"
  5. "net/netip"
  6. "time"
  7. "github.com/google/gopacket/layers"
  8. "golang.org/x/net/ipv6"
  9. "github.com/sirupsen/logrus"
  10. "github.com/slackhq/nebula/firewall"
  11. "github.com/slackhq/nebula/header"
  12. "golang.org/x/net/ipv4"
  13. )
  14. const (
  15. minFwPacketLen = 4
  16. )
  17. func (f *Interface) readOutsidePackets(ip netip.AddrPort, via *ViaSender, out []byte, packet []byte, h *header.H, fwPacket *firewall.Packet, lhf *LightHouseHandler, nb []byte, q int, localCache firewall.ConntrackCache) {
  18. err := h.Parse(packet)
  19. if err != nil {
  20. // Hole punch packets are 0 or 1 byte big, so lets ignore printing those errors
  21. if len(packet) > 1 {
  22. f.l.WithField("packet", packet).Infof("Error while parsing inbound packet from %s: %s", ip, err)
  23. }
  24. return
  25. }
  26. //l.Error("in packet ", header, packet[HeaderLen:])
  27. if ip.IsValid() {
  28. _, found := f.myVpnNetworksTable.Lookup(ip.Addr())
  29. if found {
  30. if f.l.Level >= logrus.DebugLevel {
  31. f.l.WithField("udpAddr", ip).Debug("Refusing to process double encrypted packet")
  32. }
  33. return
  34. }
  35. }
  36. var hostinfo *HostInfo
  37. // verify if we've seen this index before, otherwise respond to the handshake initiation
  38. if h.Type == header.Message && h.Subtype == header.MessageRelay {
  39. hostinfo = f.hostMap.QueryRelayIndex(h.RemoteIndex)
  40. } else {
  41. hostinfo = f.hostMap.QueryIndex(h.RemoteIndex)
  42. }
  43. var ci *ConnectionState
  44. if hostinfo != nil {
  45. ci = hostinfo.ConnectionState
  46. }
  47. switch h.Type {
  48. case header.Message:
  49. // TODO handleEncrypted sends directly to addr on error. Handle this in the tunneling case.
  50. if !f.handleEncrypted(ci, ip, h) {
  51. return
  52. }
  53. switch h.Subtype {
  54. case header.MessageNone:
  55. if !f.decryptToTun(hostinfo, h.MessageCounter, out, packet, fwPacket, nb, q, localCache) {
  56. return
  57. }
  58. case header.MessageRelay:
  59. // The entire body is sent as AD, not encrypted.
  60. // The packet consists of a 16-byte parsed Nebula header, Associated Data-protected payload, and a trailing 16-byte AEAD signature value.
  61. // The packet is guaranteed to be at least 16 bytes at this point, b/c it got past the h.Parse() call above. If it's
  62. // otherwise malformed (meaning, there is no trailing 16 byte AEAD value), then this will result in at worst a 0-length slice
  63. // which will gracefully fail in the DecryptDanger call.
  64. signedPayload := packet[:len(packet)-hostinfo.ConnectionState.dKey.Overhead()]
  65. signatureValue := packet[len(packet)-hostinfo.ConnectionState.dKey.Overhead():]
  66. out, err = hostinfo.ConnectionState.dKey.DecryptDanger(out, signedPayload, signatureValue, h.MessageCounter, nb)
  67. if err != nil {
  68. return
  69. }
  70. // Successfully validated the thing. Get rid of the Relay header.
  71. signedPayload = signedPayload[header.Len:]
  72. // Pull the Roaming parts up here, and return in all call paths.
  73. f.handleHostRoaming(hostinfo, ip)
  74. // Track usage of both the HostInfo and the Relay for the received & authenticated packet
  75. f.connectionManager.In(hostinfo.localIndexId)
  76. f.connectionManager.RelayUsed(h.RemoteIndex)
  77. relay, ok := hostinfo.relayState.QueryRelayForByIdx(h.RemoteIndex)
  78. if !ok {
  79. // The only way this happens is if hostmap has an index to the correct HostInfo, but the HostInfo is missing
  80. // its internal mapping. This should never happen.
  81. hostinfo.logger(f.l).WithFields(logrus.Fields{"vpnAddrs": hostinfo.vpnAddrs, "remoteIndex": h.RemoteIndex}).Error("HostInfo missing remote relay index")
  82. return
  83. }
  84. switch relay.Type {
  85. case TerminalType:
  86. // If I am the target of this relay, process the unwrapped packet
  87. // From this recursive point, all these variables are 'burned'. We shouldn't rely on them again.
  88. f.readOutsidePackets(netip.AddrPort{}, &ViaSender{relayHI: hostinfo, remoteIdx: relay.RemoteIndex, relay: relay}, out[:0], signedPayload, h, fwPacket, lhf, nb, q, localCache)
  89. return
  90. case ForwardingType:
  91. // Find the target HostInfo relay object
  92. targetHI, targetRelay, err := f.hostMap.QueryVpnAddrsRelayFor(hostinfo.vpnAddrs, relay.PeerAddr)
  93. if err != nil {
  94. hostinfo.logger(f.l).WithField("relayTo", relay.PeerAddr).WithError(err).WithField("hostinfo.vpnAddrs", hostinfo.vpnAddrs).Info("Failed to find target host info by ip")
  95. return
  96. }
  97. // If that relay is Established, forward the payload through it
  98. if targetRelay.State == Established {
  99. switch targetRelay.Type {
  100. case ForwardingType:
  101. // Forward this packet through the relay tunnel
  102. // Find the target HostInfo
  103. f.SendVia(targetHI, targetRelay, signedPayload, nb, out, false)
  104. return
  105. case TerminalType:
  106. hostinfo.logger(f.l).Error("Unexpected Relay Type of Terminal")
  107. }
  108. } else {
  109. hostinfo.logger(f.l).WithFields(logrus.Fields{"relayTo": relay.PeerAddr, "relayFrom": hostinfo.vpnAddrs[0], "targetRelayState": targetRelay.State}).Info("Unexpected target relay state")
  110. return
  111. }
  112. }
  113. }
  114. case header.LightHouse:
  115. f.messageMetrics.Rx(h.Type, h.Subtype, 1)
  116. if !f.handleEncrypted(ci, ip, h) {
  117. return
  118. }
  119. d, err := f.decrypt(hostinfo, h.MessageCounter, out, packet, h, nb)
  120. if err != nil {
  121. hostinfo.logger(f.l).WithError(err).WithField("udpAddr", ip).
  122. WithField("packet", packet).
  123. Error("Failed to decrypt lighthouse packet")
  124. return
  125. }
  126. lhf.HandleRequest(ip, hostinfo.vpnAddrs, d, f)
  127. // Fallthrough to the bottom to record incoming traffic
  128. case header.Test:
  129. f.messageMetrics.Rx(h.Type, h.Subtype, 1)
  130. if !f.handleEncrypted(ci, ip, h) {
  131. return
  132. }
  133. d, err := f.decrypt(hostinfo, h.MessageCounter, out, packet, h, nb)
  134. if err != nil {
  135. hostinfo.logger(f.l).WithError(err).WithField("udpAddr", ip).
  136. WithField("packet", packet).
  137. Error("Failed to decrypt test packet")
  138. return
  139. }
  140. if h.Subtype == header.TestRequest {
  141. // This testRequest might be from TryPromoteBest, so we should roam
  142. // to the new IP address before responding
  143. f.handleHostRoaming(hostinfo, ip)
  144. f.send(header.Test, header.TestReply, ci, hostinfo, d, nb, out)
  145. }
  146. // Fallthrough to the bottom to record incoming traffic
  147. // Non encrypted messages below here, they should not fall through to avoid tracking incoming traffic since they
  148. // are unauthenticated
  149. case header.Handshake:
  150. f.messageMetrics.Rx(h.Type, h.Subtype, 1)
  151. f.handshakeManager.HandleIncoming(ip, via, packet, h)
  152. return
  153. case header.RecvError:
  154. f.messageMetrics.Rx(h.Type, h.Subtype, 1)
  155. f.handleRecvError(ip, h)
  156. return
  157. case header.CloseTunnel:
  158. f.messageMetrics.Rx(h.Type, h.Subtype, 1)
  159. if !f.handleEncrypted(ci, ip, h) {
  160. return
  161. }
  162. hostinfo.logger(f.l).WithField("udpAddr", ip).
  163. Info("Close tunnel received, tearing down.")
  164. f.closeTunnel(hostinfo)
  165. return
  166. case header.Control:
  167. if !f.handleEncrypted(ci, ip, h) {
  168. return
  169. }
  170. d, err := f.decrypt(hostinfo, h.MessageCounter, out, packet, h, nb)
  171. if err != nil {
  172. hostinfo.logger(f.l).WithError(err).WithField("udpAddr", ip).
  173. WithField("packet", packet).
  174. Error("Failed to decrypt Control packet")
  175. return
  176. }
  177. f.relayManager.HandleControlMsg(hostinfo, d, f)
  178. default:
  179. f.messageMetrics.Rx(h.Type, h.Subtype, 1)
  180. hostinfo.logger(f.l).Debugf("Unexpected packet received from %s", ip)
  181. return
  182. }
  183. f.handleHostRoaming(hostinfo, ip)
  184. f.connectionManager.In(hostinfo.localIndexId)
  185. }
  186. // closeTunnel closes a tunnel locally, it does not send a closeTunnel packet to the remote
  187. func (f *Interface) closeTunnel(hostInfo *HostInfo) {
  188. final := f.hostMap.DeleteHostInfo(hostInfo)
  189. if final {
  190. // We no longer have any tunnels with this vpn addr, clear learned lighthouse state to lower memory usage
  191. f.lightHouse.DeleteVpnAddrs(hostInfo.vpnAddrs)
  192. }
  193. }
  194. // sendCloseTunnel is a helper function to send a proper close tunnel packet to a remote
  195. func (f *Interface) sendCloseTunnel(h *HostInfo) {
  196. f.send(header.CloseTunnel, 0, h.ConnectionState, h, []byte{}, make([]byte, 12, 12), make([]byte, mtu))
  197. }
  198. func (f *Interface) handleHostRoaming(hostinfo *HostInfo, udpAddr netip.AddrPort) {
  199. if udpAddr.IsValid() && hostinfo.remote != udpAddr {
  200. if hostinfo.multiportRx {
  201. // If the remote is sending with multiport, we aren't roaming unless
  202. // the IP has changed
  203. if hostinfo.remote.Addr().Compare(udpAddr.Addr()) == 0 {
  204. return
  205. }
  206. // Keep the port from the original hostinfo, because the remote is transmitting from multiport ports
  207. udpAddr = netip.AddrPortFrom(udpAddr.Addr(), hostinfo.remote.Port())
  208. }
  209. if !f.lightHouse.GetRemoteAllowList().AllowAll(hostinfo.vpnAddrs, udpAddr.Addr()) {
  210. hostinfo.logger(f.l).WithField("newAddr", udpAddr).Debug("lighthouse.remote_allow_list denied roaming")
  211. return
  212. }
  213. if !hostinfo.lastRoam.IsZero() && udpAddr == hostinfo.lastRoamRemote && time.Since(hostinfo.lastRoam) < RoamingSuppressSeconds*time.Second {
  214. if f.l.Level >= logrus.DebugLevel {
  215. hostinfo.logger(f.l).WithField("udpAddr", hostinfo.remote).WithField("newAddr", udpAddr).
  216. Debugf("Suppressing roam back to previous remote for %d seconds", RoamingSuppressSeconds)
  217. }
  218. return
  219. }
  220. hostinfo.logger(f.l).WithField("udpAddr", hostinfo.remote).WithField("newAddr", udpAddr).
  221. Info("Host roamed to new udp ip/port.")
  222. hostinfo.lastRoam = time.Now()
  223. hostinfo.lastRoamRemote = hostinfo.remote
  224. hostinfo.SetRemote(udpAddr)
  225. }
  226. }
  227. func (f *Interface) handleEncrypted(ci *ConnectionState, addr netip.AddrPort, h *header.H) bool {
  228. // If connectionstate exists and the replay protector allows, process packet
  229. // Else, send recv errors for 300 seconds after a restart to allow fast reconnection.
  230. if ci == nil || !ci.window.Check(f.l, h.MessageCounter) {
  231. if addr.IsValid() {
  232. f.maybeSendRecvError(addr, h.RemoteIndex)
  233. return false
  234. } else {
  235. return false
  236. }
  237. }
  238. return true
  239. }
  240. var (
  241. ErrPacketTooShort = errors.New("packet is too short")
  242. ErrUnknownIPVersion = errors.New("packet is an unknown ip version")
  243. ErrIPv4InvalidHeaderLength = errors.New("invalid ipv4 header length")
  244. ErrIPv4PacketTooShort = errors.New("ipv4 packet is too short")
  245. ErrIPv6PacketTooShort = errors.New("ipv6 packet is too short")
  246. ErrIPv6CouldNotFindPayload = errors.New("could not find payload in ipv6 packet")
  247. )
  248. // newPacket validates and parses the interesting bits for the firewall out of the ip and sub protocol headers
  249. func newPacket(data []byte, incoming bool, fp *firewall.Packet) error {
  250. if len(data) < 1 {
  251. return ErrPacketTooShort
  252. }
  253. version := int((data[0] >> 4) & 0x0f)
  254. switch version {
  255. case ipv4.Version:
  256. return parseV4(data, incoming, fp)
  257. case ipv6.Version:
  258. return parseV6(data, incoming, fp)
  259. }
  260. return ErrUnknownIPVersion
  261. }
  262. func parseV6(data []byte, incoming bool, fp *firewall.Packet) error {
  263. dataLen := len(data)
  264. if dataLen < ipv6.HeaderLen {
  265. return ErrIPv6PacketTooShort
  266. }
  267. if incoming {
  268. fp.RemoteAddr, _ = netip.AddrFromSlice(data[8:24])
  269. fp.LocalAddr, _ = netip.AddrFromSlice(data[24:40])
  270. } else {
  271. fp.LocalAddr, _ = netip.AddrFromSlice(data[8:24])
  272. fp.RemoteAddr, _ = netip.AddrFromSlice(data[24:40])
  273. }
  274. protoAt := 6 // NextHeader is at 6 bytes into the ipv6 header
  275. offset := ipv6.HeaderLen // Start at the end of the ipv6 header
  276. next := 0
  277. for {
  278. if dataLen < offset {
  279. break
  280. }
  281. proto := layers.IPProtocol(data[protoAt])
  282. //fmt.Println(proto, protoAt)
  283. switch proto {
  284. case layers.IPProtocolICMPv6, layers.IPProtocolESP, layers.IPProtocolNoNextHeader:
  285. fp.Protocol = uint8(proto)
  286. fp.RemotePort = 0
  287. fp.LocalPort = 0
  288. fp.Fragment = false
  289. return nil
  290. case layers.IPProtocolTCP, layers.IPProtocolUDP:
  291. if dataLen < offset+4 {
  292. return ErrIPv6PacketTooShort
  293. }
  294. fp.Protocol = uint8(proto)
  295. if incoming {
  296. fp.RemotePort = binary.BigEndian.Uint16(data[offset : offset+2])
  297. fp.LocalPort = binary.BigEndian.Uint16(data[offset+2 : offset+4])
  298. } else {
  299. fp.LocalPort = binary.BigEndian.Uint16(data[offset : offset+2])
  300. fp.RemotePort = binary.BigEndian.Uint16(data[offset+2 : offset+4])
  301. }
  302. fp.Fragment = false
  303. return nil
  304. case layers.IPProtocolIPv6Fragment:
  305. // Fragment header is 8 bytes, need at least offset+4 to read the offset field
  306. if dataLen < offset+8 {
  307. return ErrIPv6PacketTooShort
  308. }
  309. // Check if this is the first fragment
  310. fragmentOffset := binary.BigEndian.Uint16(data[offset+2:offset+4]) &^ uint16(0x7) // Remove the reserved and M flag bits
  311. if fragmentOffset != 0 {
  312. // Non-first fragment, use what we have now and stop processing
  313. fp.Protocol = data[offset]
  314. fp.Fragment = true
  315. fp.RemotePort = 0
  316. fp.LocalPort = 0
  317. return nil
  318. }
  319. // The next loop should be the transport layer since we are the first fragment
  320. next = 8 // Fragment headers are always 8 bytes
  321. case layers.IPProtocolAH:
  322. // Auth headers, used by IPSec, have a different meaning for header length
  323. if dataLen < offset+1 {
  324. break
  325. }
  326. next = int(data[offset+1]+2) << 2
  327. default:
  328. // Normal ipv6 header length processing
  329. if dataLen < offset+1 {
  330. break
  331. }
  332. next = int(data[offset+1]+1) << 3
  333. }
  334. if next <= 0 {
  335. // Safety check, each ipv6 header has to be at least 8 bytes
  336. next = 8
  337. }
  338. protoAt = offset
  339. offset = offset + next
  340. }
  341. return ErrIPv6CouldNotFindPayload
  342. }
  343. func parseV4(data []byte, incoming bool, fp *firewall.Packet) error {
  344. // Do we at least have an ipv4 header worth of data?
  345. if len(data) < ipv4.HeaderLen {
  346. return ErrIPv4PacketTooShort
  347. }
  348. // Adjust our start position based on the advertised ip header length
  349. ihl := int(data[0]&0x0f) << 2
  350. // Well-formed ip header length?
  351. if ihl < ipv4.HeaderLen {
  352. return ErrIPv4InvalidHeaderLength
  353. }
  354. // Check if this is the second or further fragment of a fragmented packet.
  355. flagsfrags := binary.BigEndian.Uint16(data[6:8])
  356. fp.Fragment = (flagsfrags & 0x1FFF) != 0
  357. // Firewall handles protocol checks
  358. fp.Protocol = data[9]
  359. // Accounting for a variable header length, do we have enough data for our src/dst tuples?
  360. minLen := ihl
  361. if !fp.Fragment && fp.Protocol != firewall.ProtoICMP {
  362. minLen += minFwPacketLen
  363. }
  364. if len(data) < minLen {
  365. return ErrIPv4InvalidHeaderLength
  366. }
  367. // Firewall packets are locally oriented
  368. if incoming {
  369. fp.RemoteAddr, _ = netip.AddrFromSlice(data[12:16])
  370. fp.LocalAddr, _ = netip.AddrFromSlice(data[16:20])
  371. if fp.Fragment || fp.Protocol == firewall.ProtoICMP {
  372. fp.RemotePort = 0
  373. fp.LocalPort = 0
  374. } else {
  375. fp.RemotePort = binary.BigEndian.Uint16(data[ihl : ihl+2])
  376. fp.LocalPort = binary.BigEndian.Uint16(data[ihl+2 : ihl+4])
  377. }
  378. } else {
  379. fp.LocalAddr, _ = netip.AddrFromSlice(data[12:16])
  380. fp.RemoteAddr, _ = netip.AddrFromSlice(data[16:20])
  381. if fp.Fragment || fp.Protocol == firewall.ProtoICMP {
  382. fp.RemotePort = 0
  383. fp.LocalPort = 0
  384. } else {
  385. fp.LocalPort = binary.BigEndian.Uint16(data[ihl : ihl+2])
  386. fp.RemotePort = binary.BigEndian.Uint16(data[ihl+2 : ihl+4])
  387. }
  388. }
  389. return nil
  390. }
  391. func (f *Interface) decrypt(hostinfo *HostInfo, mc uint64, out []byte, packet []byte, h *header.H, nb []byte) ([]byte, error) {
  392. var err error
  393. out, err = hostinfo.ConnectionState.dKey.DecryptDanger(out, packet[:header.Len], packet[header.Len:], mc, nb)
  394. if err != nil {
  395. return nil, err
  396. }
  397. if !hostinfo.ConnectionState.window.Update(f.l, mc) {
  398. hostinfo.logger(f.l).WithField("header", h).
  399. Debugln("dropping out of window packet")
  400. return nil, errors.New("out of window packet")
  401. }
  402. return out, nil
  403. }
  404. func (f *Interface) decryptToTun(hostinfo *HostInfo, messageCounter uint64, out []byte, packet []byte, fwPacket *firewall.Packet, nb []byte, q int, localCache firewall.ConntrackCache) bool {
  405. var err error
  406. out, err = hostinfo.ConnectionState.dKey.DecryptDanger(out, packet[:header.Len], packet[header.Len:], messageCounter, nb)
  407. if err != nil {
  408. hostinfo.logger(f.l).WithError(err).Error("Failed to decrypt packet")
  409. return false
  410. }
  411. err = newPacket(out, true, fwPacket)
  412. if err != nil {
  413. hostinfo.logger(f.l).WithError(err).WithField("packet", out).
  414. Warnf("Error while validating inbound packet")
  415. return false
  416. }
  417. if !hostinfo.ConnectionState.window.Update(f.l, messageCounter) {
  418. hostinfo.logger(f.l).WithField("fwPacket", fwPacket).
  419. Debugln("dropping out of window packet")
  420. return false
  421. }
  422. dropReason := f.firewall.Drop(*fwPacket, true, hostinfo, f.pki.GetCAPool(), localCache)
  423. if dropReason != nil {
  424. // NOTE: We give `packet` as the `out` here since we already decrypted from it and we don't need it anymore
  425. // This gives us a buffer to build the reject packet in
  426. f.rejectOutside(out, hostinfo.ConnectionState, hostinfo, nb, packet, q)
  427. if f.l.Level >= logrus.DebugLevel {
  428. hostinfo.logger(f.l).WithField("fwPacket", fwPacket).
  429. WithField("reason", dropReason).
  430. Debugln("dropping inbound packet")
  431. }
  432. return false
  433. }
  434. f.connectionManager.In(hostinfo.localIndexId)
  435. _, err = f.readers[q].Write(out)
  436. if err != nil {
  437. f.l.WithError(err).Error("Failed to write to tun")
  438. }
  439. return true
  440. }
  441. func (f *Interface) maybeSendRecvError(endpoint netip.AddrPort, index uint32) {
  442. if f.sendRecvErrorConfig.ShouldSendRecvError(endpoint) {
  443. f.sendRecvError(endpoint, index)
  444. }
  445. }
  446. func (f *Interface) sendRecvError(endpoint netip.AddrPort, index uint32) {
  447. f.messageMetrics.Tx(header.RecvError, 0, 1)
  448. b := header.Encode(make([]byte, header.Len), header.Version, header.RecvError, 0, index, 0)
  449. _ = f.outside.WriteTo(b, endpoint)
  450. if f.l.Level >= logrus.DebugLevel {
  451. f.l.WithField("index", index).
  452. WithField("udpAddr", endpoint).
  453. Debug("Recv error sent")
  454. }
  455. }
  456. func (f *Interface) handleRecvError(addr netip.AddrPort, h *header.H) {
  457. if f.l.Level >= logrus.DebugLevel {
  458. f.l.WithField("index", h.RemoteIndex).
  459. WithField("udpAddr", addr).
  460. Debug("Recv error received")
  461. }
  462. hostinfo := f.hostMap.QueryReverseIndex(h.RemoteIndex)
  463. if hostinfo == nil {
  464. f.l.WithField("remoteIndex", h.RemoteIndex).Debugln("Did not find remote index in main hostmap")
  465. return
  466. }
  467. if !hostinfo.RecvErrorExceeded() {
  468. return
  469. }
  470. if hostinfo.remote.IsValid() && hostinfo.remote != addr {
  471. f.l.Infoln("Someone spoofing recv_errors? ", addr, hostinfo.remote)
  472. return
  473. }
  474. f.closeTunnel(hostinfo)
  475. // We also delete it from pending hostmap to allow for fast reconnect.
  476. f.handshakeManager.DeleteHostInfo(hostinfo)
  477. }