diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-01-28 22:05:10 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-28 22:05:10 +0000 |
commit | d8bffe2f488b3841469ec8a51393f32b9da3438b (patch) | |
tree | cb17082abc90020d435e415988d468fbbbef1930 /pkg/tcpip/stack | |
parent | 0e3ddb2aa6f7cd971510dcdd09ae4d3dc8d849cf (diff) | |
parent | ce0bac4be9d808877248c328fac07ff0d66b9607 (diff) |
Merge release-20200115.0-123-gce0bac4 (automated)
Diffstat (limited to 'pkg/tcpip/stack')
-rwxr-xr-x | pkg/tcpip/stack/ndp.go | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/pkg/tcpip/stack/ndp.go b/pkg/tcpip/stack/ndp.go index d983ac390..245694118 100755 --- a/pkg/tcpip/stack/ndp.go +++ b/pkg/tcpip/stack/ndp.go @@ -538,11 +538,29 @@ func (ndp *ndpState) sendDADPacket(addr tcpip.Address) *tcpip.Error { r := makeRoute(header.IPv6ProtocolNumber, header.IPv6Any, snmc, ndp.nic.linkEP.LinkAddress(), ref, false, false) defer r.Release() - hdr := buffer.NewPrependable(int(r.MaxHeaderLength()) + header.ICMPv6NeighborSolicitMinimumSize) - pkt := header.ICMPv6(hdr.Prepend(header.ICMPv6NeighborSolicitMinimumSize)) + linkAddr := ndp.nic.linkEP.LinkAddress() + isValidLinkAddr := header.IsValidUnicastEthernetAddress(linkAddr) + ndpNSSize := header.ICMPv6NeighborSolicitMinimumSize + if isValidLinkAddr { + // Only include a Source Link Layer Address option if the NIC has a valid + // link layer address. + // + // TODO(b/141011931): Validate a LinkEndpoint's link address (provided by + // LinkEndpoint.LinkAddress) before reaching this point. + ndpNSSize += header.NDPLinkLayerAddressSize + } + + hdr := buffer.NewPrependable(int(r.MaxHeaderLength()) + ndpNSSize) + pkt := header.ICMPv6(hdr.Prepend(ndpNSSize)) pkt.SetType(header.ICMPv6NeighborSolicit) ns := header.NDPNeighborSolicit(pkt.NDPPayload()) ns.SetTargetAddress(addr) + + if isValidLinkAddr { + ns.Options().Serialize(header.NDPOptionsSerializer{ + header.NDPSourceLinkLayerAddressOption(linkAddr), + }) + } pkt.SetChecksum(header.ICMPv6Checksum(pkt, r.LocalAddress, r.RemoteAddress, buffer.VectorisedView{})) sent := r.Stats().ICMP.V6PacketsSent |