Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xds: listener type validation #11933

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

shivaspeaks
Copy link
Member

Fixes #11737

@shivaspeaks shivaspeaks changed the title Listener type validation xds: listener type validation Mar 3, 2025
@shivaspeaks shivaspeaks requested a review from ejona86 March 3, 2025 15:25
@ejona86 ejona86 self-requested a review March 5, 2025 21:20
Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't mean to approve

@shivaspeaks shivaspeaks added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Mar 6, 2025
@grpc-kokoro grpc-kokoro removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Mar 6, 2025
@shivaspeaks shivaspeaks requested a review from ejona86 March 6, 2025 20:52
InetAddress listenerIp = InetAddresses.forString(listenerAddressHnP.getHost());
InetAddress ldsIp = InetAddresses.forString(ldsAddressHnP.getHost());

if (listenerIp.isAnyLocalAddress()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said before, remove the wildcard handling. IPv4 and IPv6 wildcards behave differently, and you aren't checking the port here. And if we need to be comparing wildcards, we would really need to spell out how that is done in the gRFC to be consistent cross-language.

return;
}

String ldsAddress = update.listener().address();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my education: what would be the "best/most appropriate" behaviour if the String ldsAddress is the empty string or null?

Currently, if ldsAddress is null, we skip ipAddressesMatch entirely and proceed with the remaining logic. Would this still be fine?

Likewise, if ldsAddress is the empty string, we check ipAddressesMatch, AFAIK, this would throw an exception and would this be fine? HostAndPort.fromString would return a HostAndPort(host="", port=-1, hasBracketlessColons=false) then InetAddresses.forString would throw an IllegalArgumentException

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. Good point. I couldn't find any mention about this case in gRFC A36.

@Override
public void onResourceDoesNotExist(final String resourceName) {
if (stopped) {
return;
}
StatusException statusException = Status.UNAVAILABLE.withDescription(
String.format("Listener %s unavailable, xDS node ID: %s", resourceName,
String.format("%s listener unavailable, xDS node ID: %s", resourceName,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: what would be the reason to switch the order of the error format here? I think Listener %s is slightly more common in the code base. Consistent formatting helps with searching when debugging issues.

@shivaspeaks shivaspeaks requested a review from ejona86 March 7, 2025 18:34
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.

XdsNameResolver and XdsServerWrapper don't check listener type
4 participants