Commit Graph

6340 Commits

Author SHA1 Message Date
David Cermak 3f5a04bc63 igmp/mld6: Fix on-demand timers to set LWIP_NUM_SYS_TIMEOUT_INTERNAL
Correction on 33e3d3eb to update number of system timeouts based on
settings of IGMP and MLD6 on-demand timer settings
2022-06-28 13:28:45 +02:00
David Cermak b8fa0e7ab1 ci: Publish branch 2.1.3-esp-dev on CI success 2022-06-28 10:13:13 +02:00
xueyunfei 2e7efc486e WIP: Temporarily break ipv6 zoning to pass IT_* tests
ipv6: send data if src address is null

Send both multicast and unicast data if the src IP address is ANY
* picked from 4fd84aba
* picked from 889c3875
Ref IDF-4856
2022-04-12 13:32:12 +02:00
David Cermak 22cae23c33 test/napt: Add unit test for IP forward with PBUF_REF
Picked from espressif/esp-lwip@76303df2
Ref IDF-4797
2022-04-12 13:32:12 +02:00
xueyunfei a6c67f5d72 napt: Fix PBUF_REF type to clone the pbuf before forwarding
Picked from espressif/esp-idf@39068263
Ref IDF-4800
2022-04-12 13:32:12 +02:00
David Cermak 87a4aa2d08 PPP: Add test exhibiting empty packet null-deref
Also updates lcp.c to compile with PPP_AUTH_SUPPORT=0 in clang

Picked from espressif/esp-lwip@202a07da
Patch posted https://savannah.nongnu.org/patch/?10179
Ref IDF-4797
2022-04-12 13:32:12 +02:00
Peter Putz 46d284ea07 PPP: Fix null-deref when processing wrong packet
This happens during quick reconnect of LTE ppp session.
When processing an input packet containing only zero's,
the pppos state machine assumes these are control fields,
so doesn't allocate any pbuf for data. So if the `PPP_FLAG` comes
(start of another valid packet) in this state and the `FCS` is valid
(which is valid as long as only zero characters are being received)
we de-reference `pppos->in_tail` in pppos.c:544.

Picked from espressif/esp-lwip@537c69d5
Patch posted https://savannah.nongnu.org/patch/?10179
Ref IDF-4847
2022-04-12 13:32:12 +02:00
yuanjm ac177623a8 dns: Add API to clear dns cache
Picked from espressif/esp-lwip@ee59f77d
Ref IDF-4839
2022-04-12 13:32:12 +02:00
xueyunfei f0163d5af8 timeout: Add function for deinit system timers
Picked from espressif/esp-lwip@2749568f
Ref IDF-4847
2022-04-12 13:32:12 +02:00
yuanjm 142b21eb1e sntp: Fix client receive KOD packet that make pool MEMP_SYS_TIMEOUT not be freed
Reported as https://savannah.nongnu.org/bugs/?58817
picked from espressif/esp-lwip@1c1642fe
Ref IDF-4847
2022-04-12 13:32:12 +02:00
yuanjm 230251b7d4 dns: Fix server_idx increasing to DNS_MAX_SERVERS and trigger the LWIP_ASSERT
ESP specific patch

