Skip to content

Commit 6076a46

Browse files
authored
Merge pull request #36 from danielinux/tcp_timestamp_negotiation
TCP: fix timestamp negotiation, RFC6298 compliance, TCP zero-window probe
2 parents fdaf384 + cf7201c commit 6076a46

7 files changed

Lines changed: 1214 additions & 118 deletions

File tree

.github/workflows/linux.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
jobs:
1010
linux_test:
1111
runs-on: ubuntu-latest
12+
timeout-minutes: 15
1213

1314
steps:
1415
- uses: actions/checkout@v4
@@ -27,37 +28,50 @@ jobs:
2728
make
2829
2930
- name: Run standalone "event loop" test
31+
timeout-minutes: 5
3032
run: |
31-
sudo ./build/test-evloop
33+
set -euo pipefail
34+
timeout --preserve-status 5m sudo ./build/test-evloop
3235
sudo killall tcpdump || true
3336
3437
- name: Run standalone "IPsec esp" test
38+
timeout-minutes: 7
3539
run: |
36-
sudo ./tools/ip-xfrm/rfc4106 128
37-
sudo ./build/test-esp -m 0
40+
set -euo pipefail
41+
sudo ./tools/ip-xfrm/delete_all || true
42+
timeout --preserve-status 7m sudo ./tools/ip-xfrm/rfc4106 128
43+
timeout --preserve-status 7m sudo ./build/test-esp -m 0
3844
sudo killall tcpdump || true
39-
sudo ./tools/ip-xfrm/delete_all
40-
sudo ./tools/ip-xfrm/cbc_auth sha256 128
41-
sudo ./build/test-esp -m 1
45+
sudo ./tools/ip-xfrm/delete_all || true
46+
timeout --preserve-status 7m sudo ./tools/ip-xfrm/cbc_auth sha256 128
47+
timeout --preserve-status 7m sudo ./build/test-esp -m 1
4248
sudo killall tcpdump || true
43-
sudo ./tools/ip-xfrm/delete_all
49+
sudo ./tools/ip-xfrm/delete_all || true
4450
4551
- name: Run standalone wolfssl test
52+
timeout-minutes: 5
4653
run: |
47-
sudo ./build/test-wolfssl
54+
set -euo pipefail
55+
timeout --preserve-status 5m sudo ./build/test-wolfssl
4856
sudo killall tcpdump || true
4957
5058
- name: Run standalone forwarding test
59+
timeout-minutes: 5
5160
run: |
52-
sudo ./build/test-wolfssl-forwarding
61+
set -euo pipefail
62+
timeout --preserve-status 5m sudo ./build/test-wolfssl-forwarding
5363
5464
- name: Run standalone TTL expired test
65+
timeout-minutes: 5
5566
run: |
56-
./build/test-ttl-expired
67+
set -euo pipefail
68+
timeout --preserve-status 5m ./build/test-ttl-expired
5769
5870
- name: Testing ICMP socket by stealing system calls in ping
71+
timeout-minutes: 2
5972
run: |
60-
sudo LD_PRELOAD=$PWD/libwolfip.so ping -c 5 10.10.10.1
73+
set -euo pipefail
74+
timeout --preserve-status 2m sudo LD_PRELOAD=$PWD/libwolfip.so ping -c 5 10.10.10.1
6175
6276
- name: Install check
6377
run: |
@@ -68,5 +82,13 @@ jobs:
6882
make unit
6983
7084
- name: Run unit tests
85+
timeout-minutes: 5
7186
run: |
72-
build/test/unit
87+
set -euo pipefail
88+
timeout --preserve-status 5m build/test/unit
89+
90+
- name: Cleanup IPsec state
91+
if: always()
92+
run: |
93+
sudo ./tools/ip-xfrm/delete_all || true
94+
sudo killall tcpdump || true
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: wolfIP Autocov
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
pull_request:
8+
9+
jobs:
10+
autocov:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: true
18+
19+
- name: Install dependencies
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install -y build-essential check gcovr libwolfssl-dev
23+
24+
- name: Run autocov
25+
run: make clean autocov
26+
27+
- name: Generate coverage JSON
28+
run: |
29+
gcovr -r . --exclude "src/test/unit/unit.c" --json -o build/coverage/coverage.json
30+
31+
- name: Enforce 100% function coverage for src/wolfip.c
32+
run: |
33+
python3 - <<'PY'
34+
import json
35+
import sys
36+
37+
with open("build/coverage/coverage.json", "r", encoding="utf-8") as f:
38+
data = json.load(f)
39+
40+
target = None
41+
for file_entry in data.get("files", []):
42+
if file_entry.get("file", "").endswith("src/wolfip.c"):
43+
target = file_entry
44+
break
45+
46+
if target is None:
47+
print("ERROR: src/wolfip.c not found in coverage JSON")
48+
sys.exit(1)
49+
50+
functions = target.get("functions", [])
51+
if not functions:
52+
print("ERROR: No function coverage data for src/wolfip.c")
53+
sys.exit(1)
54+
55+
total = len(functions)
56+
covered = sum(1 for fn in functions if fn.get("execution_count", 0) > 0)
57+
pct = (covered * 100.0) / total
58+
print(f"src/wolfip.c function coverage: {covered}/{total} ({pct:.2f}%)")
59+
60+
if covered != total:
61+
print("ERROR: src/wolfip.c function coverage must be 100%")
62+
sys.exit(1)
63+
PY

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,21 @@ cov: unit $(COV_UNIT)
355355
@gcovr -r . --exclude "src/test/unit/unit.c" --html-details -o build/coverage/index.html
356356
@$(OPEN_CMD) build/coverage/index.html
357357

