Branch: refs/heads/misc-bugfixes Home: https://github.com/kronosnet/kronosnet Commit: fc73bf1486d5ee87d6715efff9ffd24d6d91cf80 https://github.com/kronosnet/kronosnet/commit/fc73bf1486d5ee87d6715efff9ffd2... Author: Fabio M. Di Nitto fdinitto@redhat.com Date: 2026-05-20 (Wed, 20 May 2026)
Changed paths: M libknet/tests/knet_bench.c
Log Message: ----------- [tests] improve input validation in knet_bench test tool
Replace atoi() with safe_atoi() helper that uses strtol() for proper error detection. Improves developer experience with better error messages.
Signed-off-by: Fabio M. Di Nitto fdinitto@redhat.com Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com
Commit: bd35ffa29ff175a1490758a5776a32b953ecb6b5 https://github.com/kronosnet/kronosnet/commit/bd35ffa29ff175a1490758a5776a32... Author: Fabio M. Di Nitto fdinitto@redhat.com Date: 2026-05-20 (Wed, 20 May 2026)
Changed paths: M libnozzle/libnozzle.c M libnozzle/tests/Makefile.am A libnozzle/tests/api_nozzle_prefix_validation.c
Log Message: ----------- libnozzle: add input validation for network prefixes
Replace atoi() with strtol() for network prefix validation to properly detect invalid input, overflow, and out-of-range values.
Add comprehensive test coverage for prefix validation scenarios.
Signed-off-by: Fabio M. Di Nitto fabbione@kronosnet.org Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com
Commit: d88d31511801c8a47bf16a7ad9b965ff1077c635 https://github.com/kronosnet/kronosnet/commit/d88d31511801c8a47bf16a7ad9b965... Author: Fabio M. Di Nitto fdinitto@redhat.com Date: 2026-05-21 (Thu, 21 May 2026)
Changed paths: M libknet/tests/Makefile.am A libknet/tests/int_decompress_bufsize.c M libknet/tests/test-common.c M libknet/tests/test-common.h M libknet/threads_rx.c
Log Message: ----------- libknet: add decompression buffer size validation
Add sanity check to verify decompressed data size does not exceed KNET_DATABUFSIZE before using it.
Signed-off-by: Fabio M. Di Nitto fdinitto@redhat.com Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com
Commit: 38b5845af9b54045b370aacbe92ca36d0b94d942 https://github.com/kronosnet/kronosnet/commit/38b5845af9b54045b370aacbe92ca3... Author: Fabio M. Di Nitto fdinitto@redhat.com Date: 2026-05-21 (Thu, 21 May 2026)
Changed paths: M libknet/host.c
Log Message: ----------- libknet: fix defragmentation buffer reclamation using wrong sequence number
The defragmentation buffer reclamation was using the old received sequence number (dst_seq_num) instead of the current packet's sequence number to calculate the valid buffer window.
This caused buffers to be reclaimed based on stale sequence information, potentially freeing buffers that should still be valid or keeping buffers that should be reclaimed.
Fixed by passing seq_num (current packet) instead of dst_seq_num (last received) to _reclaim_old_defrag_bufs().
Signed-off-by: Fabio M. Di Nitto fdinitto@redhat.com Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com
Commit: d1e0b9bf9fd7265f23aaff30e6615b4458a028b4 https://github.com/kronosnet/kronosnet/commit/d1e0b9bf9fd7265f23aaff30e6615b... Author: Fabio M. Di Nitto fdinitto@redhat.com Date: 2026-05-21 (Thu, 21 May 2026)
Changed paths: M libknet/host.c
Log Message: ----------- libknet: fix sequence number wraparound calculation in defragmentation
The distance calculation between sequence numbers was incorrect when wraparound occurred. The formula was backwards: it subtracted in the wrong direction and didn't account for the +1 needed for modular arithmetic.
This caused incorrect buffer reclamation decisions near the SEQ_MAX boundary.
Practical examples (SEQ_MAX = 65535):
Example 1 - Normal case (no wraparound): Last packet: dst_seq_num = 1000 New packet: seq_num = 1005 Expected distance: 5
BEFORE (wrong): seq_dist = dst_seq_num - seq_num = 1000 - 1005 = -5 (negative!)
AFTER (correct): seq_dist = seq_num - dst_seq_num = 1005 - 1000 = 5
Example 2 - Wraparound case: Last packet: dst_seq_num = 65534 New packet: seq_num = 3 (wrapped around) Expected distance: 5 (65534→65535→0→1→2→3)
BEFORE (wrong): seq_dist = (SEQ_MAX - seq_num) + dst_seq_num seq_dist = (65535 - 3) + 65534 = 131066 (huge wrong number!)
AFTER (correct): seq_dist = (SEQ_MAX - dst_seq_num) + seq_num + 1 seq_dist = (65535 - 65534) + 3 + 1 = 5
The +1 accounts for the transition from 65535→0 being one step, not zero.
Verification that circular buffer cleaning is not broken:
The seq_dist value is used to determine whether the new packet is: a) Within the circular buffer window (seq_dist < KNET_CBUFFER_SIZE) b) Far enough to require full buffer clear (seq_dist > threshold) c) Should trigger incremental cleaning (fall through case)
Test case 1 - Normal sequential packet: dst_seq_num = 1000, seq_num = 1005, expected distance = 5
BEFORE: seq_dist = -5 (unsigned overflow ~65530) → Incorrectly clears entire buffer for normal sequential packets!
AFTER: seq_dist = 5 → Correctly identifies packet as within buffer window, no clearing needed
Test case 2 - Wraparound (close distance): dst_seq_num = 65534, seq_num = 3, expected distance = 5
BEFORE: seq_dist = 131066 → Falls through to circular buffer cleaning code incorrectly
AFTER: seq_dist = 5 → Correctly identifies packet as within buffer window
Test case 3 - Large jump requiring buffer clear: dst_seq_num = 1000, seq_num = 50000, expected distance = 49000
BEFORE: seq_dist = -49000 (unsigned ~16536) → Clears buffer (correct by accident)
AFTER: seq_dist = 49000 → Clears buffer (correct by design)
The circular buffer cleaning code (lines 673-684) uses seq_num and dst_seq_num directly via modulo operations to find buffer positions. It does not use seq_dist for position calculations, only for the threshold check to determine whether to run. The fix corrects the threshold logic without affecting the position calculations.
Signed-off-by: Fabio M. Di Nitto fdinitto@redhat.com Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com
Commit: a465037f8c87dffe0630b7bd2065db8caee5a5e9 https://github.com/kronosnet/kronosnet/commit/a465037f8c87dffe0630b7bd2065db... Author: Fabio M. Di Nitto fdinitto@redhat.com Date: 2026-05-21 (Thu, 21 May 2026)
Changed paths: M libknet/tests/Makefile.am A libknet/tests/int_seq_wraparound_stress.c
Log Message: ----------- [tests] add comprehensive sequence number wraparound stress test
Add int_seq_wraparound_stress_test to verify correct handling of sequence number wraparound, packet loss, and out-of-order delivery in defragmentation.
Test scenarios:
1. Normal sequential with 30% packet loss - verifies basic packet loss handling 2. Wraparound boundary (65533-65535, 0-4) - tests wraparound at SEQ_MAX with loss 3. Large sequence jump (> KNET_CBUFFER_SIZE) - tests jumps exceeding buffer size 4. Out-of-order fragment delivery - tests fragments arriving in reverse order 5. Out-of-order packet delivery - tests complete packets arriving backwards (1000→1001→999) 6. Extreme loss beyond window - 5000 packet gap exceeding KNET_CBUFFER_SIZE (4096) 7. Wraparound with extreme loss - 5636 packet gap across wraparound boundary 8. Multiple wraparound cycles - rapid cycling with different loss patterns, verifies duplicate detection (17 unique packets delivered, 5 duplicates rejected)
Tests use inject_packet() to simulate realistic network conditions including packet loss, reordering, incomplete transmissions, and insane scenarios that verify robustness even under conditions that shouldn't occur in practice.
Signed-off-by: Fabio M. Di Nitto fabbione@kronosnet.org Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com
Compare: https://github.com/kronosnet/kronosnet/compare/fc73bf1486d5%5E...a465037f8c8...
To unsubscribe from these emails, change your notification settings at https://github.com/kronosnet/kronosnet/settings/notifications