Picked from espressif/esp-lwip@5a567d52
Ref IDF-4839
2022-04-12 13:32:12 +02:00
David Cermak 6d242aae0f tcp_in: Flag the pcb as closing if TCP_EVENT_CLOSED refused
If the packet contained FIN flag, we post a TCP_EVENT_CLOSE with null pbuf,
which could get lost if the underlying platform implementation of sys_mbox_(try)post()
returns ERR_MEM (i.e. won't fit into the recv mailbox).
Loosing this event causes trouble since the FIN initiator gets ACK'ed and
assumes the connection has closed, but the TCP state machine is stuck in its active state.
Fixed by flagging the pcb as closing if the ERR_MEM returned.

Picked from espressif/esp-lwip@d050c331
Patch posted https://savannah.nongnu.org/patch/?10013
Ref IDF-4847
2022-04-12 13:32:12 +02:00
xueyunfei 1a192d43fe dhcp: Add dhcp state debug info
Picked from espressif/esp-lwip@9c62fd4e
Ref IDF-4817
2022-04-12 13:32:12 +02:00
Rob Connolly 70fdf906e5 slip: Fix SLIP RX linked list append.
Append to the linked list of pbuf objects was broken so that the second
(and subsequent) packets received in a SLIP transaction would be
appended to themselves and consequently lost.
This resulted in these packets being dropped and the system suffering
extreme memory leakage.

Picked from espressif/esp-lwip@01d0ecff
Ref IDF-4847
2022-04-12 13:32:11 +02:00
xueyunfei ee4899bb63 tcp_in: Fix for potential segment overflow
The TCP MSS is 1436, assuming that the received packet length is 1436,
the disordered queue will change in order because of the arrival of this packet.
Make sure that the total length of this package and the shuffled package does not exceed the window

picked from espressif/esp-lwip@7285b846
Ref IDF-4852
2022-04-12 13:32:11 +02:00
ChenJianxing fb4623a47b nd6: Queue IPv6 packets while ND6 inprogress
...and return ERR_MEM on ND6 queue full.
Issue:
When ESP32/S2 UDPv6 TX, the pkts are queued into neighbor cache queue
when MAC address is being resolved, and as a result of LwIP component's "malloc"
use C lib not the LwIP memory pool, which cause the restriction of max
nd6 queue num can't limit the memory use.

picked from espressif/esp-lwip@80d6d19a
Ref IDF-4849
2022-04-12 13:32:11 +02:00
xiehang b35d6385dd arp: Return ERR_MEM on ARP queue full
Root Cause:
When the ARP cache table is filled, when a new packet comes in, the ARP cache table will be emptied.
Solution:
If the ARP cache table is full, ERR_MEM is returned.

picked from espressif/esp-lwip@602d25c5
Ref IDF-4849
2022-04-12 13:32:04 +02:00
xueyunfei 6c65a09e0c ip_frag: Drop IPv6 packets larger than MTU
Drop larger packets if ipv6-fragmentation is disabled

Picked from: espressif/esp-lwip@5b2072eb
Ref IDF-4846
2022-03-31 09:44:55 +02:00
Github Security Lab 12bcb04885 ppp: Fix potential array overflow
`vallen` is verified to be less than `len`, therefore, it can never
be the case that `vallen >= len + sizeof(rhostname)`.

This PR fixes the check so the `rhostname` array does not overflow.

Reported-by: Github Security Lab <securitylab@github.com>
Signed-off-by: Alvaro Muñoz <pwntester@github.com>
Ref IDF-4847
2022-03-31 09:44:55 +02:00
xueyunfei 0204887155 sockets: Fix free-select-locked after udp close
ESP_LWIP supports closing socket while waiting. This fixes potential
races.
Orig: fix bug for after udp close select_waiting assert (dd3b3017)

Ref IDF-4794
2022-03-31 09:44:55 +02:00
xiehang afb13b4d39 ip_frag: Drop IPv4 packets larger than MTU
Drop larger packets if ipv4-fragmentation is disabled

Ref IDF-4846
2022-03-31 09:44:55 +02:00
xueyunfei ca4c76622f api_msg: Fixes for sock close from another thread
Ref IDF-4794
2022-03-31 09:44:55 +02:00
xueyunfei 95d63b3ef5 sockets: Fix potential race when socket is closed already
Ref IDF-4794
2022-03-31 09:44:55 +02:00
xueyunfei 8188897ee6 sockets: Fix select-waiter when socket closed abruptly
ESP_LWIP supports closing socket while waiting. This fixes potential
races.

Ref IDF-4794
2022-03-31 09:44:55 +02:00
xueyunfei e98e90cbb6 ipv6: Support IPv4/IPv6 mapped PCBs
This change also drops UDP IPv4 packet received on IPv6-only socket.

Ref IDF-4845
2022-03-31 09:44:55 +02:00
David Cermak 2b38d2c803 autoip: Make max-conflics and rate-limit configurable
These constants are defined in RFC-3927 (10 conflicts before rate
limiting and 60 seconds between attempts) and are not intended to be
configurable. We cannot pass BCT without adjusting these params, though.

Ref IDF-4843
2022-03-31 09:44:55 +02:00
xueyunfei 6a4b9f57e7 dns: Support for fallback DNS server
This adds support for list of DNS servers, that could contain manually
configured server that won't be rewritten.
Also if some of the servers in the list is NULL, the algorithm continues
searching with other configured servers up to DNS_MAX_SERVERS.

Ref IDF-4839
2022-03-31 09:44:55 +02:00
Sachin Parekh 33e3d3eb2f igmp/mld6: Add on-demand timers config
IGMP and MLD6 timers activated only when joining groups or receiving
QUERY packets. This reduces the power consumption in applications that
do not use IGMP and MLD6.

Signed-off-by: Sachin Parekh <sachin.parekh@espressif.com>
Co-Authored-By: Axel Lin <axel.lin@gmail.com> (espressif/esp-lwip@b1eec77b)
Ref IDF-4837
2022-03-31 09:44:50 +02:00
David Cermak f978e87f3c dhcp: Add hook for appending extra client's request options
Co-Authored-By: Liu Han <liuhan@espressif.com> (espressif/esp-lwip@ae7edc2a)
Ref IDF-4817
2022-03-29 16:21:41 +02:00
David Cermak 632ac61f95 dhcp/test: Add dhcp option tests for platform hooks
Testing various cominations of extra dhcp options:
* MTU
* client-id
* VSI/VCI

Ref IDF-4817
2022-03-29 16:20:07 +02:00
yuanjm 0633e7d14b dhcp: Continuously try to rebind in t2 (if failed in t1)
The root cause of this issue is big UDP traffic consuming the buffer
so the DHCP doesn't have the bandwitdh to access the Tx buffer.
More info espressif/esp-lwip!217

Ref IDF-4817
2022-03-25 18:53:06 +01:00
Logan Gunthorpe 729d724cae dhcp: Set hostname for DISCOVER packets
If the hostname is not set in the DISCOVER packet, then some servers might
issue an OFFER with hostname configured and consequently reject the REQUEST
with any other hostname.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Ref IDF-4817
2022-03-24 18:56:24 +01:00
xueyunfei 73a92e31c0 dhcp: Enable custom config for timeouts, thresholds, delays
Also updates timeout type from u16 to u32

Co-Authored-By: David Cermak <cermak@espressif.com>
Co-Authored-By: ronghulin <ronghulin@espressif.com> (espressif/esp-lwip@32b1aaf2)
Ref IDF-4817
2022-03-24 18:56:19 +01:00
David Cermak 14bba8e365 dhcp: Add post_init hook to allow skip discovery
This enables embedded devices restart the DHCP state machine easily
after reset and continue directly with DHCP_BIND of previously bound
address.

Co-Authored-By: MartinValik <martin.valik@mail.com> (espressif/esp-lwip@3b88e84f)
Ref IDF-4817
2022-03-24 10:20:54 +01:00
martin-ger 319d4d3c91 napt: Add basic support for NAT by martin-ger
* Cosmetic updates on NAPT functionality implemented by martin-ger
- moved NAPT specific code from ip4.c to ip4_napt.c
- formatting updates to keep the changes easier to review
- updated per C-90 style used for lwip upstream (fixed warning,
renaming, lwip types)
- esp_random() -> LWIP_RAND()
- drop the connection with routing err if failed to add new napt record
- prepared for lwip unit testing

* Add ip4 routing tests
- lwip native ip-forward tests
- napt feature test udp, tcp
- napt feature, test add/release of nat records
Testing configurations: lwip unit tests are executed in the following
three configurations:
- default
- IP_FORWARD=1
- IP_FORWARD=1 & IP_NAPT=1
Note that debugging option ESP_TEST_DEBUG was introduced to enable running only
IP-FORWARD/IP-NAPT tests with verbose output

* Fix checksum of UDP
- According to the UDP protocol, the checksum is optional.
so if the checksum is 0, this meaning the checksum is turn off, and no need to
correct checksum.

* Fix disbale IPv6 and enable NAPT will build error

Co-Authored-By: David Cermak <cermak@espressif.com> (4b4d6b28, 754b8d5d)
Co-Authored-By: leo chung <gewalalb@gmail.com> (bb63eed1)
Co-Authored-By: yuanjm <yuanjianmin@espressif.com> (74cf7f9f)
Ref IDF-4800
2022-03-24 10:20:47 +01:00
xueyunfei bc50722223 ipv6: Add error check on joining incorrect multicast address
Ref IDF-4799
Picked from espressif/esp-lwip@d8327f98
2022-03-20 11:31:13 +01:00
yuanjm 72105e5338 tcp: Make retransmission timeout (RTO) configurable
Ref IDF-4798
Picked from espressif/esp-lwip@64b640ec
2022-03-20 11:16:38 +01:00
xueyunfei 0a9dad958e api_msg: Support sock close from another thread
Add support for closing the socket from another thread
while is blocked on connection.

Ref IDF-4794
2022-03-20 10:08:19 +01:00
Chen Yu Dong 5f246f5f78 ci: Add unit test suite to validate tcp state transitions
Ref IDF-4797
2022-03-20 10:08:19 +01:00
David Cermak 4a2fb7801a ci: Add github/lab build/run unit tests on linux
Co-Authored-By: Erik Ekman <erik@kryo.se> (lwip-tcpip/lwip@853258ff)
Co-Authored-By: xueyunfei <xueyunfei@espressif.com> (espressif/esp-lwip@74e2fa32)
Ref IDF-4797
2022-03-20 10:08:19 +01:00
David Cermak 08f1b41db7 ci: Update esp-lwip's version to 2.1.3-esp
Ref IDF-4797
2022-03-20 10:08:19 +01:00
Dirk Ziegelmeier dd27077ab7 Fix compile error with GCC 8 in makefsdata
lwip/lwip/src/apps/http/makefsdata/makefsdata.c:929:56: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
   snprintf(qualifiedName, sizeof(qualifiedName), "%s/%s", curSubdir, filename);

/home/dziegel/lwip/lwip/src/apps/http/makefsdata/makefsdata.c:929:3: note: ‘snprintf’ output 2 or more bytes (assuming 257) into a destination of size 256
   snprintf(qualifiedName, sizeof(qualifiedName), "%s/%s", curSubdir, filename);

Reduce subdir string length by 3 bytes to make the warning go away. The whole file path including directory AND filename is limited to MAX_PATH_LEN - so it is reasonable to reserve 3 bytes less for directory - the filename won't fit anyway in the remaining 3 bytes.

Ref IDF-4797
Picked from lwip-tcpip/lwip@30b2d073
2022-03-19 19:17:47 +01:00
Simon Goldschmidt 6ca936f6b5 Prepare 2.1.3 release 2021-11-10 19:25:03 +01:00
Hu Keping e7b74570d9 Remove unnecessary files in release tarball
This patch adds a few entries in .gitattributes to specify files that
should never end up in a distribution tarball.

Signed-off-by: Hu Keping <hukeping@huawei.com>
2021-11-10 19:18:11 +01:00
Sylvain Rochet 018c64ab94 PPP: assert if ppp_set_* functions are called when session is not dead
ppp_set_* functions that set the PPP session parameters must only be
called when the session is in a dead state (i.e. disconnected),
otherwise not fatal but surprising results may happen.
2021-10-13 21:30:13 +02:00
Sylvain Rochet 7e92fb3d7f PPP: remove LWIP_ASSERT_CORE_LOCKED on ppp_set_auth function
We do not have equivalents in PPPAPI for ppp_set_* functions because
calling them only makes sense while session is disconnected, furthermore
they are only setting structure members of the session configuration.
2021-10-13 21:29:29 +02:00
Dirk Ziegelmeier 051fbea5e6 Fix bug #54805: IP address can not be obtained over dhcp if PBUF_POOL_BUFSIZE is too small
Patch by Christoph Chang
2021-10-03 12:33:58 +02:00
Florent Matignon 214e2d90f3 bug #54700: Unexpected expiry of pending ARP table entry
New etharp queries should restart the 5 second timeout on the ARP
table entry if it is still pending.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
(cherry picked from commit ffbe075d56)
2021-10-01 20:31:59 +02:00
Simon Goldschmidt 4022a19cbc altcp: fix altcp_tcp_close for LISTEN pcb
See bug #55219

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
(cherry picked from commit 064d816ea1)
2021-10-01 19:59:02 +02:00
Simon Goldschmidt a32ea1e793 dhcp: don't set a default gateway if dhcp server doesn't give one
see bug #60578
2021-09-24 12:24:58 +02:00