1From 3ec7c31a2e5fba79936ca97de3e527f851e34c6b Mon Sep 17 00:00:00 2001
2From: David van Moolenbroek <david@minix3.org>
3Date: Thu, 2 Feb 2017 18:58:11 +0000
4Subject: [PATCH 4/4] MINIX 3 only: avoid large contiguous allocations
5
6On MINIX 3, we implement our own pool-based memory management.  The
7maximum buffer size of any one of those pool elements is small: 512
8bytes, currently.  That means that any allocation for larger
9contiguous sizes will never succeed.  This patch deals with one known
10practical case where this is a problem, namely duplication of incoming
11UDP packets that should be delivered to more than one UDP PCB.  This
12case can be resolved by using our own pbuf chain allocator.
13
14The only remaining currently known case where lwIP performs large
15contiguous allocations, is in allocating the reply buffer for ICMP
16ping requests.  The result is that our implementation will never
17respond to ping requests that exceed 512 bytes, which is just fine.
18---
19 src/core/udp.c | 4 ++++
20 1 file changed, 4 insertions(+)
21
22diff --git a/src/core/udp.c b/src/core/udp.c
23index ec4b25f..f53fb66 100644
24--- a/src/core/udp.c
25+++ b/src/core/udp.c
26@@ -368,7 +368,11 @@ udp_input(struct pbuf *p, struct netif *inp)
27                   pbuf_header_force(p, hdrs_len);
28                   p_header_changed = 1;
29                 }
30+#if defined(__minix)
31+                q = pchain_alloc(PBUF_RAW, p->tot_len);
32+#else /* !defined(__minix) */
33                 q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM);
34+#endif /* !defined(__minix) */
35                 if (q != NULL) {
36                   err_t err = pbuf_copy(q, p);
37                   if (err == ERR_OK) {
38--
392.5.2
40
41