mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 14:45:07 +03:00
Fix too many segments
read error
This commit is contained in:
parent
115d8a3b9d
commit
36e68317d4
2 changed files with 2 additions and 10 deletions
|
@ -1,17 +1,9 @@
|
||||||
package tun
|
package tun
|
||||||
|
|
||||||
const TUN_OFFSET_BYTES = 80 // sizeof(virtio_net_hdr)
|
const TUN_OFFSET_BYTES = 80 // sizeof(virtio_net_hdr)
|
||||||
const TUN_MAX_VECTOR = 16
|
|
||||||
|
|
||||||
func (tun *TunAdapter) idealBatchSize() int {
|
|
||||||
if b := tun.iface.BatchSize(); b <= TUN_MAX_VECTOR {
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
return TUN_MAX_VECTOR
|
|
||||||
}
|
|
||||||
|
|
||||||
func (tun *TunAdapter) read() {
|
func (tun *TunAdapter) read() {
|
||||||
vs := tun.idealBatchSize()
|
vs := tun.iface.BatchSize()
|
||||||
bufs := make([][]byte, vs)
|
bufs := make([][]byte, vs)
|
||||||
sizes := make([]int, vs)
|
sizes := make([]int, vs)
|
||||||
for i := range bufs {
|
for i := range bufs {
|
||||||
|
|
|
@ -162,7 +162,7 @@ func (tun *TunAdapter) _start() error {
|
||||||
tun.rwc.SetMTU(tun.MTU())
|
tun.rwc.SetMTU(tun.MTU())
|
||||||
tun.isOpen = true
|
tun.isOpen = true
|
||||||
tun.isEnabled = true
|
tun.isEnabled = true
|
||||||
tun.ch = make(chan []byte, tun.idealBatchSize())
|
tun.ch = make(chan []byte, tun.iface.BatchSize())
|
||||||
go tun.queue()
|
go tun.queue()
|
||||||
go tun.read()
|
go tun.read()
|
||||||
go tun.write()
|
go tun.write()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue