Skip the inbound firewall for the rest of a flow's run within one receive batch

This commit is contained in:
JackDoan committed 2026-10-01 12:01:00 -05:00
1 parent 905d01aee5
commit b4158b3855
3 files changed
+82 -3

No files matched your search

+18 -1
View File
@@ -477,7 +477,7 @@ func (f *Interface) handleOutsideMessagePacket(hostinfo *HostInfo, messageCounte
return
}
dropReason := f.firewall.Drop(rxc.fwPacket.Packet, true, hostinfo, f.pki.GetCAPool())
dropReason := f.allowInbound(hostinfo, rxc)
if dropReason != nil {
f.rejectOutside(out, hostinfo.ConnectionState, hostinfo, rxc.nb, rxc.scratch, rxc.q)
if f.l.Enabled(context.Background(), slog.LevelDebug) {
@@ -492,6 +492,23 @@ func (f *Interface) handleOutsideMessagePacket(hostinfo *HostInfo, messageCounte
}
}
// allowInbound runs the inbound firewall check on rxc.fwPacket. It skips the check when the packet belongs to
// the same flow from the same host as the last one allowed in this batch.
func (f *Interface) allowInbound(hostinfo *HostInfo, rxc *rxContext) error {
fp := rxc.fwPacket.Packet
if hostinfo == rxc.lastAllowedHost && fp == rxc.lastAllowed {
return nil
}
if err := f.firewall.Drop(fp, true, hostinfo, f.pki.GetCAPool()); err != nil {
return err
}
rxc.lastAllowed = fp
rxc.lastAllowedHost = hostinfo
return nil
}
func (f *Interface) maybeSendRecvError(endpoint netip.AddrPort, index uint32) {
if f.sendRecvErrorConfig.ShouldRecvError(endpoint) {
f.sendRecvError(endpoint, index)