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

avahi-daemon rejects response packet if it contains the original question record #348

Open
avillacis opened this issue Jul 15, 2021 · 2 comments
Labels

Comments

@avillacis
Copy link

Version: avahi-0.8-9.fc34.x86_64 on Fedora 34 x86_64

If a MDNS response packet received through port 5353 contains the original MDNS question record, avahi-daemon rejects further processing and logs "Invalid response packet from host ..." if running in verbose mode. Even if the response packet contains a valid answer record in addition to the question record.

I consider this behavior to be incorrect and needlessly strict. For reference, this is the relevant section from RFC 6762 section 6. Responding:

Multicast DNS responses MUST NOT contain any questions in the
Question Section. Any questions in the Question Section of a
received Multicast DNS response MUST be silently ignored.
Multicast
DNS queriers receiving Multicast DNS responses do not care what
question elicited the response; they care only that the information
in the response is true and accurate.

I take this to mean that whether the response contains an echoed question record should be irrelevant to whether the rest of the packet is taken as valid or not. So, if the packet contains a response to an actual issued query, any echoed question in the packet should be ignored and the packet should be considered valid.

I regularly work with ESP32 microcontrollers which use the Espressif MDNS implementation. The Espressif MDNS implementation echoes the question in the response packet. This causes the .local name previously broadcasted by the device to be no longer useful for locating the device in the network, since the device actually responds the query, but avahi-daemon is rejecting the response.

@avillacis
Copy link
Author

esp32-mdns-query-dropped.zip
This file contains a wireshark capture of the queries and (ignored) responses from the ESP32 device.

@d8ahazard
Copy link

Version: avahi-0.8-9.fc34.x86_64 on Fedora 34 x86_64

If a MDNS response packet received through port 5353 contains the original MDNS question record, avahi-daemon rejects further processing and logs "Invalid response packet from host ..." if running in verbose mode. Even if the response packet contains a valid answer record in addition to the question record.

I consider this behavior to be incorrect and needlessly strict. For reference, this is the relevant section from RFC 6762 section 6. Responding:

Multicast DNS responses MUST NOT contain any questions in the
Question Section. Any questions in the Question Section of a
received Multicast DNS response MUST be silently ignored.
Multicast
DNS queriers receiving Multicast DNS responses do not care what
question elicited the response; they care only that the information
in the response is true and accurate.

I take this to mean that whether the response contains an echoed question record should be irrelevant to whether the rest of the packet is taken as valid or not. So, if the packet contains a response to an actual issued query, any echoed question in the packet should be ignored and the packet should be considered valid.

I regularly work with ESP32 microcontrollers which use the Espressif MDNS implementation. The Espressif MDNS implementation echoes the question in the response packet. This causes the .local name previously broadcasted by the device to be no longer useful for locating the device in the network, since the device actually responds the query, but avahi-daemon is rejecting the response.

Doing a quick grep of the code, the only place I find that error message is in /avahi-core/server.c:

`
if (avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT) != 0 ||
avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) == 0 ||
avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) != 0) {

        avahi_log_debug("Invalid response packet from host %s.", avahi_address_snprint(t, sizeof(t), src_address));
        return;
    }

`

So, a bit of experimentation would show which of these checks need to be removed...but I'd guess it would be the first one for AVAHI_DNS_FIELD_QDCOUNT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants