Hostmap.QueryIndex is really hot

This commit is contained in:
JackDoan
2026-08-04 11:34:02 -05:00
parent e1d96b932a
commit d14b97977f
3 changed files with 19 additions and 6 deletions
+3 -1
View File
@@ -363,15 +363,17 @@ func (f *Interface) listenOut(i int) {
fwPacket := &firewall.ParsedPacket{}
nb := make([]byte, 12, 12)
scratch := make([]byte, mtu)
hostmapCache := map[uint32]*HostInfo{} //todo is this stupid
listener := func(fromUdpAddr netip.AddrPort, payload []byte) {
f.readOutsidePackets(ViaSender{UdpAddr: fromUdpAddr}, scratch, payload, h, fwPacket, lhh, nb, i, ctCache.Get())
f.readOutsidePackets(ViaSender{UdpAddr: fromUdpAddr}, scratch, payload, h, fwPacket, lhh, nb, i, ctCache.Get(), hostmapCache)
}
flusher := func() {
if err := f.batchers[i].Flush(); err != nil {
f.l.Error("Failed to flush tun coalescer", "error", err)
}
clear(hostmapCache)
}
err := li.ListenOut(listener, flusher)