Skip to content

DHCP6: decline any duplicated address, not just the last one to finish DAD - #739

Open
ulflulfl wants to merge 1 commit into
NetworkConfiguration:masterfrom
ulflulfl:master
Open

ulflulfl wants to merge 1 commit into
NetworkConfiguration:masterfrom
ulflulfl:master

Conversation

@ulflulfl

@ulflulfl ulflulfl commented Oct 2, 2026

Copy link
Copy Markdown

Problem

When several DHCPv6 addresses are assigned and DAD fails for one of them,
no DECLINE is sent. The client runs BOUND6 and keeps using the
duplicated address.

Cause

In dhcp6_dadcallback() the loop over all addresses checks the callback
argument ia instead of the loop variable ia2. So only the address
that finished DAD last is checked. With a single address both are the
same, which hides the bug.

-		if (DECLINE_IA(ia))
+		if (DECLINE_IA(ia2))
             oneduplicated = true;

Testing

We found this in an automated test that requests 8 DHCPv6 addresses and
injects a conflicting Neighbor Advertisement for the first one while it
is still tentative. Without the fix, no DECLINE is sent. With the fix,
the client sends a DECLINE for the duplicated address.

The loop in dhcp6_dadcallback() checks DECLINE_IA(ia) instead of DECLINE_IA(ia2). Only the address whose DAD finished last is checked, so with multiple addresses a duplicate found earlier is never declined.
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 4e1ceb9c-f4d5-42da-972c-e6bde4c1be78

📥 Commits

Reviewing files that changed from the base of the PR and between 5a91691 and 8b5d924.

📒 Files selected for processing (1)
  • src/dhcp6.c

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


Walkthrough

The DHCPv6 duplicate-address check now evaluates each address in the interface’s address list when it sets oneduplicated.

Changes

DHCPv6 duplicate-address detection

Layer / File(s) Summary
Check listed addresses
src/dhcp6.c
The check now evaluates the current address in the list for DECLINE_IA, rather than checking the callback address repeatedly.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Suggested reviewers: rsmarples

Merge Risk: ⚪ Minimal · up to 8b5d9

The DHCPv6 callback now checks each listed address before deciding whether to send DECLINE, addressing the missed-duplicate case. The surrounding completion and no-match handling remain intact, with no actionable merge risk identified.

Architecture Summary

Architecture risk: 🔵 Low · up to 8b5d9

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/dhcp6.c: The duplicate-address check now evaluates ia2, the current address in the loop, rather than ia, the callback address; oneduplicated is set for any listed address satisfying DECLINE_IA.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main DHCPv6 bug fix: declining duplicated addresses regardless of which address finishes DAD last.
Description check ✅ Passed The description directly explains the DHCPv6 DAD bug, identifies the incorrect loop variable, and documents the testing performed for the fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@ColinMcInnes ColinMcInnes 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.

Reasonable small change, minimal fix to address the issue. I see no problem with this.

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