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

c-ares: add option for udp_max_queries #33551

Merged
merged 14 commits into from
Apr 29, 2024

Conversation

deveshkandpal1224
Copy link
Contributor

@deveshkandpal1224 deveshkandpal1224 commented Apr 16, 2024

Commit Message: Provides an option to set udp_max_queries in DNSResolverOptions to limit max UDP queries.
Additional Description: This change does following:

  • Implements the fix in this version of c-ares library that has been raised in this comment.
  • Updates cares_dns_resolver.proto to expose the option to pass udp_max_queries which can then be passed to c-ares.
  • Adds a unit test to validate that when udp_max_queries is set, ARES_OPT_UDP_MAX_QUERIES flag is set as well.

Risk Level: Low
Testing: Unit test
Docs Changes: n/a
Release Notes: updated
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
@repokitteh-read-only repokitteh-read-only bot added api deps Approval required for changes to Envoy's external dependencies labels Apr 16, 2024
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @lizan
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).
CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @htuch

🐱

Caused by: #33551 was opened by deveshkandpal1224.

see: more, trace.

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
@adisuissa
Copy link
Contributor

@yanjunxiang-google can you please take a first pass?

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
@@ -194,7 +202,7 @@ void DnsResolverImpl::AddrInfoPendingResolution::onAresGetAddrInfoCallback(
//
// The channel cannot be destroyed and reinitialized here because that leads to a c-ares
// segfault.
if (status == ARES_ECONNREFUSED) {
if (status == ARES_ECONNREFUSED || status == ARES_EREFUSED) {
Copy link
Contributor

@yanjunxiang-google yanjunxiang-google Apr 16, 2024

Choose a reason for hiding this comment

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

nit: This change is for updating c-ares library to 1.20, but have nothing to do with the udp_max_queries option support. Does it make sense to separate it?

Copy link
Contributor Author

@deveshkandpal1224 deveshkandpal1224 Apr 16, 2024

Choose a reason for hiding this comment

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

DestroyChannelOnRefused and CustomResolverValidAfterChannelDestruction test fail in dns_impl_test.cc after upgrading the c-ares library to 1.20 if this isn't added, while udp_max_queries is supported in 1.20 so kind of tied together if that makes sense ? Or do you suggest splitting this into 2 PRs ?

Copy link
Member

Choose a reason for hiding this comment

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

Can you split into two PRs? It will make it easier to review the dependency updates vs. the UDP query specific change proposed. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure I can split it. Let me send out a PR for library update.

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>

// Validate that c_ares flag `ARES_OPT_UDP_MAX_QUERIES` is set when UInt32 property
// `udp_max_queries` is set.
TEST_P(DnsImplAresFlagsForMaxUdpQueriesinTest, UdpMaxQueriesIsSet) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:
Is there a way to verify the UdpMaxQueries number actually is enforced by the c-ares library?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yanjunxiang-google - do you mean by checking opts.udp_max_queries or something more involved ? I tried poking in that area but couldn't find anything obvious - if you have suggestions - happy to look into it!

Copy link

@rakeshdatta rakeshdatta Apr 18, 2024

Choose a reason for hiding this comment

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

I was pushing c'ares team for this change : c-ares/c-ares#444

I believe you can test like this:

  • set this value as n
  • keep pumping traffic.
  • Dont turn on dns over tcp
  • Sniffing ('ngrep -W single -l -q -d any -i "" udp port 53') the DNS packets
  • The src port should keep changing after every n DNS resolution requests.

Copy link
Contributor

Choose a reason for hiding this comment

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

This change should be ok as is, since we rely on c-ares to test the behavior of the ARES_OPT_UDP_MAX_QUERIES flag. I do not think it is important to validate that this flag is working in c-ares.

@yanjunxiang-google
Copy link
Contributor

LGTM in high level except a few nit comments.

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
@yanjunxiang-google
Copy link
Contributor

LGTM

@lizan
Copy link
Member

lizan commented Apr 18, 2024

/lgtm api

@yanavlasov for cares DNS resolver owner.

@lizan lizan assigned yanavlasov and unassigned lizan Apr 18, 2024
Copy link

@rakeshdatta rakeshdatta left a comment

Choose a reason for hiding this comment

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

I was pushing c'ares team for this change : c-ares/c-ares#444

I believe you can test like this:

  • set this value as n
  • keep pumping traffic.
  • Dont turn on dns over tcp
  • Sniffing ('ngrep -W single -l -q -d any -i "" udp port 53') the DNS packets

The src port should keep changing after every n DNS resolution requests.

Copy link
Contributor

@yanavlasov yanavlasov left a comment

Choose a reason for hiding this comment

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

/wait-any


// This option allows for number of UDP based DNS queries to be capped. Note, this
// is only applicable to c-ares DNS resolver currently.
google.protobuf.UInt32Value udp_max_queries = 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was in two minds thinking that if tomorrow there was an option for apple dns resolver, it could be leveraged. But happy to move this to c-ares if that makes more sense.

Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
Signed-off-by: deveshkandpal1224 <deveshkandpal1224@gmail.com>
@yanavlasov yanavlasov merged commit 048d9a2 into envoyproxy:main Apr 29, 2024
52 of 53 checks passed
@deveshkandpal1224 deveshkandpal1224 deleted the devesh24/upgrade-c-ares branch April 29, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api deps Approval required for changes to Envoy's external dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants