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.

v6:
  - AI review feedback
  - Simplify return value documentation for rte_pcapng_add_interface()
  - Add explanatory comment for debug-only validation in rte_pcapng_copy()
  - Adjust test comment frequency to 1% of packets for clearer intent
  - Add comment clarifying that zero-sized packets are acceptable in test

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: chain additional mbuf when comment exceeds tailroom
  pcapng: improve performance of timestamping
  test/pcapng: add tests for comments

 app/test/test_pcapng.c                 | 147 +++++++++++++++++------
 doc/guides/rel_notes/release_26_03.rst |   3 +
 lib/pcapng/rte_pcapng.c                | 160 ++++++++++++++++++-------
 lib/pcapng/rte_pcapng.h                |   7 +-
 4 files changed, 234 insertions(+), 83 deletions(-)

-- 
2.51.0

Reply via email to