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

=act Stash dns query if there is a collision. #379

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

He-Pin
Copy link
Member

@He-Pin He-Pin commented Jun 9, 2023

If there is already an onging query with same id, stash the query, otherwise send it directly.
When receive a response, unstash all and process.

refs: akka/akka#31905

Modification:

  1. stash the query if there is a collision and unstash after response received.
  2. check the response references questions, if not match the previous question, just drop it.
  3. response directly when possible.

@pjfanning
Copy link
Contributor

Generally, this looks ok to me. I'd like to have some more eyes on this change before we merge it.

@pjfanning
Copy link
Contributor

pjfanning commented Jun 10, 2023

@He-Pin would it be possible to add a test or 2 to this PR - for regression testing but also I think a test might make it clearer what this PR is fixing?

Could you also provide the link to the Akka issue - or a Pekko issue - that describes the problem? I'm pretty sure I've seen the related Akka but I can't find it today.

@pjfanning
Copy link
Contributor

@He-Pin did you see the comment in #371 (comment) about 'To protect DNS poisoning you should also add a check to the response handler in DnsClient to ensure the question in the response matches the question asked.' - fyi @IainHull

I don't know if that is something that should be done in addition to this change or instead of this change. It seems useful to have both.

Signed-off-by: He-Pin <hepin1989@gmail.com>
}
replyTo ! response
inflightRequests -= response.id
unstashAll()
Copy link
Member Author

Choose a reason for hiding this comment

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

response directly here

if (questions.head != previousQuestion.head) {
log.warning(
"Dns response referenced to different question:{} expected:{} for id:{},maybe an error.",
questions.head, previousQuestion.head, id)
Copy link
Member Author

@He-Pin He-Pin Jun 10, 2023

Choose a reason for hiding this comment

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

Check the question in the response.

This is a behavior change, it doesn't check before.

@He-Pin
Copy link
Member Author

He-Pin commented Jun 10, 2023

@pjfanning @mdedetrich I have updated the PR ,with additional checking,

@pjfanning pjfanning added the async-dns-resolver Track issues in AsyncDnsResolver and related classes label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async-dns-resolver Track issues in AsyncDnsResolver and related classes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants