This series addresses several issues in the pcapng library and improves
test coverage.
Bug Fixes:
Patches 1-3 fix potential issues with string handling in the pcapng
administrative APIs. The pcapng file format uses 16-bit length fields
for option data, but the library did not validate input string lengths,
and used fixed-size stack buffers that could be overrun by large
comments or metadata strings.
Patch 1 adds length validation against the format's 16-bit limit
Patch 2 replaces fixed stack buffers with dynamic allocation
Patch 3 handles the case where comment options exceed available
mbuf tailroom by chaining an additional mbuf segment
Performance:
Patch 4 optimizes timestamp conversion by replacing division operations
with shift-multiply arithmetic, following the approach used by the Linux
kernel vDSO. This eliminates expensive divides from the packet capture
hot path.
Test Improvements:
Patch 5 improves the pcapng unit test coverage by exercising comment
options with varied test strings, varying packet sizes to test more copy
logic paths, and ensuring the test runs long enough to verify 32-bit TSC
wraparound handling.
v5:
- Fix missing commas in test string array (AI review feedback)
- Reorder patches to put library changes before test changes
v4:
- Handle case where clang wants parenthesis for multi-line string
constants
- Add one longer comment test case
v3:
- More thorough testing
- Passed AI review
Stephen Hemminger (5):
pcapng: add length checks to string arguments
pcapng: use malloc instead of fixed buffer size
pcapng: add additional mbuf if space required on copy
pcapng: improve performance of timestamping
test: add more tests for pcapng
app/test/test_pcapng.c | 145 ++++++++++++++++++++++++++++++----------
lib/pcapng/rte_pcapng.c | 145 +++++++++++++++++++++++++++++-----------
lib/pcapng/rte_pcapng.h | 8 ++-
3 files changed, 220 insertions(+), 78 deletions(-)
--
2.51.0