-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
net: dns: Fix DNS dispatcher for multiple network interfaces #79588
base: main
Are you sure you want to change the base?
net: dns: Fix DNS dispatcher for multiple network interfaces #79588
Conversation
09f16b0
to
4a1491b
Compare
When having multiple interfaces the dns dispatcher falsely flags interfaces with the same port and address_family as duplicates. This leads to problems when for example using MDNS. Signed-off-by: Carlo Kirchmeier <carlo.kirchmeier@zuehlke.com> Co-authored-by: Nils Ruf <nils.ruf@endress.com>
4a1491b
to
7e586e2
Compare
net_sin(&ctx->local_addr)->sin_port) { | ||
dup = true; | ||
continue; | ||
if (ctx->sock == entry->sock) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't explicit check for socket FD make other checks kind of pointless? It's not that you can have a socket that is bound to two different ports...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably check the addresses instead of socket descriptor values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this also be called for interfaces that are down
or have no address assigned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we would compare
net_sin(&ctx->local_addr)->sin_addr.s_addr == net_sin(&entry->local_addr)->sin_addr.s_addr
as well as theport
right? And since no two interfaces should have the same IP assigned this would also solve the issue.
It needs to be a bit more complicated as IPv6 needs to be checked too. Your example address check only validates IPv4 address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this also be called for interfaces that are
down
or have no address assigned?
Please elaborate what you mean, I do not understand your question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this also be called for interfaces that are
down
or have no address assigned?Please elaborate what you mean, I do not understand your question.
^ was a misconception of mine and can be ignored
But as far as i can see in the MDNS responder the function register_dispatcher
and subsequently dns_dispatcher_register
is called for each interface twice (once IPv4 and IPv6) and the local_addr is the same for both interfaces since it is the multicast 224.0.0.251
respectively ff02::fb
. So both interfaces would have the same IP during the dispatch_register and the comparison would detect a false duplicate again right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, the addresses would be the same in this case.
Hmm, I am trying to understand the actual issue. So you see the problem when having two network interfaces, what exactly is printed (if you enable debugging) error / warning etc. in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In short: The second interface was detected as a duplicate by the dispatcher since it had the same address family and port as the first interface (due to MDNS multicast).
@NilsRuf-EH as I will be absent the next few days could you have a look again at what the log output was in detail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have ports and family the same, then to separate them, the network interface is the only left thing that we can use.
When having multiple interfaces the dns dispatcher falsely flags interfaces with the same port and address_family as duplicates. This leads to problems when for example using MDNS.
@NilsRuf-EH thanks for pointing that out.