Skip to content

Commit

Permalink
daemon: Add support for CRC_DAEMON_PCAP_FILE env var
Browse files Browse the repository at this point in the history
The daemon can capture all VM network traffic to a pcap file, which can
be useful to debug networking issues. This capture is currently
always enabled when --log-level debug is being used.

Because of #1881 , this means a
big pcap file is created every time the daemon is run with --log-level
debug.
Since the pcap file won't be needed most of the time, this commit adds a
dedicated CRC_DAEMON_PCAP_FILE variable which gives the path where this
data should be exported. If unset, no pcap file is created.
  • Loading branch information
cfergeau authored and praveenkumar committed Jul 14, 2021
1 parent fb92b11 commit 5ed4a8b
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions cmd/crc/cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http"
"os"
"os/signal"
"path/filepath"
"regexp"
"syscall"
"time"
Expand Down Expand Up @@ -58,7 +57,7 @@ var daemonCmd = &cobra.Command{

virtualNetworkConfig := types.Configuration{
Debug: false, // never log packets
CaptureFile: captureFile(),
CaptureFile: os.Getenv("CRC_DAEMON_PCAP_FILE"),
MTU: 4000, // Large packets slightly improve the performance. Less small packets.
Subnet: "192.168.127.0/24",
GatewayIP: constants.VSockGateway,
Expand Down Expand Up @@ -113,13 +112,6 @@ var daemonCmd = &cobra.Command{
},
}

func captureFile() string {
if !isDebugLog() {
return ""
}
return filepath.Join(constants.CrcBaseDir, "capture.pcap")
}

func run(configuration *types.Configuration) error {
vsockListener, err := vsockListener()
if err != nil {
Expand Down

0 comments on commit 5ed4a8b

Please sign in to comment.