Skip to content

Commit 7812930

Browse files
committed
Minor fixes
1 parent 4c81c8a commit 7812930

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

stack_mixed.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (m *Mixed) tunLoop() {
7777
return
7878
}
7979
}
80-
if darwinTUN, isDarwinTUN := m.tun.(DarwinTUN); isDarwinTUN {
80+
if darwinTUN, isDarwinTUN := m.tun.(DarwinTUN); isDarwinTUN && m.mtu < 49152 {
8181
m.batchLoopDarwin(darwinTUN)
8282
return
8383
}

stack_system.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func (s *System) tunLoop() {
174174
return
175175
}
176176
}
177-
if darwinTUN, isDarwinTUN := s.tun.(DarwinTUN); isDarwinTUN {
177+
if darwinTUN, isDarwinTUN := s.tun.(DarwinTUN); isDarwinTUN && s.mtu < 49152 {
178178
s.batchLoopDarwin(darwinTUN)
179179
return
180180
}

tun_darwin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ func (t *NativeTun) BatchRead() ([]*buf.Buffer, error) {
386386
func (t *NativeTun) BatchWrite(buffers []*buf.Buffer) error {
387387
for i, buffer := range buffers {
388388
iovecs := t.iovecsOutput[i].nextIovecsOutput(buffer)
389+
t.msgHdrsOutput[i] = rawfile.MsgHdrX{}
389390
t.msgHdrsOutput[i].Msg.Iov = &iovecs[0]
390391
t.msgHdrsOutput[i].Msg.Iovlen = 2
391392
}

tun_darwin_gvisor.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ func (t *NativeTun) NewEndpoint() (stack.LinkEndpoint, stack.NICOptions, error)
2020
if err != nil {
2121
return nil, stack.NICOptions{}, err
2222
}
23-
var nicOptions stack.NICOptions
24-
if t.options.MTU < 49152 {
25-
nicOptions.QDisc = fifo.New(ep, 1, 1000)
26-
}
27-
return ep, nicOptions, nil
23+
return ep, stack.NICOptions{
24+
QDisc: fifo.New(ep, 1, 1000),
25+
}, nil
2826
}

tun_linux_gvisor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import (
77
"github.com/sagernet/gvisor/pkg/tcpip/stack"
88
)
99

10+
func init() {
11+
fdbased.BufConfig = []int{65535}
12+
}
13+
1014
var _ GVisorTun = (*NativeTun)(nil)
1115

1216
func (t *NativeTun) NewEndpoint() (stack.LinkEndpoint, stack.NICOptions, error) {

0 commit comments

Comments
 (0)