diff --git a/inside.go b/inside.go index cee7a787..32175b62 100644 --- a/inside.go +++ b/inside.go @@ -15,7 +15,7 @@ import ( "github.com/slackhq/nebula/routing" ) -func (f *Interface) consumeInsidePacket(pkt tio.Packet, fwPacket *firewall.Packet, nb []byte, sendBatch batch.TxBatcher, rejectBuf []byte, q int, localCache firewall.ConntrackCache) { +func (f *Interface) consumeInsidePacket(pkt tio.Packet, fwPacket *firewall.Packet, nb []byte, sendBatch *batch.SendBatch, rejectBuf []byte, q int, localCache firewall.ConntrackCache) { // borrowed: pkt.Bytes is owned by the originating tio.Queue and is // only valid until the next Read on that queue. Every consumer below // (parse, self-forward, handshake cache, sendInsideMessage) reads it @@ -107,7 +107,7 @@ func (f *Interface) consumeInsidePacket(pkt tio.Packet, fwPacket *firewall.Packe dropReason := f.firewall.Drop(*fwPacket, false, hostinfo, f.pki.GetCAPool(), localCache) if dropReason == nil { - f.sendInsideMessage(hostinfo, pkt, nb, sendBatch, rejectBuf, q) + f.sendInsideMessage(hostinfo, pkt, nb, sendBatch) } else { f.rejectInside(packet, rejectBuf, q) if f.l.Enabled(context.Background(), slog.LevelDebug) { @@ -137,8 +137,7 @@ func (f *Interface) sendInsideEncrypt(hostinfo *HostInfo, ci *ConnectionState, s "udpAddr", hostinfo.GetRemote(), "counter", c, ) - // Skip this segment; the rest of the superpacket can still - // go out — TCP will retransmit anything we drop here. + // Skip this segment; the rest of the superpacket can still go out. TCP will retransmit anything we drop here. return nil } @@ -150,9 +149,8 @@ func (f *Interface) sendInsideEncrypt(hostinfo *HostInfo, ci *ConnectionState, s // later sendmmsg flush. Segmentation is fused with encryption here so the // kernel-supplied superpacket bytes never get written into a separate // scratch arena: SegmentSuperpacket builds each segment's plaintext in -// segScratch[:segLen] in turn, and we encrypt directly into a fresh -// SendBatch slot. -func (f *Interface) sendInsideMessage(hostinfo *HostInfo, pkt tio.Packet, nb []byte, sendBatch batch.TxBatcher, rejectBuf []byte, q int) { +// segScratch[:segLen] in turn, and we encrypt directly into a fresh SendBatch slot. +func (f *Interface) sendInsideMessage(hostinfo *HostInfo, pkt tio.Packet, nb []byte, sendBatch *batch.SendBatch) { ci := hostinfo.ConnectionState if ci.eKey == nil { return @@ -236,9 +234,7 @@ func (f *Interface) sendInsideMessage(hostinfo *HostInfo, pkt tio.Packet, nb []b return nil }) if err != nil { - hostinfo.logger(f.l).Error("Failed to segment superpacket for send", - "error", err, - ) + hostinfo.logger(f.l).Error("Failed to segment superpacket for send", "error", err) } } diff --git a/overlay/batch/batch.go b/overlay/batch/batch.go index 5cb6cbe4..7eda8c97 100644 --- a/overlay/batch/batch.go +++ b/overlay/batch/batch.go @@ -1,7 +1,5 @@ package batch -import "net/netip" - type RxBatcher interface { // Commit commits pkt to be flushed by the batch. The caller must keep pkt valid until the next Flush, and not re-use it. Commit(pkt []byte) error @@ -9,21 +7,8 @@ type RxBatcher interface { // a flow's payload-bearing packets are never reordered relative to each // other. Cross-flow and cross-lane order is not preserved, and two shapes // may legally be overtaken by later same-flow data: pure ACKs (by design, - // stale ACKs are ignored) and unparseable shapes such as fragments (an - // accepted tradeoff; see MultiCoalescer). + // stale ACKs are ignored) and unparseable shapes such as fragments (an accepted tradeoff; see MultiCoalescer). // Returns the first error observed; keeps draining so one bad packet doesn't hold up the rest. // After Flush returns, committed payload slices may be recycled. Flush() error } - -type TxBatcher interface { - // Reserve creates a pkt to borrow - Reserve(sz int) []byte - // Commit borrows pkt and records its destination. The caller must - // keep pkt valid until the next Flush. - Commit(pkt []byte, dst netip.AddrPort) - // Flush emits every queued packet via the underlying batch writer in arrival order and reports how many were - // actually written. A short count means some destinations were undeliverable, not that the batch failed. - // After Flush returns, borrowed payload slices may be recycled. - Flush() (int, error) -}