mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Create the interfaces for PACKET_MMAP endpoints to implement.
PiperOrigin-RevId: 721823737
This commit is contained in:
committed by
gVisor bot
parent
a500a2c751
commit
198ac833f1
@@ -162,7 +162,7 @@ type PacketEndpoint interface {
|
||||
// match the endpoint.
|
||||
//
|
||||
// Implementers should treat packet as immutable and should copy it
|
||||
// before before modification.
|
||||
// before modification.
|
||||
//
|
||||
// linkHeader may have a length of 0, in which case the PacketEndpoint
|
||||
// should construct its own ethernet header for applications.
|
||||
@@ -171,6 +171,67 @@ type PacketEndpoint interface {
|
||||
HandlePacket(nicID tcpip.NICID, netProto tcpip.NetworkProtocolNumber, pkt *PacketBuffer)
|
||||
}
|
||||
|
||||
// MappablePacketEndpoint is a packet endpoint that supports forwarding its
|
||||
// packets to a PacketMMapEndpoint.
|
||||
type MappablePacketEndpoint interface {
|
||||
PacketEndpoint
|
||||
|
||||
// GetPacketMMapOpts returns the options for initializing a PacketMMapEndpoint
|
||||
// for this endpoint.
|
||||
GetPacketMMapOpts(req *tcpip.TpacketReq, isRx bool) PacketMMapOpts
|
||||
|
||||
// SetPacketMMapEndpoint sets the PacketMMapEndpoint for this endpoint. All
|
||||
// packets received by this endpoint will be forwarded to the provided
|
||||
// PacketMMapEndpoint.
|
||||
SetPacketMMapEndpoint(ep PacketMMapEndpoint)
|
||||
|
||||
// GetPacketMMapEndpoint returns the PacketMMapEndpoint for this endpoint or
|
||||
// nil if there is none.
|
||||
GetPacketMMapEndpoint() PacketMMapEndpoint
|
||||
|
||||
// HandlePacketMMapCopy is a function that is called when a packet received is
|
||||
// too large for the buffer size specified for the memory mapped endpoint. In
|
||||
// this case, the packet is copied and passed to the original packet endpoint.
|
||||
HandlePacketMMapCopy(nicID tcpip.NICID, netProto tcpip.NetworkProtocolNumber, pkt *PacketBuffer)
|
||||
}
|
||||
|
||||
// PacketMMapOpts are the options for initializing a PacketMMapEndpoint.
|
||||
//
|
||||
// +stateify savable
|
||||
type PacketMMapOpts struct {
|
||||
Req *tcpip.TpacketReq
|
||||
IsRx bool
|
||||
Cooked bool
|
||||
Stack *Stack
|
||||
Stats *tcpip.TransportEndpointStats
|
||||
Wq *waiter.Queue
|
||||
NICID tcpip.NICID
|
||||
NetProto tcpip.NetworkProtocolNumber
|
||||
PacketEndpoint MappablePacketEndpoint
|
||||
}
|
||||
|
||||
// PacketMMapEndpoint is the interface implemented by endpoints to handle memory
|
||||
// mapped packets over the packet transport protocol (PACKET_MMAP).
|
||||
type PacketMMapEndpoint interface {
|
||||
// HandlePacket is called by the stack when new packets arrive that
|
||||
// match the endpoint.
|
||||
//
|
||||
// Implementers should treat packet as immutable and should copy it
|
||||
// before modification.
|
||||
//
|
||||
// linkHeader may have a length of 0, in which case the PacketEndpoint
|
||||
// should construct its own ethernet header for applications.
|
||||
//
|
||||
// HandlePacket may modify pkt.
|
||||
HandlePacket(nicID tcpip.NICID, netProto tcpip.NetworkProtocolNumber, pkt *PacketBuffer)
|
||||
|
||||
// Close releases any resources associated with the endpoint.
|
||||
Close()
|
||||
|
||||
// Readiness returns the events that the endpoint is ready for.
|
||||
Readiness(mask waiter.EventMask) waiter.EventMask
|
||||
}
|
||||
|
||||
// UnknownDestinationPacketDisposition enumerates the possible return values from
|
||||
// HandleUnknownDestinationPacket().
|
||||
type UnknownDestinationPacketDisposition int
|
||||
|
||||
Reference in New Issue
Block a user