diff --git a/dhcp.go b/dhcp.go index bb04ca1..520ef9a 100644 --- a/dhcp.go +++ b/dhcp.go @@ -9,6 +9,7 @@ import ( "github.com/insomniacslk/dhcp/dhcpv4" "gvisor.dev/gvisor/pkg/tcpip" + "gvisor.dev/gvisor/pkg/tcpip/checksum" "gvisor.dev/gvisor/pkg/tcpip/header" "gvisor.dev/gvisor/pkg/tcpip/network/ipv4" "gvisor.dev/gvisor/pkg/tcpip/transport/udp" @@ -115,7 +116,7 @@ func makeUDPv4Packet( // Calculate the UDP pseudo-header checksum. xsum := header.PseudoHeaderChecksum(udp.ProtocolNumber, srcIP, dstIP, uint16(len(udpv4))) // Calculate the UDP checksum and set it. - xsum = header.Checksum(payload, xsum) + xsum = checksum.Checksum(payload, xsum) udpv4.SetChecksum(^udpv4.CalculateChecksum(xsum)) return buf diff --git a/endpoint.go b/endpoint.go index 3143f34..489f8b5 100644 --- a/endpoint.go +++ b/endpoint.go @@ -137,7 +137,7 @@ func (e *endpoint) ARPHardwareType() header.ARPHardwareType { } // AddHeader implements stack.LinkEndpoint.AddHeader. -func (e *endpoint) AddHeader(pkt *stack.PacketBuffer) { +func (e *endpoint) AddHeader(pkt stack.PacketBufferPtr) { // Add ethernet header if needed. eth := header.Ethernet(pkt.LinkHeader().Push(header.EthernetMinimumSize)) eth.Encode(&header.EthernetFields{ @@ -184,7 +184,7 @@ func (e *endpoint) dispatchLoop(devAddr tcpip.Address, conn net.Conn) { // writePacket writes outbound packets to the connection. If it is not // currently writable, the packet is dropped. -func (e *endpoint) writePacket(pkt *stack.PacketBuffer) tcpip.Error { +func (e *endpoint) writePacket(pkt stack.PacketBufferPtr) tcpip.Error { data := pkt.ToView().AsSlice() if e.writer != nil { @@ -259,7 +259,7 @@ func (e *endpoint) inboundDispatch(devAddr tcpip.Address, conn net.Conn) (bool, } func (e *endpoint) deliverOrConsumeNetworkPacket( - pkt *stack.PacketBuffer, + pkt stack.PacketBufferPtr, conn net.Conn, ) (bool, error) { hdr, ok := pkt.LinkHeader().Consume(int(e.MaxHeaderLength())) diff --git a/go.mod b/go.mod index cf70dfa..767ad0b 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 golang.org/x/net v0.2.0 golang.org/x/sync v0.1.0 - gvisor.dev/gvisor v0.0.0-20220817001344-846276b3dbc5 + gvisor.dev/gvisor v0.0.0-20221216231429-a78e892a26d2 ) require ( diff --git a/go.sum b/go.sum index cd147e0..52b3a81 100644 --- a/go.sum +++ b/go.sum @@ -110,5 +110,5 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gvisor.dev/gvisor v0.0.0-20220817001344-846276b3dbc5 h1:cv/zaNV0nr1mJzaeo4S5mHIm5va1W0/9J3/5prlsuRM= -gvisor.dev/gvisor v0.0.0-20220817001344-846276b3dbc5/go.mod h1:TIvkJD0sxe8pIob3p6T8IzxXunlp6yfgktvTNp+DGNM= +gvisor.dev/gvisor v0.0.0-20221216231429-a78e892a26d2 h1:QN+Xh63jThYFN4CrcD4KXj+rUhevlb0LXEAlZ4m+qXQ= +gvisor.dev/gvisor v0.0.0-20221216231429-a78e892a26d2/go.mod h1:Dn5idtptoW1dIos9U6A2rpebLs/MtTwFacjKb8jLdQA= diff --git a/ping.go b/ping.go index 41ad958..dcf46c1 100644 --- a/ping.go +++ b/ping.go @@ -8,6 +8,7 @@ import ( xicmp "golang.org/x/net/icmp" xipv4 "golang.org/x/net/ipv4" "gvisor.dev/gvisor/pkg/tcpip" + "gvisor.dev/gvisor/pkg/tcpip/checksum" "gvisor.dev/gvisor/pkg/tcpip/header" "gvisor.dev/gvisor/pkg/tcpip/network/ipv4" "gvisor.dev/gvisor/pkg/tcpip/transport/icmp" @@ -129,7 +130,7 @@ func makeICMPv4EchoPacket( icmpv4.SetSequence(sequence) copy(icmpv4.Payload(), payload) icmpv4.SetChecksum(0) - icmpv4.SetChecksum(^header.Checksum(icmpv4, 0)) + icmpv4.SetChecksum(^checksum.Checksum(icmpv4, 0)) return buf }