diff --git a/tstest/natlab/vnet/vnet.go b/tstest/natlab/vnet/vnet.go index 8fe2a9ec1..4e7e763ef 100644 --- a/tstest/natlab/vnet/vnet.go +++ b/tstest/natlab/vnet/vnet.go @@ -692,17 +692,6 @@ func (s *Server) ServeUnixConn(uc *net.UnixConn, proto Protocol) { } packetRaw = buf[4 : 4+n] // raw ethernet frame } - if s.pcapWriter != nil { - ci := gopacket.CaptureInfo{ - Timestamp: time.Now(), - CaptureLength: len(packetRaw), - Length: len(packetRaw), - } - if srcNode != nil { - ci.InterfaceIndex = srcNode.id - } - must.Do(s.pcapWriter.WritePacket(ci, packetRaw)) - } packet := gopacket.NewPacket(packetRaw, layers.LayerTypeEthernet, gopacket.Lazy) le, ok := packet.LinkLayer().(*layers.Ethernet) @@ -728,6 +717,17 @@ func (s *Server) ServeUnixConn(uc *net.UnixConn, proto Protocol) { continue } } + if s.pcapWriter != nil { + ci := gopacket.CaptureInfo{ + Timestamp: time.Now(), + CaptureLength: len(packetRaw), + Length: len(packetRaw), + } + if srcNode != nil { + ci.InterfaceIndex = srcNode.id + } + must.Do(s.pcapWriter.WritePacket(ci, packetRaw)) + } netw.HandleEthernetPacket(ep) } }