Commit Graph

72 Commits

Author SHA1 Message Date
Erik Ekman
c825eb3604 tcp: Check tcp_output return values in tests
Found with clang-analyzer
2021-01-19 20:19:02 +01:00
jona
d6a6b661d9 Fix typos using codespell
Conservative strategy was used, maybe other typos remain.

Rebased: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-15 21:45:41 +01:00
Joan Lledó
785b7aba3c Sockets: Unit tests and apps corrections
* Include lwip/inet.h in some unit tests and apps
  * Since they use htons() and pals.
* test/unit/api/test_sockets.c:
  * write() could be declared by external socket headers
    * Call lwip_write() instead.
  * Code expects fcntl() to return 6
    * But O_RDWR could have another value if external
      socket headers are present
    * Replace 6 by O_RDWR.
* apps/tftp/tftp.c:
  * recv() could be declared by external socket headers
    * Rename it to tftp_recv()
2019-08-11 20:12:47 +02:00
Simon Goldschmidt
eeef3f65b8 Add a unit test for bug #54833 (tcp_abort with wrong ports)
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 22:57:24 +02:00
Simon Goldschmidt
824ebbe0e9 tcp: fix RTO timer not working if link is down
... and added some test cases for this situation
See bug #54139

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-06-19 22:48:06 +02:00
Simon Goldschmidt
a26a2e1340 adapt unit tests to additional NULL checks 2018-06-12 13:47:13 +02:00
goldsimon
7b6d2870ca test: add a unit test for TCP_CHECKSUM_ON_COPY with retransmissions
This triggers bug #50914 (TCP_CHECKSUM_ON_COPY when adding data to
retransmission) when data is added to an already transmitted segment
with an uneven length of tcp data.
2018-02-12 12:34:45 +01:00
Joel Cunningham
50a5d85f45 tcp: handle segmentation oversize during segment split (bug #52676)
This fixes a bug in tcp_split_unsent_seg where oversized segments were not
handled during the split, leading to pcb->unsent_oversized and
useg->oversize_left getting out of sync with the split segment

This would result in over-writing the pbuf if another call to tcp_write()
happened after the split, but before the remainder of the split was sent in
tcp_output

Now pcb->unsent_oversized is explicitly cleared (because the remainder at
the tail is never oversized) and useg->oversized_left is cleared after it is
trimmed

This also updates the test_tcp_persist_split unit test to explicitly check for
this case
2017-12-18 11:42:13 -06:00
goldsimon
926805bcf1 tcp unit test: fix some endless loops for TCP_WND == 0xFFFF 2017-11-17 21:04:33 +01:00
Axel Lin
a8acca5902 Trivial typo fix
s/chekc/check/g

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-11-07 13:44:43 +01:00
Joel Cunningham
de531131c5 Fix compiler warnings seen with clang 8.1.0 on MacOS
This fixes the following warnings:

test_tcp.c:266:5: error: code will never be executed [-Werror,-Wunreachable-code]
    pbuf_free(p);
    ^~~~~~~~~
 - The check API 'fail' aborts the test, thus pbuf_free(p) will never be executed

pbuf.c:783:111: error: format specifies type 'unsigned short' but the argument has type 'u8_t' (aka 'unsigned char') [-Werror,-Wformat]
      LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: %p has ref %"U16_F", ending here.\n", (void *)p, ref));
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
 - LWIP_PBUF_REF_T is u8_t by default and doesn't match U16_F, so cast to u16_t. The cast and formatter will need to be changed
   if ref is larger than 16 bits

ethernet.c:105:16: error: format specifies type 'unsigned char' but the argument has type 'unsigned int' [-Werror,-Wformat]
               (unsigned)ethhdr->dest.addr[0], (unsigned)ethhdr->dest.addr[1], (unsigned)ethhdr->dest.addr[2],
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 - addr[] is type u8_t, formatter is X8_F which should be 8 bits. 'unsigned' is an int, so cast to unsighed char instead
2017-10-13 07:52:34 -05:00
goldsimon
630c4a3de3 try to fix building unit test on gcc/clang 2017-09-11 11:10:42 +02:00
goldsimon
48c687ea84 tcp_remove_all() (used in tcp test setup/teardown): handle tcp_bound_pcbs, too 2017-09-05 22:20:44 +02:00
goldsimon
cf651e7e0f add test case that shows what's wrong for bug #51937 (Leaking tcp_pcbs on passive close with unacked data) 2017-09-05 22:19:38 +02:00
goldsimon
fca38fda1a remove unnecessary lines from last added test case 2017-09-05 22:18:52 +02:00
goldsimon
8c04009357 add unit test case for passive open & (invalid) bug #51941 2017-09-05 21:47:06 +02:00
Joel Cunningham
f582c88339 tcp: persist timer re-work (bug #50837)
This re-works the persist timer to have the following behavior:

  1) Only start persist timer when a buffered segment doesn't fit within
     the current window and there is no in-fligh data.  Previously, the
     persist timer was always started when the window went to zero even
     if there was no buffered data (since timer was managed in receive
     pathway rather than transmit pathway)
  2) Upon first fire of persist timer, fill the remaining window if
     non-zero by splitting the unsent segment.  If split segment is sent,
     persist timer is stopped, RTO timer is now ensuring reliable window
     updates
  3) If window is already zero when persist timer fires, send 1 byte probe
  4) Persist timer and zero window probe should only be active when the
     following are true:
       * no in-flight data (pcb->unacked == NULL)
       * when there is buffered data (pcb->unsent != NULL)
       * when pcb->unsent->len > pcb->snd_wnd
2017-08-25 09:35:10 -05:00
goldsimon
22ee33951b TCP: added a unit test for trimming left side of rx segment 2017-08-21 22:34:01 +02:00
goldsimon
4cec20230e Ensure that unit tests leave the stack in a clean state 2017-08-03 22:28:50 +02:00
Joel Cunningham
c03fef9a3c bug #50837: add zero-window probe timeout
This commit adds a timeout to the zero-window probing (persist timer)
mechanism. LwIP has not historically had a timeout for the persist
timer, leading to unbounded blocking if connection drops during the
zero-window condition

This commit also adds two units test, one to check the RTO timeout
and a second to check the zero-window probe timeout
2017-05-09 09:01:03 -05:00
Joel Cunningham
de90d03e48 tcp: task #14128 - Appropriate Byte Counting support
This commit adds TCP Appropriate Byte Counting (ABC) support based on
RFC 3465

ABC replaces the previous congestion window growth mechanism and has been
configured with limit of 2 SMSS.  See task #14128 for discussion on
defaults, but the goal is to mitigate the performance impact of delayed
ACKs on congestion window growth

This commit also introduces a mechanism to track when the stack is
undergoing a period following an RTO where data is being retransmitted.

Lastly, this adds a unit test to verify RTO period tracking and some
basic ABC cwnd checking
2017-04-20 15:59:24 -05:00
Joel Cunningham
6fe66771cb test_tcp: de-duplicate test IP addresses, netmask, and ports
This creates a single version of test IP addresses, netmasks, and ports.
All tests were using the same values, but duplicated in each test

This also adds const to some functions so we can use a const version
of addresses
2017-03-31 12:01:43 -05:00
Joel Cunningham
648b2b6f2b test_tcp: remove unnecessary memsets
test_tcp_init_netif() memsets both netif and txcounters, so no need to manually do it
2017-03-31 11:59:12 -05:00
Joel Cunningham
34c9e30225 test_tcp: de-duplicate seqno checking defines
This commit moves common defines and senqo array so they can be
re-used in mulptiple places for sequence number checking rather
than duplicated

Currently they are used in two places, but I'm anticipating needing
them in future TCP unit tests
2017-03-31 11:57:33 -05:00
goldsimon
a42d1678eb tcp unit tests: don't break later tests relying on loopif 2017-03-17 08:56:03 +01:00
Joel Cunningham
8bf402fd67 Fix unit test with assumed congestion avoidance
test_tcp_fast_rexmit_wraparound correctness relied on the congestion
window being in congestion avoidance so that only a single TCP_MSS
segment is sent upon ACKing the first segment.

It's not known whether the test was relying tcp_alloc() to set ssthresh
to 0 and thus start in congestion avoidance or if the test was working by
accident until changes in b90a54f989

