Bucket received frames by their mac receive stamp and read one bucket back

This commit is contained in:
flamingcow
2026-08-04 20:04:30 -07:00
parent 8db5c29882
commit 703039587b
4 changed files with 185 additions and 47 deletions
+16
View File
@@ -114,6 +114,22 @@ func newMmsghdrs(bufs [][]byte) ([]mmsghdr, []unix.Iovec) {
return hdrs, iovs
}
// Room for one SCM_TIMESTAMPING and its three timespecs.
const cmsgLen = 128
// Receive headers carry a control buffer each, so the mac's receive stamp comes
// back alongside every frame.
func newRxMmsghdrs(bufs [][]byte) ([]mmsghdr, [][]byte) {
hdrs, _ := newMmsghdrs(bufs)
oob := make([][]byte, len(bufs))
for i := range bufs {
oob[i] = make([]byte, cmsgLen)
hdrs[i].hdr.Control = &oob[i][0]
hdrs[i].hdr.Controllen = cmsgLen
}
return hdrs, oob
}
func packetDrops(fd int) uint64 {
st, err := unix.GetsockoptTpacketStats(fd, unix.SOL_PACKET, unix.PACKET_STATISTICS)
if err != nil {