Judge a frame against the stream its socket receives rather than the one its header claims
This commit is contained in:
@@ -464,12 +464,13 @@ func (d *direction) start(wg *sync.WaitGroup, doneTx, doneRx *atomic.Bool, rxRea
|
|||||||
}
|
}
|
||||||
for i, fd := range d.rxFDs {
|
for i, fd := range d.rxFDs {
|
||||||
w := &rxWorker{
|
w := &rxWorker{
|
||||||
fd: fd,
|
fd: fd,
|
||||||
batch: batchSize,
|
batch: batchSize,
|
||||||
spec: d.specs[i],
|
stream: uint16(i),
|
||||||
stats: d.rxStats[i],
|
spec: d.specs[i],
|
||||||
streams: d.streams,
|
stats: d.rxStats[i],
|
||||||
ready: rxReady,
|
loss: &d.streams[i],
|
||||||
|
ready: rxReady,
|
||||||
}
|
}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
@@ -65,12 +65,13 @@ func (s *rxStats) bucket(e int64) (frames, bytes uint64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type rxWorker struct {
|
type rxWorker struct {
|
||||||
fd int
|
fd int
|
||||||
batch int
|
batch int
|
||||||
spec *frameSpec
|
stream uint16
|
||||||
stats *rxStats
|
spec *frameSpec
|
||||||
streams []lossWindow
|
stats *rxStats
|
||||||
ready *sync.WaitGroup
|
loss *lossWindow
|
||||||
|
ready *sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *rxWorker) run(done *atomic.Bool) {
|
func (w *rxWorker) run(done *atomic.Bool) {
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user