summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport
diff options
context:
space:
mode:
authorKevin Krakauer <krakauer@google.com>2019-11-25 09:26:30 -0800
committergVisor bot <gvisor-bot@google.com>2019-11-25 09:37:53 -0800
commit1641338b14204ea941c547cf4c1a70665922ca05 (patch)
tree0cea43077a6ae371b0915d095169f89ddfb8464f /pkg/tcpip/transport
parent2b1b51f1d7dd96f14b0af3b2663c33bc7ab67f63 (diff)
Set transport and network headers on outbound packets.
These are necessary for iptables to read and parse headers for packet filtering. PiperOrigin-RevId: 282372811
Diffstat (limited to 'pkg/tcpip/transport')
-rw-r--r--pkg/tcpip/transport/tcp/connect.go1
-rw-r--r--pkg/tcpip/transport/udp/endpoint.go5
2 files changed, 4 insertions, 2 deletions
diff --git a/pkg/tcpip/transport/tcp/connect.go b/pkg/tcpip/transport/tcp/connect.go
index f14f0ca65..4206db8b6 100644
--- a/pkg/tcpip/transport/tcp/connect.go
+++ b/pkg/tcpip/transport/tcp/connect.go
@@ -647,6 +647,7 @@ func buildTCPHdr(r *stack.Route, id stack.TransportEndpointID, pkt *tcpip.Packet
off := pkt.DataOffset
// Initialize the header.
tcp := header.TCP(hdr.Prepend(header.TCPMinimumSize + optLen))
+ pkt.TransportHeader = buffer.View(tcp)
tcp.Encode(&header.TCPFields{
SrcPort: id.LocalPort,
DstPort: id.RemotePort,
diff --git a/pkg/tcpip/transport/udp/endpoint.go b/pkg/tcpip/transport/udp/endpoint.go
index 23c1da717..24cb88c13 100644
--- a/pkg/tcpip/transport/udp/endpoint.go
+++ b/pkg/tcpip/transport/udp/endpoint.go
@@ -823,8 +823,9 @@ func sendUDP(r *stack.Route, data buffer.VectorisedView, localPort, remotePort u
ttl = r.DefaultTTL()
}
if err := r.WritePacket(nil /* gso */, stack.NetworkHeaderParams{Protocol: ProtocolNumber, TTL: ttl, TOS: tos}, tcpip.PacketBuffer{
- Header: hdr,
- Data: data,
+ Header: hdr,
+ Data: data,
+ TransportHeader: buffer.View(udp),
}); err != nil {
r.Stats().UDP.PacketSendErrors.Increment()
return err