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

fix: correctly handle dns messages in our dns implementation #8768

Merged
merged 1 commit into from
May 24, 2024

Conversation

DmitriyMV
Copy link
Member

@DmitriyMV DmitriyMV commented May 20, 2024

  • By default, github.com/miekg/dns uses dns.MinMsgSize for UDP messages, which is 512 bytes. This is too small for some DNS request/responses, and can cause truncation and errors. This change sets the buffer size to dns.DefaultMsgSize
    4096 bytes, which is the maximum size of a dns packet payload per RFC 6891.
  • We also retry the request if the response is truncated or previous connection was closed.
  • And finally we properly handle the case where the response is larger than the client buffer size,
    and we return a truncated correct response.

Closes #8763

@frezbo
Copy link
Member

frezbo commented May 20, 2024

I wonder if we can add some tests too

@DmitriyMV
Copy link
Member Author

DmitriyMV commented May 20, 2024

Tests are incoming.

@DmitriyMV DmitriyMV force-pushed the dns-buffer-size branch 3 times, most recently from d4b4344 to ba5ef97 Compare May 23, 2024 17:34
- By default, github.com/miekg/dns uses `dns.MinMsgSize` for UDP messages, which is 512 bytes. This is too small for some
DNS request/responses, and can cause truncation and errors. This change sets the buffer size to `dns.DefaultMsgSize`
4096 bytes, which is the maximum size of a dns packet payload per RFC 6891.
- We also retry the request if the response is truncated or previous connection was closed.
- And finally we properly handle the case where the response is larger than the client buffer size,
and we return a truncated correct response.

Closes siderolabs#8763

Signed-off-by: Dmitriy Matrenichev <[email protected]>
@DmitriyMV
Copy link
Member Author

/m

@talos-bot talos-bot merged commit a9cf9b7 into siderolabs:main May 24, 2024
46 checks passed
@DmitriyMV DmitriyMV deleted the dns-buffer-size branch May 24, 2024 20:14
@smira smira mentioned this pull request May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backported
Development

Successfully merging this pull request may close these issues.

Errors on resolution of long domain names with forwardKubeDNSToHost
4 participants