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

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Thu Oct 15 14:43:57 CEST 2026


Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/171408

_AI Code Review_

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

# AF_PACKET PMD Test and Driver Enhancements Review

## ERRORS

None.

## WARNINGS

**Patch 2/4: net/af_packet: filter Rx of outgoing packets in the PMD**

1. **Missing documentation of devarg value range and default**
   - Line: `doc/guides/nics/af_packet.rst:28-29`
   ```rst
   *   ``ignore_outgoing`` - ``rte_eth_rx_burst()`` returns only incoming
       packets (optional, disabled by default);
   ```
   The documentation states "disabled by default" but does not explicitly state the valid values are `0` and `1`.
   Other devargs in the same file document their valid values (e.g., `qdisc_bypass=<0|1>`).
   
   **Suggested fix:** Change to:
   ```rst
   *   ``ignore_outgoing`` - set to ``1`` to make ``rte_eth_rx_burst()`` return only incoming
       packets (optional, ``0|1``, default ``0``);
   ```

**Patch 4/4: net/af_packet: use kernel to filter multi-queue Rx**

2. **Unconditional shift of fanout_arg may produce wrong value if flag is already set**
   - Line: `drivers/net/af_packet/rte_eth_af_packet.c:1009`
   ```c
   if (ignore_outgoing != 0 && nb_queues > 1)
       fanout_arg |= PACKET_FANOUT_FLAG_IGNORE_OUTGOING << 16;
   ```
   The flag `PACKET_FANOUT_FLAG_IGNORE_OUTGOING` is defined as `0x4000`.
   Shifting it left by 16 bits produces `0x40000000`.
   This is ORed into `fanout_arg` which earlier (line 986-995) was initialized from `fanout_mode`,
   a value in the range 0-5 for the algorithm type in the low 16 bits.
   
   The shift is correct: kernel expects the flags in the upper 16 bits of the `int` argument,
   and this puts `0x4000` into bits 30-14, which is the flags field.
   However, if this code were ever extended to set other fanout flags before this point,
   a second `|=` could clobber them.
   
   **Suggested fix:** Use a named intermediate or add a comment clarifying the flags field,
   or ensure all flag-setting happens in one place.
   Example:
   ```c
   /* Fanout flags go in upper 16 bits; algorithm type in lower 16 */
   uint32_t fanout_flags = 0;
   if (ignore_outgoing != 0 && nb_queues > 1)
       fanout_flags |= PACKET_FANOUT_FLAG_IGNORE_OUTGOING;
   fanout_arg |= fanout_flags << 16;
   ```
   
   This is a maintainability concern, not a current bug, since no other fanout flags are set.

## INFO

**Patch 1/4: test/af_packet: ignore stray packets in loopback test**

No issues. The test enhancement correctly tags frames and counts only matching ones,
addressing flakiness from kernel-injected packets.

**Patch 2/4: net/af_packet: filter Rx of outgoing packets in the PMD**

The PMD-side filtering logic is correct:
- `sll->sll_pkttype == PACKET_OUTGOING` identifies outgoing frames
- The check occurs before mbuf allocation, avoiding resource waste
- The test correctly verifies both `ignore_outgoing=0` and `=1` behavior
- The test distinguishes incoming (FD_MAC_TAG) from outgoing (DEV_MAC_TAG) frames

**Patch 3/4: net/af_packet: use kernel to filter single-queue Rx**

The use of `PACKET_IGNORE_OUTGOING` for single-queue ports is correct:
- The socket option is set only when `nb_queues == 1` and `ignore_outgoing != 0`
- The PMD-side filtering is disabled in this case (`rx_queue->ignore_outgoing = ignore_outgoing != 0 && nb_queues > 1`)
- The documentation correctly notes that `PACKET_IGNORE_OUTGOING` does not work with fanout groups

**Patch 4/4: net/af_packet: use kernel to filter multi-queue Rx**

The opportunistic use of `PACKET_FANOUT_FLAG_IGNORE_OUTGOING` is correct:
- The flag is set for all kernel versions; kernels before 6.2 ignore it
- The PMD-side filtering remains as a fallback for older kernels
- The `#ifndef` guard allows building on headers that lack the definition

One observation: the patch does not update the PMD-side filtering condition to account for the possibility
that the kernel flag was effective. The line:
```c
rx_queue->ignore_outgoing = ignore_outgoing != 0 && nb_queues > 1;
```
remains unchanged from patch 3. This is acceptable as a universal fallback:
on kernel 6.2+ the kernel filters and the PMD check never triggers because no outgoing packets reach the socket;
on older kernels the PMD check catches them. The redundant check on 6.2+ is harmless (no packets to skip)
and keeps the code simple.

Review-Result: WARNING


More information about the test-report mailing list