5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-21 21:50:29 +00:00

Merge pull request #286 from neilalexander/fixndp

Fix ICMPv6 behaviour when populating peermacs
This commit is contained in:
Neil Alexander 2018-12-26 12:29:16 +00:00 committed by GitHub
commit a8e6b864fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,14 +175,17 @@ func (i *icmpv6) parse_packet_tun(datain []byte, datamac *[]byte) ([]byte, error
case ipv6.ICMPTypeNeighborAdvertisement: case ipv6.ICMPTypeNeighborAdvertisement:
if datamac != nil { if datamac != nil {
var addr address.Address var addr address.Address
var target address.Address
var mac macAddress var mac macAddress
copy(addr[:], ipv6Header.Src[:]) copy(addr[:], ipv6Header.Src[:])
copy(target[:], datain[48:64])
copy(mac[:], (*datamac)[:]) copy(mac[:], (*datamac)[:])
neighbor := i.peermacs[addr] // i.tun.core.log.Printf("Learning peer MAC %x for %x\n", mac, target)
neighbor := i.peermacs[target]
neighbor.mac = mac neighbor.mac = mac
neighbor.learned = true neighbor.learned = true
neighbor.lastadvertisement = time.Now() neighbor.lastadvertisement = time.Now()
i.peermacs[addr] = neighbor i.peermacs[target] = neighbor
} }
return nil, errors.New("No response needed") return nil, errors.New("No response needed")
} }