358+
autocov: unit $(COV_UNIT)
359+
@echo "[RUN] unit (coverage)"
360+
@rm -f $(COV_DIR)/*.gcda
361+
@$(COV_UNIT)
362+
@echo "[COV] gcovr html"
363+
@mkdir -p build/coverage
364+
@gcovr -r . --exclude "src/test/unit/unit.c" --html-details -o build/coverage/index.html
365+
358366
# Install dynamic library to re-link linux applications
359367
#
360368
install:
361369
install libwolfip.so $(PREFIX)/lib
362370
ldconfig
363371

364-
.PHONY: clean all static cppcheck cov
372+
.PHONY: clean all static cppcheck cov autocov
365373

366374
cppcheck:
367375
$(CPPCHECK) $(CPPCHECK_FLAGS) src/ 2>cppcheck_results.xml

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ A single network interface can be associated with the device.
3131
| **Transport** | TCP | Connection management, reliable delivery | [RFC 793](https://datatracker.ietf.org/doc/html/rfc793), [RFC 9293](https://datatracker.ietf.org/doc/html/rfc9293) |
3232
| **Transport** | TCP | Maximum Segment Size negotiation | [RFC 793](https://datatracker.ietf.org/doc/html/rfc793) |
3333
| **Transport** | TCP | TCP Timestamps, RTT measurement, PAWS, Window Scaling | [RFC 7323](https://datatracker.ietf.org/doc/html/rfc7323) |
34-
| **Transport** | TCP | Retransmission timeout (RTO) computation | [RFC 6298](https://datatracker.ietf.org/doc/html/rfc6298) |
34+
| **Transport** | TCP | Retransmission timeout (RTO) computation | [RFC 6298](https://datatracker.ietf.org/doc/html/rfc6298), [RFC 5681](https://datatracker.ietf.org/doc/html/rfc5681) |
3535
| **Transport** | TCP | TCP SACK | [RFC 2018](https://datatracker.ietf.org/doc/html/rfc2018), [RFC 2883](https://datatracker.ietf.org/doc/html/rfc2883), [RFC 6675](https://datatracker.ietf.org/doc/html/rfc6675) |
3636
| **Transport** | TCP | Congestion Control: Slow start, congestion avoidance | [RFC 5681](https://datatracker.ietf.org/doc/html/rfc5681) |
3737
| **Transport** | TCP | Fast Retransmit, triple duplicate ACK detection | [RFC 5681](https://datatracker.ietf.org/doc/html/rfc5681) |

src/test/esp/test_esp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
static void __attribute__((noreturn)) print_usage_and_die(void);
4141

42-
#define TEST_SIZE (12 * 1024)
42+
#define TEST_SIZE (8 * 1024)
4343
#define BUFFER_SIZE TEST_SIZE
4444

4545
static int disable_ipsec = 0;

0 commit comments

Comments
 (0)