Skip to content

fix: Get devlink parameters for the first device only#142

Merged
almaslennikov merged 1 commit intoMellanox:network-operator-26.1.xfrom
e0ne:devlink-params-pf-only
Jan 22, 2026
Merged

fix: Get devlink parameters for the first device only#142
almaslennikov merged 1 commit intoMellanox:network-operator-26.1.xfrom
e0ne:devlink-params-pf-only

Conversation

@e0ne
Copy link
Collaborator

@e0ne e0ne commented Jan 22, 2026

This will return PF parameters only if PF PCI address provided and VF parameters for VF PC address.

This will return PF parameters only if PF PCI address provided
and VF parameters for VF PC address.

Signed-off-by: Ivan Kolodiazhnyi <ikolodiazhny@nvidia.com>
@github-actions
Copy link

Thanks for your PR,
To run vendors CIs, Maintainers can use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs, Maintainers can use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@greptile-apps
Copy link

greptile-apps bot commented Jan 22, 2026

Greptile Summary

Added deduplication logic to GetDevlinkDeviceParams to ensure only parameters for the specified device are returned. The function now keeps only the first occurrence of each parameter by name before processing, which prevents returning duplicate or incorrect parameters when querying a specific PCI address (PF or VF).

  • Fixed issue where devlink parameters from multiple devices could be returned for a single PCI address query
  • Added import for github.com/vishvananda/netlink package
  • Implemented deduplication using a map to track seen parameter names
  • The fix ensures PF parameters are returned for PF addresses and VF parameters for VF addresses

Confidence Score: 4/5

  • This PR is safe to merge with low risk
  • The change adds a straightforward deduplication step that prevents duplicate parameters from being processed. The logic is simple and defensive, using a standard map-based approach to track seen parameter names. The change only affects the parameter retrieval flow and doesn't modify any existing behavior beyond fixing the duplicate issue.
  • No files require special attention

Important Files Changed

Filename Overview
pkg/host/internal/network/network.go Added deduplication logic to keep only first occurrence of each devlink parameter by name before merging

Sequence Diagram

sequenceDiagram
    participant Caller
    participant GetDevlinkDeviceParams
    participant netlinkLib
    participant Deduplication
    participant Merging

    Caller->>GetDevlinkDeviceParams: Request params for PCI address
    GetDevlinkDeviceParams->>netlinkLib: DevlinkGetDeviceParams(bus, pciAddr)
    netlinkLib-->>GetDevlinkDeviceParams: Return []*DevlinkParam (may have duplicates)
    
    GetDevlinkDeviceParams->>Deduplication: Deduplicate by name
    Note over Deduplication: Keep only first occurrence<br/>of each param name
    Deduplication-->>GetDevlinkDeviceParams: pfParams (deduplicated list)
    
    GetDevlinkDeviceParams->>Merging: Merge params by name and CMODE
    Note over Merging: Group by name, then by CMODE<br/>(runtime, driverinit, permanent)
    Merging-->>GetDevlinkDeviceParams: devlinkParams (final list)
    
    GetDevlinkDeviceParams-->>Caller: Return []DevlinkParam
Loading

@greptile-apps
Copy link

greptile-apps bot commented Jan 22, 2026

Greptile's behavior is changing!

From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

@almaslennikov
Copy link
Collaborator

Can there be a case where values on different PFs are different?

@almaslennikov almaslennikov merged commit 212232b into Mellanox:network-operator-26.1.x Jan 22, 2026
11 of 14 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