From 4b531a6333340c2702e98c5504cd9d7a712f4eea Mon Sep 17 00:00:00 2001 From: Dong Heng Date: Thu, 30 Aug 2018 16:17:05 +0800 Subject: [PATCH] fix(lwip): Fix UDP send more than 1472 bytes --- components/lwip/lwip/src/core/udp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/lwip/lwip/src/core/udp.c b/components/lwip/lwip/src/core/udp.c index ce2e3d29..34bb18e6 100644 --- a/components/lwip/lwip/src/core/udp.c +++ b/components/lwip/lwip/src/core/udp.c @@ -516,6 +516,19 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, struct netif *netif; const ip_addr_t *dst_ip_route = dst_ip; + /** + * UDP max payload = MTU(1500 now) - IP head(20) - UDP head(8) = 1472 + * + * We test that LWIP send 1473 bytes data, linux can cacth these but windows can't. + * + * If enable IP_FRAG option, these data should be fragmented at IP layer.. + */ +#if ESP_LWIP && !IP_FRAG + if (p && p->tot_len > 1472) { + return ERR_VAL; + } +#endif + if ((pcb == NULL) || (dst_ip == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) { return ERR_VAL; }