Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ require (
github.com/hashicorp/mdns v1.0.1 // indirect
github.com/hashicorp/memberlist v0.5.0 // indirect
github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443 // indirect
github.com/hedzr/go-ringbuf/v2 v2.2.1 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,6 @@ github.com/hashicorp/memberlist v0.5.0 h1:EtYPN8DpAURiapus508I4n9CzHs2W+8NZGbmmR
github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0=
github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443 h1:O/pT5C1Q3mVXMyuqg7yuAWUg/jMZR1/0QTzTRdNR6Uw=
github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443/go.mod h1:bEpDU35nTu0ey1EXjwNwPjI9xErAsoOCmcMb9GKvyxo=
github.com/hedzr/go-ringbuf/v2 v2.2.1 h1:bnIRxSCWYt4vs5UCDCOYf+r1C8cQC7tkcOdjOTaVzNk=
github.com/hedzr/go-ringbuf/v2 v2.2.1/go.mod h1:N3HsRpbHvPkX9GsykpkPoR2vD6WRR6GbU7tx/9GLE4M=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
Expand Down
130 changes: 0 additions & 130 deletions pkg/tunnel/connection/pipe.go

This file was deleted.

74 changes: 0 additions & 74 deletions pkg/tunnel/connection/pipe_test.go

This file was deleted.

8 changes: 4 additions & 4 deletions pkg/tunnel/fasttun/fasttun.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ type Device interface {
// MTU returns the device's Maximum Transmission Unit.
MTU() (int, error)

// BatchSize returns the recommended number of packets to process in one batch.
// This is useful for optimizing I/O performance.
BatchSize() int

// NewPacketQueue creates a new packet queue for the device.
// Each queue is associated with a file descriptor and can be used
// concurrently with others.
Expand All @@ -31,6 +27,10 @@ type Device interface {
type PacketQueue interface {
io.Closer

// BatchSize returns the recommended number of packets to process in one batch.
// This is useful for optimizing I/O performance.
BatchSize() int

// Read reads packets into the provided buffer slices `pkts` and stores
// the size of each packet in `sizes`.
//
Expand Down
14 changes: 9 additions & 5 deletions pkg/tunnel/fasttun/fasttun_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ func (d *LinuxDevice) Close() error {
}
d.packetQueues = nil

return fmt.Errorf("failed to close packet queues: %w", closeErr)
if closeErr != nil {
return fmt.Errorf("failed to close packet queues: %w", closeErr)
}

return nil
}

func (d *LinuxDevice) Name() string {
Expand All @@ -54,10 +58,6 @@ func (d *LinuxDevice) MTU() (int, error) {
return d.mtu, nil
}

func (d *LinuxDevice) BatchSize() int {
return 64
}

// NewPacketQueue creates a new packet queue for the device.
func (d *LinuxDevice) NewPacketQueue() (PacketQueue, error) {
fd, err := unix.Open("/dev/net/tun", unix.O_RDWR|unix.O_CLOEXEC, 0)
Expand Down Expand Up @@ -121,6 +121,10 @@ func (q *LinuxPacketQueue) Close() error {
return q.tunFile.Close()
}

func (q *LinuxPacketQueue) BatchSize() int {
return 64
}

func (q *LinuxPacketQueue) Read(pkts [][]byte, sizes []int) (int, error) {
fd := int(q.tunFile.Fd())
timeout := 50 * time.Millisecond
Expand Down
Loading