Judge a frame against the stream its socket receives rather than the one its header claims

This commit is contained in:
flamingcow
2026-08-04 21:19:08 -07:00
parent 51467231ee
commit 21788fdd4f
2 changed files with 18 additions and 17 deletions
+2 -1
View File
@@ -466,9 +466,10 @@ func (d *direction) start(wg *sync.WaitGroup, doneTx, doneRx *atomic.Bool, rxRea
w := &rxWorker{ w := &rxWorker{
fd: fd, fd: fd,
batch: batchSize, batch: batchSize,
stream: uint16(i),
spec: d.specs[i], spec: d.specs[i],
stats: d.rxStats[i], stats: d.rxStats[i],
streams: d.streams, loss: &d.streams[i],
ready: rxReady, ready: rxReady,
} }
wg.Add(1) wg.Add(1)
+6 -6
View File
@@ -67,9 +67,10 @@ func (s *rxStats) bucket(e int64) (frames, bytes uint64) {
type rxWorker struct { type rxWorker struct {
fd int fd int
batch int batch int
stream uint16
spec *frameSpec spec *frameSpec
stats *rxStats stats *rxStats
streams []lossWindow loss *lossWindow
ready *sync.WaitGroup ready *sync.WaitGroup
} }
@@ -115,11 +116,10 @@ func (w *rxWorker) run(done *atomic.Bool) {
w.stats.observe(ts, uint64(len(buf))) w.stats.observe(ts, uint64(len(buf)))
} }
// A sequence number the sender never reached got past the header // The ethertype this socket is bound to already says which stream the
// checksum, so the frame is damaged whatever its payload says. Counted // frame belongs to, so a header naming another one is damaged, as is a
// here rather than left to the payload check, which would report the // sequence number the sender never reached.
// same frame twice or, if only the header was hit, not at all. if p.stream != w.stream || !w.loss.observe(p.seq) {
if int(p.stream) < len(w.streams) && !w.streams[p.stream].observe(p.seq) {
w.stats.badHdr.Add(1) w.stats.badHdr.Add(1)
continue continue
} }