This fixes the test by enforcing the requirement of starting in
congestion avoidance

Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-03-10 08:12:17 +01:00
goldsimon
e9e9ec23b8 tcp unit tests: fixed that tcp_teardown() could lead to accessing a netif pointer that is not valid any more (netif added in test function stored on stack) 2017-03-09 20:23:16 +01:00
sg
b198c877db fix compiling TCP unit tests with IPv6 enabled 2017-01-16 14:21:08 +01:00
Dirk Ziegelmeier
1884c7e83f Fix TCP unit tests after changes from "Add hook for TCP Initial Sequence Number generation" commit
(pcb->lastack and friends are not initialized during allocation any more, but by connect() / bind() call)
2016-12-31 11:46:27 +01:00
Dirk Ziegelmeier
7f319f5ec5 Fix compile of test_tcp.c unit test after introduction of tcp_next_iss hook 2016-12-18 21:46:49 +01:00
sg
a2fd68098e minor: macros should not end with underscore(s) 2016-08-08 21:47:53 +02:00
Dirk Ziegelmeier
6af213787a Fix clang address sanitizer errors in unit tests (buffers too small) 2016-08-07 20:21:27 +02:00
goldsimon
288fc8ede3 fixed unit tests after changing memp stats 2016-07-08 10:20:04 +02:00
Dirk Ziegelmeier
d133999e1d Fix warnings in unit test code when compiling with stricter GCC settings 2016-06-23 22:30:37 +02:00
Dirk Ziegelmeier
8dc77ef558 doxygen updates - include IPv6 in documentation. Exclude include/netif/ppp/polarssl.
Convert TODO -> @todo
2016-06-22 20:18:23 +02:00
Henrik Persson
b9a2ee8aaa [PATCH] Drop instead of ASSERT in tcp_input header parsing
Since allowing input validation to trip the ASSERT handler is bad,
let's just drop the packets instead if validation fails.

Signed-off-by: sg <goldsimon@gmx.de>
2016-06-13 20:08:43 +02:00
Sylvain Rochet
37bb0b89f0 all: trivial include changes related to the new "lwip/priv/" include directory 2015-10-10 22:46:47 +02:00
Erik Ekman
e8c0ba2a47 Fix tests after ip4_current_header() made const 2015-09-18 09:52:08 +02:00
sg
851e03966d Fixed more compiler warnings for unit tests 2015-08-05 21:15:41 +02:00
Erik Ekman
dbdeca3032 test_tcp_oos: Remove last_dropped variable, never read 2015-08-05 21:01:17 +02:00
sg
767d0d9046 Fixed unit tests (compiler errors/warnings, coding style) 2015-08-03 20:41:49 +02:00
Sylvain Rochet
632de523de Fixed PBUF_LINK_ENCAPSULATION_HLEN support
PBUF_LINK_ENCAPSULATION_HLEN support was introduced by 6ef7563f and
missed the fact that header size calculation/reservation using
computation like PBUF_LINK_HLEN + PBUF_IP_HLEN + ... are used all over
the source code. Hopefully fixed all of them.
2015-04-20 23:43:33 +02:00
goldsimon
cf180b651b fixed unit tests after changing ip_addr_t 2015-04-10 08:51:06 +02:00
Clint Sbisa
32f6e7e231 tcp: Fix ooseq processing when seqno is near 2^32
An edge case in out-of-sequence TCP packet processing did not use the
appropriate macro to check if the sender overran the recieve window.

Consequently, this case sometimes evaluated to true when it shouldn't, which
resulted in various bad behavior, including trying to resize a TCP buffer to 4
gigabytes.
2015-03-20 08:32:14 +01:00
goldsimon
94f7bcef67 Fixed tcp unit tests after changing routing to check for link up 2015-03-20 08:31:39 +01:00
goldsimon
df16a7c4f3 Fixed compiler warnings in unit tests 2015-03-06 07:39:06 +01:00
Simon Goldschmidt
dbd125c714 Fixed bug #35874 reserved identifier violation (removed leading underscores from header include guards) 2014-05-19 21:46:18 +02:00
Simon Goldschmidt
a80c4d147c Unit test patch by Erik Ekman: use macro to store correct testcase name 2014-02-12 21:52:21 +01:00
goldsimon
5db6bb02d6 TCP unit tests: fix that ip.rterr stats are increased (some unit tests had no netif set) 2012-03-25 17:12:02 +02:00
goldsimon
86766f4e20 Minor: cosmetic source code layout changes 2012-02-22 21:35:04 +01:00