DHCPv6: When deprecating addresses, restart on prefix deletions - #672
Conversation
As that might invalidate the next address to iterate on. Reported-by: CuB3y0nd <root@cubeyond.net>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughIn ChangesDelegated-prefix deprecation loop fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/dhcp6.c (1)
2636-2641: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
againis read uninitialized and is sticky across iterations.
again(line 2615) is assigned only whenia->flags & IPV6_AF_PFXDELEGATIONis set, but it is unconditionally read at line 2655 (if (again) goto again;).
- For the first
iathat lacksIPV6_AF_PFXDELEGATION,againis read uninitialized → undefined behavior.- Once it becomes
true, it is never cleared, so subsequent iterations (including those withoutIPV6_AF_PFXDELEGATION) will spuriouslygoto again, restarting the loop and re-walking the list unnecessarily.Reset
againat the start of each iteration before the conditional assignment.🐛 Proposed fix: reset per-iteration
`#ifndef` SMALL /* If we delegated from this prefix, deprecate or remove * the delegations. */ + again = false; if (ia->flags & IPV6_AF_PFXDELEGATION) again = dhcp6_deprecatedele(ia); `#endif`🤖 Prompt for 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. In `@src/dhcp6.c` around lines 2636 - 2641, The `again` variable is only conditionally assigned when the `IPV6_AF_PFXDELEGATION` flag is checked and `dhcp6_deprecatedele(ia)` is called, but it is unconditionally read at the end of the loop iteration in the `goto again` check, causing uninitialized variable access and sticky state across iterations. Reset the `again` variable to false at the beginning of each loop iteration that processes the `ia` items, before the conditional check for `IPV6_AF_PFXDELEGATION`. This ensures the variable is always initialized and does not carry over its value from previous iterations.
🤖 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.
Outside diff comments:
In `@src/dhcp6.c`:
- Around line 2636-2641: The `again` variable is only conditionally assigned
when the `IPV6_AF_PFXDELEGATION` flag is checked and `dhcp6_deprecatedele(ia)`
is called, but it is unconditionally read at the end of the loop iteration in
the `goto again` check, causing uninitialized variable access and sticky state
across iterations. Reset the `again` variable to false at the beginning of each
loop iteration that processes the `ia` items, before the conditional check for
`IPV6_AF_PFXDELEGATION`. This ensures the variable is always initialized and
does not carry over its value from previous iterations.
As that might invalidate the next address to iterate on.
Reported-by: CuB3y0nd root@cubeyond.net