|SUCCESS| [v7, 4/4] net/af_packet: use kernel to filter multi-queue Rx

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Fri Oct 16 23:51:31 CEST 2026


Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/171577

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-10-16

# DPDK Patch Review

## PATCH 1/4: test/af_packet: ignore stray packets in loopback test

### Errors

None.

### Warnings

None.

### Info

**Patch purpose:** Test robustness improvement.
This patch tags test frames with a recognizable source MAC and counts only matching frames in the loopback test, filtering out stray IPv6 ND packets or other unrelated traffic that may appear on the TAP interface. The change is test-only and does not affect the PMD itself.

---

## PATCH 2/4: net/af_packet: filter Rx of outgoing packets in the PMD

### Errors

None.

### Warnings

**Release notes formatting:**
The release notes entry says "Added ``ignore_outgoing``" but the subsequent patch (3/4) changes the phrasing to "Added ``ignore_outgoing`` devarg". The word "devarg" should be included here for consistency, or the entry should be written once in the final form. However, since patch 3/4 corrects this, it is not a hard blocker.

### Info

**New devarg added:**
The patch adds the `ignore_outgoing=<0|1>` devarg to control whether `rte_eth_rx_burst()` returns outgoing packets. The default is 0 (existing behavior: return both incoming and outgoing). Documentation is updated in `doc/guides/nics/af_packet.rst` and release notes are added.

**Test coverage:**
The patch includes comprehensive functional tests:
- `test_af_packet_invalid_ignore_outgoing()` tests rejection of invalid values
- `test_af_packet_ignore_outgoing_single_queue()` and `test_af_packet_ignore_outgoing_multi_queue()` test both `ignore_outgoing=0` and `ignore_outgoing=1` with single and multiple queues

The test approach is sound:
- Uses two vdevs (one TX, one RX) to generate outgoing traffic on the TAP
- Writes directly to the TAP fd to generate incoming traffic
- Verifies that outgoing frames are filtered when `ignore_outgoing=1` and not filtered when `ignore_outgoing=0`
- Verifies that incoming frames are received in both cases

**PMD implementation:**
The filtering is done in `eth_af_packet_rx()` by checking `sll_pkttype == PACKET_OUTGOING` and skipping such frames before allocating an mbuf. This approach is efficient: it avoids mbuf allocation for filtered frames.

**Parsing:**
The `parse_uint()` call with `max_val=1` correctly rejects values >1.

---

## PATCH 3/4: net/af_packet: use kernel to filter single-queue Rx

### Errors

None.

### Warnings

None.

### Info

**Kernel optimization for single queue:**
When `ignore_outgoing=1` and `nb_queues == 1`, the patch sets the `PACKET_IGNORE_OUTGOING` socket option (available since Linux 4.20, guaranteed present in DPDK's minimum supported kernel 5.4). This moves filtering to the kernel, avoiding the PMD-side check.

**Fanout limitation:**
The socket option does not work for sockets in a fanout group (multi-queue scenario), so the patch only sets it when `nb_queues == 1`. For multi-queue, the PMD-side filtering from patch 2/4 remains in effect.

**Logic correctness:**
- `PACKET_IGNORE_OUTGOING` is set when `ignore_outgoing != 0 && nb_queues == 1`
- `rx_queue->ignore_outgoing` (PMD-side check) is set to `ignore_outgoing != 0 && nb_queues > 1`

These are mutually exclusive and cover all cases when `ignore_outgoing=1`:
- Single queue: kernel filters, PMD does not
- Multi-queue: kernel cannot filter (fanout), PMD does

**Documentation updated:**
`doc/guides/nics/af_packet.rst` is updated to note that `PACKET_IGNORE_OUTGOING` is set for single-queue ports. Release notes are updated to change "Added ``ignore_outgoing``" to "Added ``ignore_outgoing`` devarg" (the phrasing issue from patch 2/4 is resolved here).

---

## PATCH 4/4: net/af_packet: use kernel to filter multi-queue Rx

### Errors

None.

### Warnings

None.

### Info

**Kernel optimization for multi-queue (opportunistic):**
Since Linux 6.2, the kernel supports `PACKET_FANOUT_FLAG_IGNORE_OUTGOING` for fanout groups. The patch sets this flag opportunistically for all kernel versions when `ignore_outgoing=1 && nb_queues > 1`. Older kernels (5.4-6.1) ignore the flag, and the PMD-side filtering from patch 2/4 serves as a fallback.

**Feature detection:**
There is no way to query kernel support for this flag. The patch documents that the flag takes effect from Linux 6.2 and that the PMD filtering remains as a fallback for older kernels. This is acceptable: the flag is harmless on older kernels, and the functionality is correct in all cases.

**Logic correctness after all patches:**
After applying all four patches, the filtering behavior is:
- Single queue + `ignore_outgoing=1`: `PACKET_IGNORE_OUTGOING` set, no PMD filtering
- Multi-queue + `ignore_outgoing=1`: `PACKET_FANOUT_FLAG_IGNORE_OUTGOING` set (takes effect on Linux >=6.2), PMD filtering as fallback
- `ignore_outgoing=0`: no filtering at all (existing behavior)

**Documentation updated:**
`doc/guides/nics/af_packet.rst` is updated to document the multi-queue behavior and the Linux 6.2 requirement. The note about PMD filtering as a fallback is clear.

---

## Overall Assessment

The patch series is well-structured, well-tested, and correct.

**Strengths:**
- Comprehensive test coverage with functional tests for all scenarios
- Clear documentation of kernel version requirements and fallback behavior
- Efficient implementation (avoids mbuf allocation for filtered frames)
- Backward compatible (default `ignore_outgoing=0` preserves existing behavior)
- Opportunistic kernel optimization where available

**No correctness issues identified:**
- Resource management is correct (mbufs are freed in all paths)
- Error handling is appropriate
- No race conditions or undefined behavior
- Boolean and integer comparisons are explicit where required by style

**No style violations identified:**
- C coding style is correct
- API tags are not applicable (internal PMD code, no new public API)
- Release notes are updated appropriately

Review-Result: CLEAN


More information about the test-report mailing list