tstest/natlab/vnet: fix first packet pcap handling

Signed-off-by: Maisem Ali <[email protected]>
This commit is contained in:
Maisem Ali committed 2024-08-08 20:35:18 -07:00
1 parent 88f60bd16e
commit 6f2f08ae80
1 file changed
+11 -11
+11 -11
View File
@@ -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)
}
}