mdns: increase mDNS output packet size

When more than one service (just 2) need to be probed for conflict, generation
of the probe packet fail because pbuf is too small!

So OUTPACKET_SIZE renamed to MDNS_OUTPUT_PACKET_SIZE and moved to mdns_opts.h
to allow configuration. Default configuration raise it to 1450 to have enough
space when MDNS_MAX_SERVICES > 1 else it remain 512.

Extract from RFC 6762, chapter 17, Multicast DNS Message Size:

   The 1987 DNS specification [RFC1035] restricts DNS messages carried
   by UDP to no more than 512 bytes (not counting the IP or UDP
   headers).  For UDP packets carried over the wide-area Internet in
   1987, this was appropriate.  For link-local multicast packets on
   today's networks, there is no reason to retain this restriction.
   Given that the packets are by definition link-local, there are no
   Path MTU issues to consider.

   Multicast DNS messages carried by UDP may be up to the IP MTU of the
   physical interface, less the space required for the IP header (20
   bytes for IPv4; 40 bytes for IPv6) and the UDP header (8 bytes).

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
David Girault 2019-01-31 16:47:10 +01:00 committed by Simon Goldschmidt
parent cb3f0a9b17
commit a2498898b0
2 changed files with 12 additions and 5 deletions

View File

@ -52,9 +52,6 @@
#if LWIP_MDNS_RESPONDER
/* Payload size allocated for each outgoing UDP packet */
#define OUTPACKET_SIZE 500
/* Function prototypes */
static void mdns_clear_outmsg(struct mdns_outmsg *outmsg);
@ -93,7 +90,7 @@ mdns_add_question(struct mdns_outpacket *outpkt, struct mdns_domain *domain,
if (!outpkt->pbuf) {
/* If no pbuf is active, allocate one */
outpkt->pbuf = pbuf_alloc(PBUF_TRANSPORT, OUTPACKET_SIZE, PBUF_RAM);
outpkt->pbuf = pbuf_alloc(PBUF_TRANSPORT, MDNS_OUTPUT_PACKET_SIZE, PBUF_RAM);
if (!outpkt->pbuf) {
return ERR_MEM;
}
@ -166,7 +163,7 @@ mdns_add_answer(struct mdns_outpacket *reply, struct mdns_domain *domain,
if (!reply->pbuf) {
/* If no pbuf is active, allocate one */
reply->pbuf = pbuf_alloc(PBUF_TRANSPORT, OUTPACKET_SIZE, PBUF_RAM);
reply->pbuf = pbuf_alloc(PBUF_TRANSPORT, MDNS_OUTPUT_PACKET_SIZE, PBUF_RAM);
if (!reply->pbuf) {
return ERR_MEM;
}

View File

@ -60,6 +60,16 @@
#define MDNS_MAX_SERVICES 1
#endif
/** Payload size allocated for each outgoing UDP packet. Will be allocated with
* PBUF_RAM and freed after packet was sent.
* According to RFC 6762, there is no reason to retain the 512 bytes restriction
* for link-local multicast packet.
* 512 bytes isn't enough when 2 services need to be probed.
*/
#ifndef MDNS_OUTPUT_PACKET_SIZE
#define MDNS_OUTPUT_PACKET_SIZE ((MDNS_MAX_SERVICES == 1) ? 512 : 1450)
#endif
/** MDNS_RESP_USENETIF_EXTCALLBACK==1: register an ext_callback on the netif
* to automatically restart probing/announcing on status or address change.
*/