Skip to content

Enable LLDP-MED for DPUs#3692

Draft
stoo-davies wants to merge 2 commits into
NVIDIA:mainfrom
stoo-davies:dpu-lldp-med-enable
Draft

Enable LLDP-MED for DPUs#3692
stoo-davies wants to merge 2 commits into
NVIDIA:mainfrom
stoo-davies:dpu-lldp-med-enable

Conversation

@stoo-davies

Copy link
Copy Markdown
Contributor

Adds code to forge-dpu-agent to do two things..

  1. Enable LLDP-MED in the /etc/defaults/lldp file
  2. Removes the interface restriction that was preventing it from running on the management interface.

These changes are for automated cable validation.

Related issues

#3204

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Additional Notes

Tested on a BF3.

Signed-off-by: Stoo Davies <189670495+stoo-davies@users.noreply.github.com>
@stoo-davies
stoo-davies requested a review from a team as a code owner July 17, 2026 20:19
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 43b95b6e-cc4b-4b3b-bdd7-7a3fc63a0210

📥 Commits

Reviewing files that changed from the base of the PR and between 637edb1 and 60023fe.

📒 Files selected for processing (2)
  • crates/agent/src/lldp.rs
  • crates/agent/src/main_loop.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/agent/src/main_loop.rs

Summary by CodeRabbit

  • New Features
    • Improved LLDP initialization on DPU-OS startup (preparation step followed by system description update).
    • Automatically updates LLDP daemon arguments, disables conflicting interface configuration, and ensures LLDP-MED inventory is enabled.
  • Bug Fixes
    • Added bounded retries and timed verification to reduce LLDP restart/configuration failures.
    • LLDP preparation errors are now logged without blocking startup; system description update failures are logged as warnings.
  • Tests
    • Expanded coverage for daemon argument rewriting and LLDP-MED inventory parsing/enablement behavior.

Walkthrough

LLDP preparation now updates lldpd configuration, verifies LLDP-MED inventory settings with retryable service restarts, and runs during DPU-OS startup before setting the LLDP system description.

Changes

LLDP preparation

Layer / File(s) Summary
LLDP configuration preparation
crates/agent/src/lldp.rs
Adds prepare_lldp(), disables the active interface configuration, and ensures the desired DAEMON_ARGS value is written with newline normalization.
LLDP-MED verification and restart retries
crates/agent/src/lldp.rs
Queries LLDP-MED configuration through lldpcli with bounded execution, restarts lldpd when necessary, and applies bounded retry delays and failure handling.
Asynchronous system description and startup wiring
crates/agent/src/lldp.rs, crates/agent/src/main_loop.rs
Makes system-description updates asynchronous, reloads changed configuration through lldpcli, and runs preparation separately during DPU-OS startup with independent error logging. Unit tests cover argument rewriting and inventory parsing.

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

Sequence Diagram(s)

sequenceDiagram
  participant setup_and_run
  participant prepare_lldp
  participant lldpcli
  participant systemctl
  setup_and_run->>prepare_lldp: prepare_lldp()
  prepare_lldp->>lldpcli: Query LLDP-MED configuration
  lldpcli-->>prepare_lldp: Configuration JSON
  prepare_lldp->>systemctl: Restart lldpd.service when required
  systemctl-->>prepare_lldp: Restart result
  prepare_lldp-->>setup_and_run: Preparation result
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: enabling LLDP-MED for DPUs.
Description check ✅ Passed The description is clearly related to the LLDP-MED and interface-restriction changes in this pull request.
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 PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/agent/src/lldp.rs`:
- Around line 81-103: Extract the configuration line-rewrite logic into a pure
helper and the inventory JSON value parsing into another pure helper, replacing
direct filesystem and command coupling in the tested paths. Add table-driven
tests using value_scenarios! and scenarios! covering absent and existing
DAEMON_ARGS, LF, CRLF, and missing-final-newline inputs, plus yes, no, missing,
and unexpected JSON values; preserve the current transformation behavior.
- Around line 119-122: Bound all LLDP-related child processes with deadlines:
update the lldpcli call in the LLDP configuration read path, the systemctl
restart path, and LldpdConfigFileWriter::daemon_read() to use timeout-capable
process handling. Ensure expired commands are terminated and reported as
retryable failures so agent startup and config-change handling cannot block
indefinitely.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f2e83359-f23d-45d5-af93-f2b125c2bd71

📥 Commits

Reviewing files that changed from the base of the PR and between 0dae3ca and 637edb1.

📒 Files selected for processing (2)
  • crates/agent/src/lldp.rs
  • crates/agent/src/main_loop.rs

Comment thread crates/agent/src/lldp.rs
Comment thread crates/agent/src/lldp.rs Outdated
Signed-off-by: Stoo Davies <189670495+stoo-davies@users.noreply.github.com>
@wminckler

Copy link
Copy Markdown
Contributor

Is there a plan to support this when DPF is used? (or does it do that already?)

Comment thread crates/agent/src/lldp.rs

fn ensure_lldpd_daemon_args() -> eyre::Result<bool> {
let current_contents =
fs::read_to_string(LLDPD_DEFAULT_CONFIG).wrap_err("couldn't read lldpd default config")?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: this should use a bounded buffer size

@stoo-davies
stoo-davies marked this pull request as draft July 17, 2026 22:19
@copy-pr-bot

copy-pr-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@stoo-davies

Copy link
Copy Markdown
Contributor Author

Converting this back to draft until I can address the DPF question from @wminckler

The new code won't break anything since it's guarded by the is_dpu_os() check, however I need to get the same config applied under DPF provisioning.

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