From 83181647bf1002aefe0f6234c2fce8d91595fc5c Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Wed, 22 May 2024 09:29:47 +0000 Subject: [PATCH] fix: fix conversion from netip to tcpip Signed-off-by: Spike Curtis --- net/tstun/tap_linux.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/tstun/tap_linux.go b/net/tstun/tap_linux.go index 7dcb5ee5d8ec7..b6623da73fb35 100644 --- a/net/tstun/tap_linux.go +++ b/net/tstun/tap_linux.go @@ -295,10 +295,8 @@ func packLayer2UDP(payload []byte, srcMAC, dstMAC net.HardwareAddr, src, dst net buf := make([]byte, header.EthernetMinimumSize+header.UDPMinimumSize+header.IPv4MinimumSize+len(payload)) payloadStart := len(buf) - len(payload) copy(buf[payloadStart:], payload) - srcB := src.Addr().As4() - srcIP := tcpip.Address(srcB[:]) - dstB := dst.Addr().As4() - dstIP := tcpip.Address(dstB[:]) + srcIP := tcpip.AddrFromSlice(src.Addr().AsSlice()) + dstIP := tcpip.AddrFromSlice(dst.Addr().AsSlice()) // Ethernet header eth := header.Ethernet(buf) eth.Encode(&header.EthernetFields{