From e91eeea83f9017590b9e6f6774f7c6008af534ac Mon Sep 17 00:00:00 2001 From: Christopher Koch Date: Thu, 6 Jul 2023 16:55:36 -0700 Subject: [PATCH] Allow SLAAC to work without requiring an NDP dispatcher. Before this change, a non-nil NDPDisp was required to make AutoGenLinkLocal (i.e. SLAAC) work in netstack. PiperOrigin-RevId: 546128157 --- pkg/tcpip/network/ipv6/ndp.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/tcpip/network/ipv6/ndp.go b/pkg/tcpip/network/ipv6/ndp.go index 25c445769..b6391516a 100644 --- a/pkg/tcpip/network/ipv6/ndp.go +++ b/pkg/tcpip/network/ipv6/ndp.go @@ -1140,12 +1140,6 @@ func (ndp *ndpState) doSLAAC(prefix tcpip.Subnet, pl, vl time.Duration) { // // The IPv6 endpoint that ndp belongs to MUST be locked. func (ndp *ndpState) addAndAcquireSLAACAddr(addr tcpip.AddressWithPrefix, temporary bool, lifetimes stack.AddressLifetimes) stack.AddressEndpoint { - // Inform the integrator that we have a new SLAAC address. - ndpDisp := ndp.ep.protocol.options.NDPDisp - if ndpDisp == nil { - return nil - } - addressEndpoint, err := ndp.ep.addAndAcquirePermanentAddressLocked(addr, stack.AddressProperties{ PEB: stack.FirstPrimaryEndpoint, ConfigType: stack.AddressConfigSlaac, @@ -1156,8 +1150,11 @@ func (ndp *ndpState) addAndAcquireSLAACAddr(addr tcpip.AddressWithPrefix, tempor panic(fmt.Sprintf("ndp: error when adding SLAAC address %+v: %s", addr, err)) } - if disp := ndpDisp.OnAutoGenAddress(ndp.ep.nic.ID(), addr); disp != nil { - addressEndpoint.RegisterDispatcher(disp) + // Inform the integrator that we have a new SLAAC address. + if ndpDisp := ndp.ep.protocol.options.NDPDisp; ndpDisp != nil { + if disp := ndpDisp.OnAutoGenAddress(ndp.ep.nic.ID(), addr); disp != nil { + addressEndpoint.RegisterDispatcher(disp) + } } return addressEndpoint