mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
netstack: remove sniffer.LogPacketsToPCAP
This was always set to 1, with the deteriminant of whether to log PCAP output instead being whether `sniffer.Endpoint.writer` was non-nil. There's no reason to keep it around. PiperOrigin-RevId: 675712237
This commit is contained in:
committed by
gVisor bot
parent
f681bcc095
commit
4d37180f89
@@ -39,11 +39,6 @@ import (
|
||||
// package. Valid values are 0 or 1.
|
||||
var LogPackets atomicbitops.Uint32 = atomicbitops.FromUint32(1)
|
||||
|
||||
// LogPacketsToPCAP is a flag used to enable or disable logging packets to a
|
||||
// pcap writer. Valid values are 0 or 1. A writer must have been specified when the
|
||||
// sniffer was created for this flag to have effect.
|
||||
var LogPacketsToPCAP atomicbitops.Uint32 = atomicbitops.FromUint32(1)
|
||||
|
||||
// Endpoint is used to sniff and log network traffic.
|
||||
//
|
||||
// +stateify savable
|
||||
@@ -155,11 +150,10 @@ func (e *Endpoint) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pk
|
||||
// DumpPacket logs a packet, depending on configuration, to stderr and/or a
|
||||
// pcap file. ts is an optional timestamp for the packet.
|
||||
func (e *Endpoint) DumpPacket(dir Direction, protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer, ts *time.Time) {
|
||||
writer := e.writer
|
||||
if LogPackets.Load() == 1 {
|
||||
LogPacket(e.logPrefix, dir, protocol, pkt)
|
||||
}
|
||||
if writer != nil && LogPacketsToPCAP.Load() == 1 {
|
||||
if e.writer != nil {
|
||||
packet := pcapPacket{
|
||||
packet: pkt,
|
||||
maxCaptureLen: int(e.maxPCAPLen),
|
||||
@@ -173,7 +167,7 @@ func (e *Endpoint) DumpPacket(dir Direction, protocol tcpip.NetworkProtocolNumbe
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if _, err := writer.Write(b); err != nil {
|
||||
if _, err := e.writer.Write(b); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user