Skip to content

fix: treat IPv4LL DHCP assignments as incomplete during boot#2649

Open
ljm42 wants to merge 2 commits into
masterfrom
fix-dhcp-ipv4ll-boot-wait
Open

fix: treat IPv4LL DHCP assignments as incomplete during boot#2649
ljm42 wants to merge 2 commits into
masterfrom
fix-dhcp-ipv4ll-boot-wait

Conversation

@ljm42
Copy link
Copy Markdown
Member

@ljm42 ljm42 commented May 22, 2026

Summary

  • Treat IPv4LL/link-local DHCP assignments as incomplete during boot.
  • When IPv4 DHCP is enabled and the interface has carrier, rc.inet1 now waits up to 60 seconds for a non-link-local IPv4 address instead of continuing as soon as dhcpcd assigns a 169.254.x.x address.
  • Clarify DHCP fallback logs to distinguish an existing dhcpcd process from starting a new background process.

Validation

  • Ran: bash -n etc/rc.d/rc.inet1
  • Tested on test4 with the updated rc.inet1 override. During boot, dhcpcd assigned 169.254.150.83 at 14:25:51, then rc.inet1 continued waiting until dhcpcd leased 10.11.1.191 at 14:25:59.
  • Confirmed current test4 state: br0 has 10.11.1.191/24, default route via 10.11.1.1, and nameserver 10.11.1.1.

Summary by CodeRabbit

  • Bug Fixes

    • Improved DHCP handling to avoid unnecessary restarts when DHCP is already running and to better detect link-local-only IPv4 addresses.
    • Clarified log messages during interface bring-up/shutdown for more accurate diagnostics.
  • New Features

    • Added IPv4-specific DHCP wait and address detection to reduce false negatives during interface initialization.

Review Change Stack

When IPv4 DHCP is enabled and the interface has carrier, rc.inet1 now waits up to 60 seconds for a non-link-local IPv4 address instead of continuing as soon as dhcpcd assigns a 169.254.x.x address.

If no usable IPv4 address is received within the timeout, dhcpcd continues polling in the background.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0a84323e-ee71-4240-8f57-ca3dec36ee17

📥 Commits

Reviewing files that changed from the base of the PR and between 5cf8a69 and 5880ba1.

📒 Files selected for processing (1)
  • etc/rc.d/rc.inet1

Walkthrough

Adds dhcp4_addr() and dhcp_wait() to detect non-link-local IPv4 addresses and wrap dhcpcd -w with a 60s timeout and IPv4 polling; ipaddr_up() now calls dhcp_wait() and branches on its return to log IPv4LL-only, do nothing, or start dhcpcd in background.

Changes

DHCP Polling Enhancement

Layer / File(s) Summary
DHCP polling helper functions
etc/rc.d/rc.inet1
Adds dhcp4_addr() to detect non-169.254.x.x IPv4 addresses and dhcp_wait() to run dhcpcd -w with a 60s timeout and (for IPv4) poll to distinguish IPv4LL-only vs non-link-local assignment; returns status codes for callers.
DHCP startup flow integration
etc/rc.d/rc.inet1
Refactors ipaddr_up() carrier-present path to call dhcp_wait() and branch on its return: 0 requires no action, 2 logs IPv4LL-only and leaves dhcpcd running, other failures start dhcpcd -b in background; updates carrier-down log wording.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibble on code beneath the moon,
Two tiny helpers hum a tune,
One sniffs link-local in the air,
One waits a beat to be more fair,
Then ipaddr_up acts — light as a rune. 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: treating IPv4 Link-Local (169.254.x.x) DHCP assignments as incomplete during boot and waiting for a proper address.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-dhcp-ipv4ll-boot-wait

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 and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 22, 2026

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2026.05.25.1631
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2649/webgui-pr-2649.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates
  • Post-merge behavior: This preview stays available after merge until preview storage expires or it is manually cleaned up

📝 Modified Files:

Click to expand file list
etc/rc.d/rc.inet1

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2649, or run:

plugin remove webgui-pr-2649

🤖 This comment is automatically generated and will be updated with each new push to this PR.

@ljm42 ljm42 marked this pull request as ready for review May 22, 2026 21:44
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.

1 participant