Skip to content

Commit d5865f2

Browse files
committed
Fix gvisor loopback address
1 parent ff49ece commit d5865f2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stack_gvisor_tcp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (f *TCPForwarder) HandlePacket(id stack.TransportEndpointID, pkt *stack.Pac
5252
ipHdr.SetSourceAddressWithChecksumUpdate(inet4LoopbackAddress)
5353
tcpHdr := header.TCP(pkt.TransportHeader().Slice())
5454
tcpHdr.SetChecksum(0)
55-
tcpHdr.SetChecksum(^checksum.Checksum(tcpHdr.Payload(), tcpHdr.CalculateChecksum(
55+
tcpHdr.SetChecksum(^checksum.Combine(pkt.Data().Checksum(), tcpHdr.CalculateChecksum(
5656
header.PseudoHeaderChecksum(header.TCPProtocolNumber, ipHdr.SourceAddress(), ipHdr.DestinationAddress(), ipHdr.PayloadLength()),
5757
)))
5858
f.tun.WritePacket(pkt)
@@ -66,7 +66,7 @@ func (f *TCPForwarder) HandlePacket(id stack.TransportEndpointID, pkt *stack.Pac
6666
ipHdr.SetSourceAddress(inet6LoopbackAddress)
6767
tcpHdr := header.TCP(pkt.TransportHeader().Slice())
6868
tcpHdr.SetChecksum(0)
69-
tcpHdr.SetChecksum(^checksum.Checksum(tcpHdr.Payload(), tcpHdr.CalculateChecksum(
69+
tcpHdr.SetChecksum(^checksum.Combine(pkt.Data().Checksum(), tcpHdr.CalculateChecksum(
7070
header.PseudoHeaderChecksum(header.TCPProtocolNumber, ipHdr.SourceAddress(), ipHdr.DestinationAddress(), ipHdr.PayloadLength()),
7171
)))
7272
f.tun.WritePacket(pkt)

0 commit comments

Comments
 (0)