mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
tcp_benchmark: allow packet sniffing/logging
PiperOrigin-RevId: 534910831
This commit is contained in:
committed by
gVisor bot
parent
3b57dd815f
commit
ebc8d4df1f
@@ -14,6 +14,7 @@ go_binary(
|
||||
"//pkg/tcpip/adapters/gonet",
|
||||
"//pkg/tcpip/link/fdbased",
|
||||
"//pkg/tcpip/link/qdisc/fifo",
|
||||
"//pkg/tcpip/link/sniffer",
|
||||
"//pkg/tcpip/network/arp",
|
||||
"//pkg/tcpip/network/ipv4",
|
||||
"//pkg/tcpip/network/ipv6",
|
||||
|
||||
@@ -50,6 +50,7 @@ disable_linux_gso=
|
||||
disable_linux_gro=
|
||||
gro=0
|
||||
num_client_threads=1
|
||||
sniff=false
|
||||
|
||||
# Check for netem support.
|
||||
lsmod_output=$(lsmod | grep sch_netem)
|
||||
@@ -199,6 +200,9 @@ while [[ $# -gt 0 ]]; do
|
||||
[[ "$#" -le 0 ]] && echo "no iperf name provided" && exit 1
|
||||
iperf_binary_name=$1
|
||||
;;
|
||||
--sniff)
|
||||
netstack_opts="${netstack_opts} -sniff"
|
||||
;;
|
||||
*)
|
||||
echo "unknown option: $1"
|
||||
echo ""
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/tcpip/adapters/gonet"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/link/fdbased"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/link/qdisc/fifo"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/link/sniffer"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/network/arp"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/network/ipv4"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/network/ipv6"
|
||||
@@ -72,6 +73,7 @@ var (
|
||||
mutexprofile = flag.String("mutexprofile", "", "write a mutex profile to the specified file.")
|
||||
traceprofile = flag.String("traceprofile", "", "write a 5s trace of the benchmark to the specified file.")
|
||||
useIpv6 = flag.Bool("ipv6", false, "use ipv6 instead of ipv4.")
|
||||
sniff = flag.Bool("sniff", false, "log sniffed packets")
|
||||
)
|
||||
|
||||
type impl interface {
|
||||
@@ -229,6 +231,10 @@ func newNetstackImpl(mode string) (impl, error) {
|
||||
return nil, fmt.Errorf("failed to create FD endpoint: %v", err)
|
||||
}
|
||||
|
||||
if *sniff {
|
||||
ep = sniffer.New(ep)
|
||||
}
|
||||
|
||||
qDisc := fifo.New(ep, runtime.GOMAXPROCS(0), 1000)
|
||||
opts := stack.NICOptions{QDisc: qDisc, GROTimeout: *gro}
|
||||
if err := s.CreateNICWithOptions(nicID, ep, opts); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user