Implement MappablePacketEndpoint for PACKET_MMAP and add tests.

PiperOrigin-RevId: 723590936
This commit is contained in:
Lucas Manning
2025-02-05 11:39:27 -08:00
committed by gVisor bot
parent e37e6814d3
commit 83a4caf2a7
7 changed files with 641 additions and 18 deletions
+3 -2
View File
@@ -185,7 +185,8 @@ type TpacketHdr struct {
TpMac uint16
TpNet uint16
TpSec uint32
TpUsec uint32 `marshal:"unaligned"`
TpUsec uint32
_ [4]byte
}
// TpacketAlignment is the alignment of a frame in a packet_mmap ring buffer
@@ -202,7 +203,7 @@ const (
// TPACKET_HDRLEN is the length of a TpacketHdr from <linux/if_packet.h>.
var (
TPACKET_HDRLEN = TPacketAlign(uint32((*TpacketHdr)(nil).SizeBytes()) + uint32((*SockAddrLink)(nil).SizeBytes()))
TPACKET_HDRLEN = TPacketAlign(uint32((*TpacketHdr)(nil).SizeBytes())) + uint32((*SockAddrLink)(nil).SizeBytes())
)
// TPacketAlign aligns a value to the alignment of a TPacket.