mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
NDP Neighbor Solicitations sent during DAD must have an IP hop limit of 255
NDP Neighbor Solicitations sent during Duplicate Address Detection must have an IP hop limit of 255, as all NDP Neighbor Solicitations should have. Test: Test that DAD messages have the IPv6 hop limit field set to 255. PiperOrigin-RevId: 275321680
This commit is contained in:
committed by
gVisor bot
parent
06ed9e329d
commit
962aa235de
@@ -80,6 +80,13 @@ const (
|
||||
// icmpv6SequenceOffset is the offset of the sequence field
|
||||
// in a ICMPv6 Echo Request/Reply message.
|
||||
icmpv6SequenceOffset = 6
|
||||
|
||||
// NDPHopLimit is the expected IP hop limit value of 255 for received
|
||||
// NDP packets, as per RFC 4861 sections 4.1 - 4.5, 6.1.1, 6.1.2, 7.1.1,
|
||||
// 7.1.2 and 8.1. If the hop limit value is not 255, nodes MUST silently
|
||||
// drop the NDP packet. All outgoing NDP packets must use this value for
|
||||
// its IP hop limit field.
|
||||
NDPHopLimit = 255
|
||||
)
|
||||
|
||||
// ICMPv6Type is the ICMP type field described in RFC 4443 and friends.
|
||||
|
||||
@@ -21,15 +21,6 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/tcpip/stack"
|
||||
)
|
||||
|
||||
const (
|
||||
// ndpHopLimit is the expected IP hop limit value of 255 for received
|
||||
// NDP packets, as per RFC 4861 sections 4.1 - 4.5, 6.1.1, 6.1.2, 7.1.1,
|
||||
// 7.1.2 and 8.1. If the hop limit value is not 255, nodes MUST silently
|
||||
// drop the NDP packet. All outgoing NDP packets must use this value for
|
||||
// its IP hop limit field.
|
||||
ndpHopLimit = 255
|
||||
)
|
||||
|
||||
// handleControl handles the case when an ICMP packet contains the headers of
|
||||
// the original packet that caused the ICMP one to be sent. This information is
|
||||
// used to find out which transport endpoint must be notified about the ICMP
|
||||
@@ -90,7 +81,7 @@ func (e *endpoint) handleICMP(r *stack.Route, netHeader buffer.View, vv buffer.V
|
||||
header.ICMPv6RouterSolicit,
|
||||
header.ICMPv6RouterAdvert,
|
||||
header.ICMPv6RedirectMsg:
|
||||
if iph.HopLimit() != ndpHopLimit {
|
||||
if iph.HopLimit() != header.NDPHopLimit {
|
||||
received.Invalid.Increment()
|
||||
return
|
||||
}
|
||||
@@ -217,7 +208,7 @@ func (e *endpoint) handleICMP(r *stack.Route, netHeader buffer.View, vv buffer.V
|
||||
//
|
||||
// The IP Hop Limit field has a value of 255, i.e., the packet
|
||||
// could not possibly have been forwarded by a router.
|
||||
if err := r.WritePacket(nil /* gso */, hdr, buffer.VectorisedView{}, stack.NetworkHeaderParams{Protocol: header.ICMPv6ProtocolNumber, TTL: ndpHopLimit, TOS: stack.DefaultTOS}); err != nil {
|
||||
if err := r.WritePacket(nil /* gso */, hdr, buffer.VectorisedView{}, stack.NetworkHeaderParams{Protocol: header.ICMPv6ProtocolNumber, TTL: header.NDPHopLimit, TOS: stack.DefaultTOS}); err != nil {
|
||||
sent.Dropped.Increment()
|
||||
return
|
||||
}
|
||||
@@ -359,7 +350,7 @@ func (*protocol) LinkAddressRequest(addr, localAddr tcpip.Address, linkEP stack.
|
||||
ip.Encode(&header.IPv6Fields{
|
||||
PayloadLength: length,
|
||||
NextHeader: uint8(header.ICMPv6ProtocolNumber),
|
||||
HopLimit: ndpHopLimit,
|
||||
HopLimit: header.NDPHopLimit,
|
||||
SrcAddr: r.LocalAddress,
|
||||
DstAddr: r.RemoteAddress,
|
||||
})
|
||||
|
||||
@@ -143,7 +143,7 @@ func TestICMPCounts(t *testing.T) {
|
||||
ip.Encode(&header.IPv6Fields{
|
||||
PayloadLength: uint16(payloadLength),
|
||||
NextHeader: uint8(header.ICMPv6ProtocolNumber),
|
||||
HopLimit: ndpHopLimit,
|
||||
HopLimit: header.NDPHopLimit,
|
||||
SrcAddr: r.LocalAddress,
|
||||
DstAddr: r.RemoteAddress,
|
||||
})
|
||||
|
||||
@@ -150,7 +150,7 @@ func TestHopLimitValidation(t *testing.T) {
|
||||
|
||||
// Receive the NDP packet with an invalid hop limit
|
||||
// value.
|
||||
handleIPv6Payload(hdr, ndpHopLimit-1, ep, &r)
|
||||
handleIPv6Payload(hdr, header.NDPHopLimit-1, ep, &r)
|
||||
|
||||
// Invalid count should have increased.
|
||||
if got := invalid.Value(); got != 1 {
|
||||
@@ -164,7 +164,7 @@ func TestHopLimitValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
// Receive the NDP packet with a valid hop limit value.
|
||||
handleIPv6Payload(hdr, ndpHopLimit, ep, &r)
|
||||
handleIPv6Payload(hdr, header.NDPHopLimit, ep, &r)
|
||||
|
||||
// Rx count of NDP packet of type typ.typ should have
|
||||
// increased.
|
||||
|
||||
@@ -239,7 +239,7 @@ func (ndp *ndpState) doDuplicateAddressDetection(n *NIC, addr tcpip.Address, rem
|
||||
pkt.SetChecksum(header.ICMPv6Checksum(pkt, r.LocalAddress, r.RemoteAddress, buffer.VectorisedView{}))
|
||||
|
||||
sent := r.Stats().ICMP.V6PacketsSent
|
||||
if err := r.WritePacket(nil, hdr, buffer.VectorisedView{}, NetworkHeaderParams{Protocol: header.ICMPv6ProtocolNumber, TTL: r.DefaultTTL(), TOS: DefaultTOS}); err != nil {
|
||||
if err := r.WritePacket(nil, hdr, buffer.VectorisedView{}, NetworkHeaderParams{Protocol: header.ICMPv6ProtocolNumber, TTL: header.NDPHopLimit, TOS: DefaultTOS}); err != nil {
|
||||
sent.Dropped.Increment()
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@ func TestDADResolve(t *testing.T) {
|
||||
|
||||
// Check NDP packet.
|
||||
checker.IPv6(t, p.Header.ToVectorisedView().First(),
|
||||
checker.TTL(header.NDPHopLimit),
|
||||
checker.NDPNS(
|
||||
checker.NDPNSTargetAddress(addr1)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user