crazy multiport stuff

(cherry picked from commit 0488793a62)
This commit is contained in:
JackDoan authored and Wade Simmons committed 2026-09-02 11:26:30 -04:00
1 parent dd8f660c0a
commit 0ae7ba073c
19 files changed
+1841 -77

No files matched your search

+9 -5
View File
@@ -102,7 +102,7 @@ func (f *Interface) readOutsidePackets(via ViaSender, packet []byte, rxc *rxCont
// recvError if necessary
if hostinfo == nil || hostinfo.ConnectionState == nil {
if !via.IsRelayed {
f.maybeSendRecvError(via.UdpAddr, h.RemoteIndex)
f.maybeSendRecvError(via.UdpAddr, h.RemoteIndex, via.SockIdx)
}
return
}
@@ -214,6 +214,7 @@ func (f *Interface) handleOutsideRelayPacket(hostinfo *HostInfo, via ViaSender,
relayHI: hostinfo,
relay: relay,
IsRelayed: true,
SockIdx: via.SockIdx,
}
f.readOutsidePackets(via, signedPayload, rxc)
case ForwardingType:
@@ -492,17 +493,20 @@ func (f *Interface) handleOutsideMessagePacket(hostinfo *HostInfo, messageCounte
}
}
func (f *Interface) maybeSendRecvError(endpoint netip.AddrPort, index uint32) {
func (f *Interface) maybeSendRecvError(endpoint netip.AddrPort, index uint32, q int) {
if f.sendRecvErrorConfig.ShouldRecvError(endpoint) {
f.sendRecvError(endpoint, index)
f.sendRecvError(endpoint, index, q)
}
}
func (f *Interface) sendRecvError(endpoint netip.AddrPort, index uint32) {
// sendRecvError replies from the socket the offending packet arrived on (q).
// A lane peer's spoof guard compares our source addr against the lane's
// remote, so a reply from the base port would be discarded.
func (f *Interface) sendRecvError(endpoint netip.AddrPort, index uint32, q int) {
f.messageMetrics.Tx(header.RecvError, 0, 1)
b := header.Encode(make([]byte, header.Len), header.Version, header.RecvError, 0, index, 0)
_ = f.outside.WriteTo(b, endpoint)
_ = f.writers[q].WriteTo(b, endpoint)
if f.l.Enabled(context.Background(), slog.LevelDebug) {
f.l.Debug("Recv error sent",
"index", index,