fix(nacos): correct network interface filter logic in InetIPv6Utils#4355
Open
DanielWu-star wants to merge 1 commit into
Open
fix(nacos): correct network interface filter logic in InetIPv6Utils#4355DanielWu-star wants to merge 1 commit into
DanielWu-star wants to merge 1 commit into
Conversation
The network interface filter condition in findFirstValidIPv6Address() incorrectly used OR (||) operators instead of AND (&&) operators. Current behavior: if (ifc.isUp() || !ifc.isVirtual() || !ifc.isLoopback()) This means any interface that is UP, OR non-virtual, OR non-loopback would pass the filter, which allows DOWN/virtual/loopback interfaces to be incorrectly selected. Expected behavior: if (ifc.isUp() && !ifc.isVirtual() && !ifc.isLoopback()) The interface should only be selected when ALL conditions are met: it is UP, NOT virtual, AND NOT a loopback interface.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
The current IPv6 interface filtering logic in
findFirstValidIPv6Address()uses:This condition evaluates to
truefor most network interfaces, including interfaces that are down, virtual, or loopback.As a result, the filtering logic appears to be much less restrictive than intended when selecting a valid IPv6 address.
This PR refines the interface filtering condition to only consider active, non-virtual, and non-loopback interfaces during IPv6 address discovery.
Does this pull request fix one issue?
Fix #4354
Describe how you did it
Replaced:
with:
This aligns the interface filtering behavior with the method's purpose of discovering a valid IPv6 address from usable network interfaces.
Describe how to verify it
Special notes for reviews
This change was proposed based on the discussion in #4354.
If the current behavior is intentional, please let me know and I can further investigate the original design rationale.