mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
fix core_test.go and a race in setting/using mtu
This commit is contained in:
parent
cb81be94ec
commit
b34c3230f8
3 changed files with 33 additions and 13 deletions
|
@ -243,12 +243,15 @@ func (k *keyStore) readPC(p []byte) (int, error) {
|
|||
if len(bs) < 40 {
|
||||
continue
|
||||
}
|
||||
if len(bs) > int(k.mtu) {
|
||||
k.mutex.Lock()
|
||||
mtu := int(k.mtu)
|
||||
k.mutex.Unlock()
|
||||
if len(bs) > mtu {
|
||||
// Using bs would make it leak off the stack, so copy to buf
|
||||
buf := make([]byte, 40)
|
||||
copy(buf, bs)
|
||||
ptb := &icmp.PacketTooBig{
|
||||
MTU: int(k.mtu),
|
||||
MTU: mtu,
|
||||
Data: buf[:40],
|
||||
}
|
||||
if packet, err := CreateICMPv6(buf[8:24], buf[24:40], ipv6.ICMPTypePacketTooBig, 0, ptb); err == nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue