Skip to content

[PWCI] "test: new test for null PMD"#610

Open
ovsrobot wants to merge 3 commits intomainfrom
series_36997
Open

[PWCI] "test: new test for null PMD"#610
ovsrobot wants to merge 3 commits intomainfrom
series_36997

Conversation

@ovsrobot
Copy link
Owner

@ovsrobot ovsrobot commented Jan 8, 2026

Auto-submission for "http://patchwork.dpdk.org/project/dpdk/list/?series=36997"

Summary by Sourcery

Add comprehensive unit tests for the null Ethernet PMD and adjust supporting utilities to better handle larger packet sizes and device capabilities.

New Features:

  • Introduce a null PMD unit test suite covering RX/TX behavior, stats, link status, MTU and device info, RSS/RETA configuration, MAC and mode handling, and multi-threaded TX on MT-lockfree queues.

Bug Fixes:

  • Correct packet burst generator APIs to support 16-bit packet lengths and avoid overflow in segment length calculations.
  • Align null PMD device info with API expectations by using UINT32_MAX for max_rx_pktlen and removing invalid min_rx_bufsize reporting.

Enhancements:

  • Wire the new null PMD tests into the test app build with appropriate dependencies.

Summary by CodeRabbit

  • New Features

    • Added comprehensive test suite for null PMD validating RX/TX behavior, packet handling, device configuration, and multi-threaded operations.
  • Improvements

    • Enhanced packet generator to support larger packet sizes and improved remainder handling across packet segments.
    • Simplified device information handling and cleaned up initialization logic.
  • Chores

    • Added test file build dependencies for required modules.

✏️ Tip: You can customize this high-level summary in your review settings.

The info_get callback doesn't need to check its args
since already done by ethdev. The maximum packet size allowed
by this dummy driver is limited only by the maximum values
in mbuf fields.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: 0-day Robot <robot@bytheb.org>
The packet length in packet burst generator was uint8_t which
limited usefulness for testing larger packet sizes.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Add a test for null PMD including different packet sizes
and lockless transmit.

Original version of  test was generated with Claude based off
of existing test_pmd_ring.c with some cleanup afterwards.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: 0-day Robot <robot@bytheb.org>
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 8, 2026

Reviewer's Guide

Adds a comprehensive unit test suite for the null PMD, adjusts the packet burst generator to support larger packet lengths and clearer per-segment sizing, and refines null PMD device info reporting to better match its capabilities, wiring the new test into the app/test build.

Sequence diagram for null PMD test using packet burst generator

sequenceDiagram
    actor Tester
    participant NullPmdTest
    participant EAL as EalInit
    participant EthDev as rte_eth_dev
    participant PBGen as PacketBurstGenerator
    participant NullPMD as NullPmdDriver

    Tester->>NullPmdTest: run_all_null_pmd_tests()
    NullPmdTest->>EAL: rte_eal_init()
    EAL-->>NullPmdTest: init_result

    NullPmdTest->>EthDev: rte_eth_dev_configure(port_id, rx_conf, tx_conf)
    EthDev-->>NullPmdTest: status

    NullPmdTest->>EthDev: rte_eth_dev_start(port_id)
    EthDev-->>NullPmdTest: status

    NullPmdTest->>PBGen: init(total_pktlen, segment_sizes, nb_segs)
    PBGen-->>NullPmdTest: status

    loop for_each_test_case
        NullPmdTest->>PBGen: generate_burst(mbufs, nb_pkts)
        PBGen-->>NullPmdTest: mbufs

        NullPmdTest->>EthDev: rte_eth_tx_burst(port_id, queue_id, mbufs, nb_pkts)
        EthDev->>NullPMD: null_tx_burst()
        NullPMD-->>EthDev: nb_tx
        EthDev-->>NullPmdTest: nb_tx

        NullPmdTest->>EthDev: rte_eth_rx_burst(port_id, queue_id, mbufs, nb_pkts)
        EthDev->>NullPMD: null_rx_burst()
        NullPMD-->>EthDev: nb_rx(usually_zero)
        EthDev-->>NullPmdTest: nb_rx

        NullPmdTest->>EthDev: rte_eth_dev_info_get(port_id, dev_info)
        EthDev->>NullPMD: eth_dev_info(dev, dev_info)
        NullPMD-->>EthDev: dev_info(max_rx_pktlen=UINT32_MAX,...)
        EthDev-->>NullPmdTest: dev_info

        NullPmdTest->>NullPmdTest: assert_capabilities_and_behavior()
    end

    NullPmdTest->>EthDev: rte_eth_dev_stop(port_id)
    EthDev-->>NullPmdTest: status
    NullPmdTest-->>Tester: report_results
Loading

Class diagram for null PMD device info and packet burst generator changes

classDiagram
    class rte_eth_dev {
        +rte_eth_dev_data* data
    }

    class rte_eth_dev_data {
        +void* dev_private
    }

    class pmd_internals {
        +rx_null_queue rx_null_queues[]
        +tx_null_queue tx_null_queues[]
        +uint16_t reta_size
    }

    class rte_eth_dev_info {
        +uint32_t max_mac_addrs
        +uint32_t max_rx_pktlen
        +uint16_t max_rx_queues
        +uint16_t max_tx_queues
        +uint64_t tx_offload_capa
        +uint16_t reta_size
    }

    class PacketBurstGeneratorConfig {
        +uint32_t total_pktlen
        +uint16_t segment_sizes[]
        +uint1616_t nb_segs
    }

    class PacketBurstGenerator {
        +PacketBurstGeneratorConfig config
        +int init(uint32_t total_pktlen, uint16_t segment_sizes[], uint16_t nb_segs)
        +int generate_burst(struct_rte_mbuf* mbufs[], uint16_t nb_pkts)
    }

    class NullPmdTest {
        +int setup()
        +int test_basic_tx_rx()
        +int test_max_rx_pktlen_limits()
        +int test_segmented_packets()
        +int teardown()
    }

    rte_eth_dev --> rte_eth_dev_data : has
    rte_eth_dev_data --> pmd_internals : dev_private
    pmd_internals --> rte_eth_dev_info : populates
    NullPmdTest --> rte_eth_dev : configures
    NullPmdTest --> PacketBurstGenerator : uses
    PacketBurstGenerator --> PacketBurstGeneratorConfig : has
    rte_eth_dev_info <.. NullPmdTest : validates
Loading

Architecture/flow diagram for app/test null PMD test wiring

flowchart LR
    subgraph AppTest["app/test binary"]
        direction TB
        TestMain["test/main.c: test registry"]
        NullPmdTestFile["test_pmd_null.c: null PMD tests"]
        PBGenFile["packet_burst_generator.c"]
    end

    Meson["app/test/meson.build: test_pmd_null integration"]
    DpdkCore["DPDK core (EAL, ethdev)"]
    NullPMD["drivers/net/null: null PMD"]

    Meson --> AppTest
    TestMain --> NullPmdTestFile
    NullPmdTestFile --> PBGenFile

    NullPmdTestFile --> DpdkCore
    DpdkCore --> NullPMD

    NullPMD --> DpdkCore
    DpdkCore --> NullPmdTestFile

    PBGenFile --> DpdkCore
Loading

File-Level Changes

Change Details Files
Update packet burst generator APIs to use 16-bit packet length and precomputed segment sizes for multi-segment mbufs.
  • Change pkt_len parameter type from uint8_t to uint16_t in the packet burst generator functions and their declarations to allow larger packets.
  • Refactor local variables so that per-segment length and last-segment length are computed once (pkt_seg_data_len and last_seg_data_len) instead of recalculating in the loop.
  • Use last_seg_data_len when setting the data_len of the final segment in multi-segment packets for both IPv4/UDP and generic protocol burst generators.
app/test/packet_burst_generator.c
app/test/packet_burst_generator.h
Align null PMD dev_info reporting with modern ethdev expectations and remove redundant null checks.
  • Remove explicit NULL checks for dev and dev_info in eth_dev_info, relying on the ethdev API contract that they are valid.
  • Initialize the pmd_internals pointer directly from dev->data->dev_private at declaration time.
  • Replace dev_info->max_rx_pktlen assignment of (uint32_t)-1 with UINT32_MAX and drop unused dev_info->min_rx_bufsize initialization.
drivers/net/null/rte_eth_null.c
Introduce a full-featured null PMD unit test suite and integrate it into the test app build.
  • Add test_pmd_null.c implementing setup/teardown for a vdev-backed null port and a suite of tests covering RX/TX behavior, stats, custom size and modes (copy, no-rx), link status, dev info (including MTU and offloads), multi-burst behavior, RSS/RETA configuration, stats reset, MAC address operations, promiscuous/allmulticast defaults, and multi-threaded TX using MT_LOCKFREE.
  • Provide helper routines to create/configure null vdev ports and to bulk-allocate mbufs with randomized valid lengths.
  • Register the new test suite as a fast test (null_pmd_autotest) and hook it into meson by adding the appropriate dependencies for test_pmd_null.c (net_ring, ethdev, bus_vdev).
app/test/test_pmd_null.c
app/test/meson.build

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

This PR adds a comprehensive test suite for the null PMD (test_pmd_null.c), updates packet burst generator functions to support larger packet sizes by changing the pkt_len parameter from uint8_t to uint16_t, simplifies the null PMD device info function, and configures build dependencies for the new tests.

Changes

Cohort / File(s) Summary
Build Configuration
app/test/meson.build
Added test_pmd_null.c with dependencies on net_ring, ethdev, and bus_vdev
Packet Burst Generator
app/test/packet_burst_generator.h, app/test/packet_burst_generator.c
Updated generate_packet_burst and generate_packet_burst_proto function signatures to use uint16_t for pkt_len parameter (previously uint8_t). Implemented segmentation logic that computes per-segment data length and handles remainder in final segment via last_seg_data_len.
Null PMD Test Suite
app/test/test_pmd_null.c
New comprehensive unit test file (968 lines) covering null PMD lifecycle, RX/TX behavior, mbuf handling, packet sizing, link status, device info, multi-burst operations, RSS/RETA, MAC operations, stats, and multi-threaded TX scenarios with helper functions and test framework.
Null PMD Driver
drivers/net/null/rte_eth_null.c
Simplified eth_dev_info function by removing explicit NULL-check and using direct initialization for internals. Changed max_rx_pktlen to UINT32_MAX and removed min_rx_bufsize assignment.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~40 minutes

Poem

🐰 Hops of code, a test suite springs to life,
Packets burst with newfound might and strife,
From eight-bit bounds to sixteen-bit dreams,
The null PMD glows with testing beams,
A rabbit's work, both thorough and precise! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective: adding a new test for the null PMD. It is concise, specific, and clearly summarizes the primary change in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • In test_mbuf_setup_burst, you're modifying m->buf_len and never setting pkt_len; it would be safer and more conventional to leave buf_len as allocated by the mempool and set both data_len and pkt_len to the chosen payload length to avoid unexpected behavior in other code paths.
  • In test_null_reta_config, the reta_conf array is sized using RTE_ETH_RSS_RETA_SIZE_128, but you index it using dev_info.reta_size; to avoid potential overflow if the null PMD's reta_size ever differs, consider allocating the array based on dev_info.reta_size (e.g., via dynamic allocation) or asserting that dev_info.reta_size <= RTE_ETH_RSS_RETA_SIZE_128.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `test_mbuf_setup_burst`, you're modifying `m->buf_len` and never setting `pkt_len`; it would be safer and more conventional to leave `buf_len` as allocated by the mempool and set both `data_len` and `pkt_len` to the chosen payload length to avoid unexpected behavior in other code paths.
- In `test_null_reta_config`, the `reta_conf` array is sized using `RTE_ETH_RSS_RETA_SIZE_128`, but you index it using `dev_info.reta_size`; to avoid potential overflow if the null PMD's `reta_size` ever differs, consider allocating the array based on `dev_info.reta_size` (e.g., via dynamic allocation) or asserting that `dev_info.reta_size <= RTE_ETH_RSS_RETA_SIZE_128`.

## Individual Comments

### Comment 1
<location> `app/test/test_pmd_null.c:189-192` </location>
<code_context>
+		uint16_t len;
+
+		/* Choose random length between ether min and available space */
+		len = rte_rand_max(rte_pktmbuf_tailroom(m) - RTE_ETHER_MIN_LEN)
+			+ RTE_ETHER_MIN_LEN;
+		m->data_len = len;
+		m->buf_len = len;
+	}
+	return 0;
</code_context>

<issue_to_address>
**issue (testing):** Random mbuf setup does not set pkt_len, which can make TX/statistics checks misleading

Here `data_len` and `buf_len` are updated but `pkt_len` is left at its previous value (often 0). For tests that rely on TX stats or PMD length handling (e.g., `test_null_tx_basic` and other stats checks), this can cause undercounted bytes and unrealistic mbufs. Please also set `m->pkt_len = len;` so these mbufs correctly represent single-segment packets.
</issue_to_address>

### Comment 2
<location> `app/test/test_pmd_null.c:615-624` </location>
<code_context>
+	struct rte_eth_rss_reta_entry64 reta_conf[RTE_ETH_RSS_RETA_SIZE_128 /
</code_context>

<issue_to_address>
**issue (bug_risk):** RETA test assumes reta_size ≤ RTE_ETH_RSS_RETA_SIZE_128 and may overflow the local array

In `test_null_reta_config`, `reta_conf` is statically sized for `RTE_ETH_RSS_RETA_SIZE_128 / RTE_ETH_RETA_GROUP_SIZE`, but `nreta` is derived from `dev_info.reta_size`. If `dev_info.reta_size` exceeds `RTE_ETH_RSS_RETA_SIZE_128`, `nreta` will be out of bounds and the test will write past `reta_conf`. Please either assert `dev_info.reta_size <= RTE_ETH_RSS_RETA_SIZE_128` before using `nreta`, or allocate `reta_conf` dynamically based on `dev_info.reta_size` (and free it).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +615 to +624
struct rte_eth_rss_reta_entry64 reta_conf[RTE_ETH_RSS_RETA_SIZE_128 /
RTE_ETH_RETA_GROUP_SIZE];
struct rte_eth_conf port_conf = {0};
uint16_t reta_port;
const uint16_t num_queues = 2;
unsigned int i, j, nreta;
uint16_t q;
int ret;

/* Create a new null device for RETA testing with multiple queues */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): RETA test assumes reta_size ≤ RTE_ETH_RSS_RETA_SIZE_128 and may overflow the local array

In test_null_reta_config, reta_conf is statically sized for RTE_ETH_RSS_RETA_SIZE_128 / RTE_ETH_RETA_GROUP_SIZE, but nreta is derived from dev_info.reta_size. If dev_info.reta_size exceeds RTE_ETH_RSS_RETA_SIZE_128, nreta will be out of bounds and the test will write past reta_conf. Please either assert dev_info.reta_size <= RTE_ETH_RSS_RETA_SIZE_128 before using nreta, or allocate reta_conf dynamically based on dev_info.reta_size (and free it).

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @app/test/meson.build:
- Line 144: Remove the extraneous 'net_ring' dependency from the test_pmd_null.c
entry in the meson build definition: update the dependency list for
'test_pmd_null.c' so it only contains ['ethdev', 'bus_vdev'] (remove 'net_ring')
to reflect that the test exercises only the null PMD.

In @app/test/test_pmd_null.c:
- Around line 176-195: In test_mbuf_setup_burst, don’t modify the mbuf’s buf_len
(it’s allocator-owned); remove the assignment to m->buf_len and instead set the
packet length metadata correctly by assigning m->pkt_len = len (keeping
m->data_len = len). Leave buf_len untouched so the mempool-managed buffer size
is not corrupted.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd60dcd and cd96006.

📒 Files selected for processing (5)
  • app/test/meson.build
  • app/test/packet_burst_generator.c
  • app/test/packet_burst_generator.h
  • app/test/test_pmd_null.c
  • drivers/net/null/rte_eth_null.c
🧰 Additional context used
🧬 Code graph analysis (2)
app/test/test_pmd_null.c (4)
lib/mbuf/rte_mbuf.c (1)
  • rte_pktmbuf_pool_create (280-287)
lib/ethdev/rte_ethdev.h (2)
  • rte_eth_rx_burst (6347-6406)
  • rte_eth_tx_burst (6686-6746)
lib/mbuf/rte_mbuf.h (2)
  • rte_pktmbuf_alloc_bulk (1068-1082)
  • rte_pktmbuf_tailroom (1629-1634)
lib/mempool/rte_mempool.c (1)
  • rte_mempool_avail_count (1021-1042)
app/test/packet_burst_generator.h (1)
app/test/packet_burst_generator.c (1)
  • generate_packet_burst_proto (303-430)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (16)
drivers/net/null/rte_eth_null.c (1)

301-304: LGTM!

The simplification is appropriate: inline initialization of internals is cleaner, and using UINT32_MAX instead of (uint32_t)-1 improves readability while being semantically equivalent. The removal of redundant null checks aligns with DPDK driver conventions where dev and dev_info are guaranteed valid by the caller.

app/test/packet_burst_generator.h (1)

61-72: LGTM!

The parameter type change from uint8_t to uint16_t for pkt_len correctly enables support for packet sizes beyond 255 bytes. This aligns with typical Ethernet MTU requirements and the implementation changes in the corresponding .c file.

app/test/packet_burst_generator.c (2)

219-230: Good refactoring for larger packet support.

The updated segment length calculation correctly handles remainder distribution to the last segment. However, there's no guard against nb_pkt_segs == 0, which would cause a division by zero at line 229.

Consider adding a defensive check or documenting the precondition that nb_pkt_segs >= 1:

🛡️ Optional: Add defensive check
 	/* Calculate per-segment data length */
+	if (nb_pkt_segs == 0)
+		return -1;
 	pkt_seg_data_len = pkt_len / nb_pkt_segs;
 	last_seg_data_len = pkt_seg_data_len + (pkt_len % nb_pkt_segs);

308-319: Consistent with generate_packet_burst changes.

The same segment length calculation logic is correctly applied here. The same consideration regarding nb_pkt_segs == 0 applies.

app/test/test_pmd_null.c (12)

1-35: Well-structured test header and constants.

The includes, constants, and global variables are appropriately defined for the test suite. The use of RTE_MAX_ETHPORTS as the initial invalid port_id is a good practice.


36-99: LGTM!

The helper functions properly encapsulate device creation and configuration. Error handling in create_null_port correctly cleans up on failure. The configure_null_port function follows standard DPDK port setup patterns.


101-139: LGTM!

Setup and teardown functions properly manage test resources. The teardown sequence correctly stops the device before closing and uninitializing.


231-276: LGTM!

The stats test properly resets counters, performs RX/TX operations, and verifies the expected packet counts. Good coverage of the stats_get and stats_reset functionality.


281-319: LGTM!

Good test coverage for the custom packet size configuration. The test properly creates a separate device instance, verifies the size, and cleans up.


324-389: LGTM!

Both mode tests (copy and no-rx) properly verify the expected behavior: copy mode allows RX, while no-rx mode returns zero packets on RX but still allows TX. Cleanup is correctly performed for each temporary port.


394-467: LGTM!

The link status test properly verifies state transitions and restarts the device for subsequent tests. The device info test validates key capabilities including MULTI_SEGS, MT_LOCKFREE, and RSS configuration values.


472-522: LGTM!

Good stress test for verifying consistent behavior across multiple burst operations. The cumulative stats verification ensures packet counts are accurately tracked.


528-690: LGTM!

Comprehensive RSS and RETA tests that properly configure multi-queue devices, update configurations, and verify the changes persist. The tests correctly handle the RSS prerequisite of multiple queues.


695-777: LGTM!

The stats reset, MAC address, and promiscuous/allmulticast tests are straightforward and verify expected null PMD behaviors correctly.


836-935: Good MT_LOCKFREE validation test.

The test properly verifies concurrent TX to a shared queue. The worker implementation correctly handles allocation failures and tracks transmission counts.

Minor note: The wait loop at lines 908-910 iterates over all worker lcores, not just the ones launched (limited to 4). This is safe but slightly wasteful. Consider breaking after waiting on num_workers lcores if performance matters.


937-968: LGTM!

The test suite is properly structured with setup/teardown hooks and comprehensive test case coverage. The REGISTER_FAST_TEST macro correctly registers it for the autotest framework.

'test_per_lcore.c': [],
'test_pflock.c': [],
'test_pie.c': ['sched'],
'test_pmd_null.c': ['net_ring', 'ethdev', 'bus_vdev'],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check if test_pmd_null.c uses any ring-related functionality
rg -n 'ring|net_ring' app/test/test_pmd_null.c || echo "No ring references found"

Repository: ovsrobot/dpdk

Length of output: 78


🏁 Script executed:

# Read the test_pmd_null.c file to see what it imports and uses
cat app/test/test_pmd_null.c

Repository: ovsrobot/dpdk

Length of output: 26070


🏁 Script executed:

# Check the meson.build context around line 144
sed -n '140,150p' app/test/meson.build

Repository: ovsrobot/dpdk

Length of output: 604


🏁 Script executed:

# Compare with test_pmd_ring.c dependencies in meson.build
sed -n '145,147p' app/test/meson.build

Repository: ovsrobot/dpdk

Length of output: 251


Remove unnecessary net_ring dependency from test_pmd_null.c.

The test file does not use the ring PMD at all—it exclusively tests the null PMD (net_null). The net_ring dependency was copied from test_pmd_ring.c and should be removed. The correct dependencies are ['ethdev', 'bus_vdev'].

🤖 Prompt for AI Agents
In @app/test/meson.build at line 144, Remove the extraneous 'net_ring'
dependency from the test_pmd_null.c entry in the meson build definition: update
the dependency list for 'test_pmd_null.c' so it only contains ['ethdev',
'bus_vdev'] (remove 'net_ring') to reflect that the test exercises only the null
PMD.

Comment on lines +176 to +195
static int
test_mbuf_setup_burst(struct rte_mbuf **bufs, unsigned int burst_size)
{
unsigned int i;

if (rte_pktmbuf_alloc_bulk(mp, bufs, burst_size) != 0)
return -1;

for (i = 0; i < burst_size; i++) {
struct rte_mbuf *m = bufs[i];
uint16_t len;

/* Choose random length between ether min and available space */
len = rte_rand_max(rte_pktmbuf_tailroom(m) - RTE_ETHER_MIN_LEN)
+ RTE_ETHER_MIN_LEN;
m->data_len = len;
m->buf_len = len;
}
return 0;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Bug: Incorrect modification of buf_len corrupts mbuf metadata.

Line 192 incorrectly sets m->buf_len = len. The buf_len field represents the total allocated buffer size and must not be modified after allocation—it's set by the mempool and remains constant. Only data_len and pkt_len should be modified to indicate actual packet data length.

This corruption could cause memory safety issues when the mbuf is freed or reused.

🐛 Proposed fix
 	for (i = 0; i < burst_size; i++) {
 		struct rte_mbuf *m = bufs[i];
 		uint16_t len;

 		/* Choose random length between ether min and available space */
 		len = rte_rand_max(rte_pktmbuf_tailroom(m) - RTE_ETHER_MIN_LEN)
 			+ RTE_ETHER_MIN_LEN;
 		m->data_len = len;
-		m->buf_len = len;
+		m->pkt_len = len;
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
static int
test_mbuf_setup_burst(struct rte_mbuf **bufs, unsigned int burst_size)
{
unsigned int i;
if (rte_pktmbuf_alloc_bulk(mp, bufs, burst_size) != 0)
return -1;
for (i = 0; i < burst_size; i++) {
struct rte_mbuf *m = bufs[i];
uint16_t len;
/* Choose random length between ether min and available space */
len = rte_rand_max(rte_pktmbuf_tailroom(m) - RTE_ETHER_MIN_LEN)
+ RTE_ETHER_MIN_LEN;
m->data_len = len;
m->buf_len = len;
}
return 0;
}
static int
test_mbuf_setup_burst(struct rte_mbuf **bufs, unsigned int burst_size)
{
unsigned int i;
if (rte_pktmbuf_alloc_bulk(mp, bufs, burst_size) != 0)
return -1;
for (i = 0; i < burst_size; i++) {
struct rte_mbuf *m = bufs[i];
uint16_t len;
/* Choose random length between ether min and available space */
len = rte_rand_max(rte_pktmbuf_tailroom(m) - RTE_ETHER_MIN_LEN)
RTE_ETHER_MIN_LEN;
m->data_len = len;
m->pkt_len = len;
}
return 0;
}
🤖 Prompt for AI Agents
In @app/test/test_pmd_null.c around lines 176 - 195, In test_mbuf_setup_burst,
don’t modify the mbuf’s buf_len (it’s allocator-owned); remove the assignment to
m->buf_len and instead set the packet length metadata correctly by assigning
m->pkt_len = len (keeping m->data_len = len). Leave buf_len untouched so the
mempool-managed buffer size is not corrupted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants