mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-05 07:50:24 +08:00
fix: MTU in sendAllSameDst
This commit is contained in:
@@ -176,9 +176,14 @@ func (m *Me) sendAllSameDst(packet []byte) (n int) {
|
||||
for len(ptr) > 20 && p.issame(ptr) {
|
||||
totl := waterutil.IPv4TotalLength(ptr)
|
||||
if int(totl) > len(ptr) {
|
||||
logrus.Debugln("[me] wrap got invalid totl, break")
|
||||
break
|
||||
}
|
||||
i += int(totl)
|
||||
if i > int(m.mtu) {
|
||||
logrus.Debugln("[me] wrap exceed mtu, break")
|
||||
break
|
||||
}
|
||||
ptr = rem[i:]
|
||||
logrus.Debugln("[me] wrap", totl, "bytes packet to send together")
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ import (
|
||||
func (l *Link) WriteAndPut(p *head.Packet, istransfer bool) (n int, err error) {
|
||||
teatype := uint8(rand.Intn(16))
|
||||
sndcnt := atomic.AddUintptr(&l.sendcount, 1)
|
||||
logrus.Debugln("[send] count:", sndcnt, ", additional data:", uint16(sndcnt))
|
||||
mtu := l.mtu
|
||||
if l.mturandomrange > 0 {
|
||||
mtu -= uint16(rand.Intn(int(l.mturandomrange))) & 0xfff8
|
||||
}
|
||||
logrus.Debugln("[send] mtu:", mtu, ", count:", sndcnt, ", additional data:", uint16(sndcnt))
|
||||
if len(p.Data) <= int(mtu) {
|
||||
if !istransfer {
|
||||
p.FillHash()
|
||||
@@ -44,7 +44,7 @@ func (l *Link) WriteAndPut(p *head.Packet, istransfer bool) (n int, err error) {
|
||||
packet := head.SelectPacket()
|
||||
*packet = *p
|
||||
for ; int(totl)-i > int(mtu); i += int(mtu) {
|
||||
logrus.Debugln("[send] split frag", i, ":", i+int(mtu), ", remain:", int(totl)-i-int(mtu))
|
||||
logrus.Debugln("[send] split frag [", i, "~", i+int(mtu), "], remain:", int(totl)-i-int(mtu))
|
||||
packet.Data = data[:int(mtu)]
|
||||
cnt, err := l.write(packet, teatype, uint16(sndcnt), mtu, totl, uint16(i>>3), istransfer, true)
|
||||
n += cnt
|
||||
|
||||
Reference in New Issue
Block a user