From ec8763d5b18eb94737bfe46d8765683be412488b Mon Sep 17 00:00:00 2001 From: Ievgen Bondarenko Date: Fri, 22 May 2026 10:53:53 -0700 Subject: [PATCH] tcpip/ipv6: use isEnabled() in disableLocked() to match ipv4 sibling ### Summary Swap `e.Enabled()` for `e.isEnabled()` in `(*endpoint).disableLocked()` at `pkg/tcpip/network/ipv6/ipv6.go`. The IPv4 sibling at `pkg/tcpip/network/ipv4/ipv4.go:363` already uses `e.isEnabled()`. ### Why `e.Enabled()` returns `e.nic.Enabled() && e.isEnabled()`. If the NIC has been disabled but the endpoint's own `isEnabled()` is still set, the current code early-returns from `disableLocked` and skips the full per-protocol teardown: `ndp.stopSolicitingRouters`, `ndp.cleanupState`, MLD `softLeaveAll`, DAD stop, the all-nodes multicast leave, and `setEnabled(false)`. After the early-return, `e.isEnabled()` still reports true. A subsequent `endpoint.Close()` calls `disableLocked` again, hits the same early-return, then runs `addressableEndpointState.Cleanup` while NDP state and any still-armed SLAAC, RS, or DAD timer remain alive against the wiped address state. IPv4 at `ipv4.go:363` uses `e.isEnabled()` and runs the local teardown regardless of the NIC's state. The 2020 commit 53a95ad0df that introduced the `e.Enabled()` form was about gating packet-sending paths during shutdown; the disable path itself should not be one of those gated sites. ### Test - `bazel test //pkg/tcpip/network/ipv6/... //pkg/tcpip/tests/integration/...` The intent of the original 2020 commit (gating packet-sending paths during shutdown) is preserved at the packet sites that still call `e.Enabled()`; only `disableLocked` is changed to match IPv4. ### CLA Signed via individual Google CLA on `sactransport2000@gmail.com`. FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/13214 from ibondarenko1:tcpip-ipv6-disablelocked-isenabled 818274a6e981bb62199c5fae68f46b73c8cb1796 PiperOrigin-RevId: 919758320 --- pkg/tcpip/network/ipv6/ipv6.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/tcpip/network/ipv6/ipv6.go b/pkg/tcpip/network/ipv6/ipv6.go index 57648cf86e..f4876561c0 100644 --- a/pkg/tcpip/network/ipv6/ipv6.go +++ b/pkg/tcpip/network/ipv6/ipv6.go @@ -672,7 +672,7 @@ func (e *endpoint) Disable() { } func (e *endpoint) disableLocked() { - if !e.Enabled() { + if !e.isEnabled() { return }