From d0c9070715db7a39598693d2f17d69d3fb364958 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 20 Jan 2023 10:55:16 +0100 Subject: [PATCH] fix(mdns): Remove strict mode as it's invalid Strict mode was introduced to support "one-shot" queries (described in RFC6762/sec5.1) that are sent by lwip or dig. It was incorrectly assumed that responding to such queries violates the spec, as we have to repeat queries in responces, which is forbidden in RFC6762/sec6. It is however required to repeat query fields according to the Section 6.7. Legacy Unicast Responses: "it MUST repeat the query ID and the question given in the query message." --- components/mdns/Kconfig | 11 ---------- components/mdns/mdns.c | 2 -- .../mdns/private_include/mdns_private.h | 21 ------------------- 3 files changed, 34 deletions(-) diff --git a/components/mdns/Kconfig b/components/mdns/Kconfig index def0d850d..50bab3ba1 100644 --- a/components/mdns/Kconfig +++ b/components/mdns/Kconfig @@ -64,17 +64,6 @@ menu "mDNS" Configures timeout for adding a new mDNS service. Adding a service fails if could not be completed within this time. - config MDNS_STRICT_MODE - bool "mDNS strict mode" - default "n" - help - Configures strict mode. Set this to 1 for the mDNS library to strictly follow the RFC6762: - Currently the only strict feature: Do not repeat original questions in response packets - (defined in RFC6762 sec. 6). - Default configuration is 0, i.e. non-strict mode, since some implementations, - such as lwIP mDNS resolver (used by standard POSIX API like getaddrinfo, gethostbyname) - could not correctly resolve advertised names. - config MDNS_TIMER_PERIOD_MS int "mDNS timer period (ms)" range 10 10000 diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 5d08322f0..42bb4f5da 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -1728,7 +1728,6 @@ static void _mdns_create_answer_from_parsed_packet(mdns_parsed_packet_t *parsed_ return; } -#ifdef MDNS_REPEAT_QUERY_IN_RESPONSE if (parsed_packet->src_port != MDNS_SERVICE_PORT && // Repeat the queries only for "One-Shot mDNS queries" (q->type == MDNS_TYPE_ANY || q->type == MDNS_TYPE_A || q->type == MDNS_TYPE_AAAA)) { mdns_out_question_t *out_question = malloc(sizeof(mdns_out_question_t)); @@ -1751,7 +1750,6 @@ static void _mdns_create_answer_from_parsed_packet(mdns_parsed_packet_t *parsed_ out_question->own_dynamic_memory = true; queueToEnd(mdns_out_question_t, packet->questions, out_question); } -#endif // MDNS_REPEAT_QUERY_IN_RESPONSE if (q->unicast) { unicast = true; } diff --git a/components/mdns/private_include/mdns_private.h b/components/mdns/private_include/mdns_private.h index d4fef5f13..0f40110e8 100644 --- a/components/mdns/private_include/mdns_private.h +++ b/components/mdns/private_include/mdns_private.h @@ -21,27 +21,6 @@ #define _mdns_dbg_printf(...) printf(__VA_ARGS__) #endif -/** mDNS strict mode: Set this to 1 for the mDNS library to strictly follow the RFC6762: - * Strict features: - * - to do not set original questions in response packets per RFC6762, sec 6 - * - * The actual configuration is 0, i.e. non-strict mode, since some implementations, - * such as lwIP mdns resolver (used by standard POSIX API like getaddrinfo, gethostbyname) - * could not correctly resolve advertised names. - */ -#ifndef CONFIG_MDNS_STRICT_MODE -#define MDNS_STRICT_MODE 0 -#else -#define MDNS_STRICT_MODE 1 -#endif - -#if !MDNS_STRICT_MODE -/* mDNS responders sometimes repeat queries in responses - * but according to RFC6762, sec 6: Responses MUST NOT contain - * any item in question field */ -#define MDNS_REPEAT_QUERY_IN_RESPONSE 1 -#endif - /** Number of predefined interfaces */ #ifndef CONFIG_MDNS_PREDEF_NETIF_STA #define CONFIG_MDNS_PREDEF_NETIF_STA 0