diff options
author | Bhasker Hariharan <bhaskerh@google.com> | 2020-07-22 15:12:56 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-07-22 15:33:33 -0700 |
commit | 71bf90c55bd888f9b9c493533ca5e4b2b4b3d21d (patch) | |
tree | c28e9fb6e24c4f442839b041d5a1ba5105ff1dbd /pkg/tcpip/link/waitable/waitable.go | |
parent | 13c0cca50e061c9b9a3ae8e13e8baa0f29909370 (diff) |
Support for receiving outbound packets in AF_PACKET.
Updates #173
PiperOrigin-RevId: 322665518
Diffstat (limited to 'pkg/tcpip/link/waitable/waitable.go')
-rw-r--r-- | pkg/tcpip/link/waitable/waitable.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/tcpip/link/waitable/waitable.go b/pkg/tcpip/link/waitable/waitable.go index 24a8dc2eb..b152a0f26 100644 --- a/pkg/tcpip/link/waitable/waitable.go +++ b/pkg/tcpip/link/waitable/waitable.go @@ -60,6 +60,15 @@ func (e *Endpoint) DeliverNetworkPacket(remote, local tcpip.LinkAddress, protoco e.dispatchGate.Leave() } +// DeliverOutboundPacket implements stack.NetworkDispatcher.DeliverOutboundPacket. +func (e *Endpoint) DeliverOutboundPacket(remote, local tcpip.LinkAddress, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) { + if !e.dispatchGate.Enter() { + return + } + e.dispatcher.DeliverOutboundPacket(remote, local, protocol, pkt) + e.dispatchGate.Leave() +} + // Attach implements stack.LinkEndpoint.Attach. It saves the dispatcher and // registers with the lower endpoint as its dispatcher so that "e" is called // for inbound packets. @@ -153,3 +162,8 @@ func (e *Endpoint) Wait() {} func (e *Endpoint) ARPHardwareType() header.ARPHardwareType { return e.lower.ARPHardwareType() } + +// AddHeader implements stack.LinkEndpoint.AddHeader. +func (e *Endpoint) AddHeader(local, remote tcpip.LinkAddress, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer) { + e.lower.AddHeader(local, remote, protocol, pkt) +} |