Skip to content

ethtool: add RX flow steering rule and table queries - #1233

Merged
aboch merged 4 commits into
vishvananda:mainfrom
aarcamp:pr/ac/ethtool-ntuple-get
Oct 27, 2026
Merged

aboch merged 4 commits into
vishvananda:mainfrom
aarcamp:pr/ac/ethtool-ntuple-get

Conversation

@aarcamp

@aarcamp aarcamp commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Add NetDevRxFlowGet to read installed RX flow steering rules. Add NetDevRxFlowActionGet to inspect rule actions. Add NetDevRxFlowTableGet to query rule count, table capacity and automatic placement support.

These queries let callers reuse existing rules or choose valid insertion locations. Unit tests cover decoding, validation and both ethtool_rxnfc ABI layouts.

Validated on ConnectX-7 with IPv4/IPv6 rules, table exhaustion/recovery, and reuse of existing rules across Cilium agent restarts.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Added ways to view receive flow-table capacity and special rule locations.
    • Added details for individual receive-flow rules, including queue, discard, and Wake-on-LAN actions.
    • Added support for reading Ethernet, TCP/UDP IPv4, and TCP/UDP IPv6 flow matches.
  • Bug Fixes
    • IPv4-mapped IPv6 addresses are now correctly rejected where IPv6 addresses are unsupported.
    • Unsupported flow actions, extensions, and rule types are reported as not implemented.
    • Receive-flow insertion accepts direct queue actions; other action types are reported as not implemented.

Add NetDevRxFlowGet to read a rule by location and decode its match,
target queue and location into the types used by NetDevRxFlowInsert.

Return an error wrapping ErrNotImplemented for unsupported match criteria
and actions, so callers can distinguish unsupported rules from failures
reading them.

Honor extension flags and apply the existing matcher validation,
including its rejection of IPv4-mapped IPv6 addresses. Test the decoder
with distinct masks and active and ignored extension fields.

Clarify the existing IPv6 input errors and the limited coverage of
the loopback smoke test.

Signed-off-by: Aaron Campbell <aaron@monkey.org>
Derive the rule-location buffer capacity from GRXCLSRLALL and rule_cnt
instead of passing it separately. This lets the shared ioctl helper
handle rule-table queries while keeping other commands fixed-size.

Update the existing list caller and ABI tests.

Signed-off-by: Aaron Campbell <aaron@monkey.org>
Add NetDevRxFlowTableGet to report the installed rule count, table size
and support for automatic location selection with RX_CLS_LOC_ANY.
Drivers may reject explicit locations or other special values.

Some drivers, including mlx5, report the size only with GRXCLSRLALL.
Follow ethtool and query it when the count reply omits the size, even
for an empty table. Preserve the automatic-placement flag from the
count reply.

Test generic driver replies, changing rule counts and ioctl failures.
Return those failures without retries.

Signed-off-by: Aaron Campbell <aaron@monkey.org>
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 95393719-4ee1-4dce-a587-a362cc6ff23a
Commits

Reviewing files that changed from the base of the PR and between 0af512f and 4832fd3.

Files selected for processing: 2
  • ethtool_ntuple_linux.go
  • ethtool_ntuple_linux_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

The Linux RX flow implementation adds APIs to retrieve flow-table metadata, decode rule actions, and retrieve supported rules as typed values. It also updates list serialization and IPv6 validation, with tests for parsing, retrieval, unsupported encodings, and loopback behavior.

Changes: RX Flow Retrieval

Layer / File(s) Summary
RX flow serialization and validation
ethtool_ntuple_linux.go, ethtool_ntuple_linux_test.go
The list serializer now derives location capacity from the request. IPv6 validation rejects IPv4 and IPv4-mapped addresses. Insertion accepts queue-only actions. Tests cover serializer updates, action validation, IPv6 validation, and loopback outcomes.
Table and action retrieval
ethtool_ntuple_linux.go, ethtool_ntuple_linux_test.go
Adds table metadata and action types and getters. Table retrieval falls back to a rule-list request when the count response has no size. Tests cover table parsing, fallback, ioctl errors, and action encodings.
Typed RX flow rule decoding
ethtool_ntuple_linux.go, ethtool_ntuple_linux_test.go
Adds decoding for Ethernet and TCP/UDP IPv4 and IPv6 rules. Tests cover round trips, unsupported actions and extensions, and mapped IPv6 rejection.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Possibly related PRs

Suggested reviewers: aboch, acamatcisco

Merge Risk: Minimal · up to 4832f

No actionable issue remains from this review; the change is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 39 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: adding RX flow steering rule and flow-table query APIs.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown

Add Carrot credits or activate Agent usage billing to use Autofix

Comment thread ethtool_ntuple_linux.go Resolved
Add NetDevRxFlowActionGet to report a rule's queue, RSS context, virtual
function, drop or Wake-on-LAN action independently of its match criteria.
This lets callers inspect rules that NetDevRxFlowGet does not support.

Move Queue into NetDevRxFlow.Action so the rule's action is represented
in one place. Keep insertion and NetDevRxFlowGet limited to direct queue
actions, and reject other insertion actions before issuing the ioctl.
Test queue-only actions and rejection of other action fields.

Decode the special ring_cookie actions before the RSS flag and document
that queue indices are relative to the VF when one is selected. Extend
the action tests and unsupported-device smoke test.

Reject unsupported action bits instead of silently interpreting
driver-specific encodings as ordinary queue actions.

Signed-off-by: Aaron Campbell <aaron@monkey.org>
@aarcamp
aarcamp force-pushed the pr/ac/ethtool-ntuple-get branch from 0af512f to 4832fd3 Compare October 26, 2026 11:00
@aboch

aboch commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks @aarcamp please squash the commits into one

@aarcamp

aarcamp commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @aarcamp please squash the commits into one

I can do this, but each commit is already logically coherent, do you still want me to? FWIW I made 4 commits so each change could be reviewed independently, but posted as one PR to cut down on paperwork. :)

@aboch

aboch commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

LGTM

@aboch
aboch merged commit e536899 into vishvananda:main Oct 27, 2026
3 checks passed
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