Fix gVisor process
This commit is contained in:
parent
46aa536b37
commit
c569e3e92f
5 changed files with 22 additions and 19 deletions
|
|
@ -38,7 +38,7 @@ func NewUDPForwarder(ctx context.Context, stack *stack.Stack, handler Handler, t
|
||||||
stack: stack,
|
stack: stack,
|
||||||
handler: handler,
|
handler: handler,
|
||||||
}
|
}
|
||||||
forwarder.udpNat = udpnat.New(handler, forwarder.PreparePacketConnection, timeout, true)
|
forwarder.udpNat = udpnat.New(handler, forwarder.PreparePacketConnection, timeout, false)
|
||||||
return forwarder
|
return forwarder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ func (m *Mixed) wintunLoop(winTun WinTun) {
|
||||||
|
|
||||||
func (m *Mixed) batchLoopLinux(linuxTUN LinuxTUN, batchSize int) {
|
func (m *Mixed) batchLoopLinux(linuxTUN LinuxTUN, batchSize int) {
|
||||||
packetBuffers := make([][]byte, batchSize)
|
packetBuffers := make([][]byte, batchSize)
|
||||||
writeBuffers := make([][]byte, batchSize)
|
writeBuffers := make([][]byte, 0, batchSize)
|
||||||
packetSizes := make([]int, batchSize)
|
packetSizes := make([]int, batchSize)
|
||||||
for i := range packetBuffers {
|
for i := range packetBuffers {
|
||||||
packetBuffers[i] = make([]byte, m.mtu+PacketOffset+m.frontHeadroom)
|
packetBuffers[i] = make([]byte, m.mtu+PacketOffset+m.frontHeadroom)
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,7 @@ func (s *System) wintunLoop(winTun WinTun) {
|
||||||
|
|
||||||
func (s *System) batchLoopLinux(linuxTUN LinuxTUN, batchSize int) {
|
func (s *System) batchLoopLinux(linuxTUN LinuxTUN, batchSize int) {
|
||||||
packetBuffers := make([][]byte, batchSize)
|
packetBuffers := make([][]byte, batchSize)
|
||||||
writeBuffers := make([][]byte, batchSize)
|
writeBuffers := make([][]byte, 0, batchSize)
|
||||||
packetSizes := make([]int, batchSize)
|
packetSizes := make([]int, batchSize)
|
||||||
for i := range packetBuffers {
|
for i := range packetBuffers {
|
||||||
packetBuffers[i] = make([]byte, s.mtu+s.frontHeadroom)
|
packetBuffers[i] = make([]byte, s.mtu+s.frontHeadroom)
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,13 @@ func (t *NativeTun) WritePacket(pkt *stack.PacketBuffer) (int, error) {
|
||||||
|
|
||||||
func (t *NativeTun) NewEndpoint() (stack.LinkEndpoint, stack.NICOptions, error) {
|
func (t *NativeTun) NewEndpoint() (stack.LinkEndpoint, stack.NICOptions, error) {
|
||||||
ep, err := fdbased.New(&fdbased.Options{
|
ep, err := fdbased.New(&fdbased.Options{
|
||||||
FDs: []int{t.tunFd},
|
FDs: []int{t.tunFd},
|
||||||
MTU: t.options.MTU,
|
MTU: t.options.MTU,
|
||||||
RXChecksumOffload: true,
|
ProcessorsPerChannel: 1,
|
||||||
PacketDispatchMode: fdbased.RecvMMsg,
|
RXChecksumOffload: true,
|
||||||
MultiPendingPackets: t.options.EXP_MultiPendingPackets,
|
PacketDispatchMode: fdbased.RecvMMsg,
|
||||||
SendMsgX: t.options.EXP_SendMsgX,
|
MultiPendingPackets: t.options.EXP_MultiPendingPackets,
|
||||||
|
SendMsgX: t.options.EXP_SendMsgX,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, stack.NICOptions{}, err
|
return nil, stack.NICOptions{}, err
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,13 @@ func (t *NativeTun) WritePacket(pkt *stack.PacketBuffer) (int, error) {
|
||||||
func (t *NativeTun) NewEndpoint() (stack.LinkEndpoint, stack.NICOptions, error) {
|
func (t *NativeTun) NewEndpoint() (stack.LinkEndpoint, stack.NICOptions, error) {
|
||||||
if t.vnetHdr {
|
if t.vnetHdr {
|
||||||
ep, err := fdbased.New(&fdbased.Options{
|
ep, err := fdbased.New(&fdbased.Options{
|
||||||
FDs: []int{t.tunFd},
|
FDs: []int{t.tunFd},
|
||||||
MTU: t.options.MTU,
|
MTU: t.options.MTU,
|
||||||
GSOMaxSize: gsoMaxSize,
|
ProcessorsPerChannel: 1,
|
||||||
GRO: true,
|
GSOMaxSize: gsoMaxSize,
|
||||||
RXChecksumOffload: true,
|
GRO: true,
|
||||||
TXChecksumOffload: t.txChecksumOffload,
|
RXChecksumOffload: true,
|
||||||
|
TXChecksumOffload: t.txChecksumOffload,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, stack.NICOptions{}, err
|
return nil, stack.NICOptions{}, err
|
||||||
|
|
@ -87,10 +88,11 @@ func (t *NativeTun) NewEndpoint() (stack.LinkEndpoint, stack.NICOptions, error)
|
||||||
return ep, stack.NICOptions{}, nil
|
return ep, stack.NICOptions{}, nil
|
||||||
} else {
|
} else {
|
||||||
ep, err := fdbased.New(&fdbased.Options{
|
ep, err := fdbased.New(&fdbased.Options{
|
||||||
FDs: []int{t.tunFd},
|
FDs: []int{t.tunFd},
|
||||||
MTU: t.options.MTU,
|
MTU: t.options.MTU,
|
||||||
RXChecksumOffload: true,
|
ProcessorsPerChannel: 1,
|
||||||
TXChecksumOffload: t.txChecksumOffload,
|
RXChecksumOffload: true,
|
||||||
|
TXChecksumOffload: t.txChecksumOffload,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, stack.NICOptions{}, err
|
return nil, stack.NICOptions{}, err
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue