net: mdns: Discard the message if query count is 0
As described in RFC 6804 ch. 2, if query count is 0, discard
the message silently.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
diff --git a/subsys/net/lib/dns/dns_pack.c b/subsys/net/lib/dns/dns_pack.c
index 3362828..34b3651 100644
--- a/subsys/net/lib/dns/dns_pack.c
+++ b/subsys/net/lib/dns/dns_pack.c
@@ -449,7 +449,8 @@
qdcount = dns_unpack_header_qdcount(dns_header);
if (qdcount < 1) {
- return -EINVAL;
+ /* Discard the message if query count is 0. RFC 6804 ch. 2 */
+ return -ENOENT;
}
if (src_id) {
diff --git a/subsys/net/lib/dns/mdns_responder.c b/subsys/net/lib/dns/mdns_responder.c
index c065580..f9a3b75 100644
--- a/subsys/net/lib/dns/mdns_responder.c
+++ b/subsys/net/lib/dns/mdns_responder.c
@@ -533,7 +533,6 @@
ret = mdns_unpack_query_header(&dns_msg, NULL);
if (ret < 0) {
- ret = -EINVAL;
goto quit;
}
@@ -670,7 +669,7 @@
ARG_UNUSED(my_ctx);
ret = dns_read(sock, dns_data, len, addr, addrlen);
- if (ret < 0 && ret != -EINVAL) {
+ if (ret < 0 && ret != -EINVAL && ret != -ENOENT) {
NET_DBG("%s read failed (%d)", "mDNS", ret);
}