Skip to content

tcpip/ipv6: use isEnabled() in disableLocked() to match ipv4 sibling#13214

Open
ibondarenko1 wants to merge 1 commit into
google:masterfrom
ibondarenko1:tcpip-ipv6-disablelocked-isenabled
Open

tcpip/ipv6: use isEnabled() in disableLocked() to match ipv4 sibling#13214
ibondarenko1 wants to merge 1 commit into
google:masterfrom
ibondarenko1:tcpip-ipv6-disablelocked-isenabled

Conversation

@ibondarenko1
Copy link
Copy Markdown

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 53a95ad 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.

The IPv4 (*endpoint).disableLocked at pkg/tcpip/network/ipv4/ipv4.go:363
early-returns on !e.isEnabled(). The IPv6 sibling at
pkg/tcpip/network/ipv6/ipv6.go:675 early-returns on !e.Enabled(), and
e.Enabled() folds in e.nic.Enabled(). When the NIC has been disabled
independently but the endpoint's local enabled flag is still set, the
IPv6 path skips ndp.stopSolicitingRouters, ndp.cleanupState, MLD
softLeaveAll, DAD stop, the all-nodes multicast leave, and the final
setEnabled(false). After 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.

The 2020 commit 53a95ad introduced e.Enabled() for packet-sending
sites that need to honor both nic and endpoint flags. The disable path
should not gate on nic state; it should run the local teardown
regardless and let the per-protocol state machine reach a clean stop.
IPv4 already gets this right. Mirror the IPv4 form.

Signed-off-by: Ievgen Bondarenko <sactransport2000@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants