Skip to content

dhcpsd: Only start privileged helper when waiting for interfaces#7

Merged
rsmarples merged 3 commits intomasterfrom
nopriv
Apr 21, 2026
Merged

dhcpsd: Only start privileged helper when waiting for interfaces#7
rsmarples merged 3 commits intomasterfrom
nopriv

Conversation

@rsmarples
Copy link
Copy Markdown
Member

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d0f4f9db-aa9c-4209-9f06-80cc4419f722

📥 Commits

Reviewing files that changed from the base of the PR and between a60fda6 and b47b7ed.

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

Walkthrough

Conditional control flow added: send and BPF initialization now branch on the DHCPSD_WAITIF flag. When set, privileged helper paths (priv_openbpf / priv_sendbpf) are used; when clear, direct interface callbacks and direct BPF opens are used. Documentation date and option text updated.

Changes

Cohort / File(s) Summary
DHCP send & BPF init
src/dhcp.c, src/dhcpsd.c
dhcp_outputipudp() now chooses between priv_sendbpf() (when DHCPSD_WAITIF set) and ifp->if_output()/direct BPF (bpf_open) otherwise. dhcpsd_configure_pools() opens BPF via priv_openbpf() or bpf_open() based on flag. main() only calls priv_init() when DHCPSD_WAITIF is set and adjusts startup flow.
Docs & minor cleanup
src/dhcpsd.8.in, src/if.c
Manual date updated and -w option text clarifies privileged helper requirement. Minor formatting/bracing changes in if_learnifaces() / if_free() with no behavioral change.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant DHCP as DHCPd
  participant CFG as Config (ctx)
  participant Priv as Privileged helper
  participant IF as Network Interface
  participant BPF as BPF socket
  DHCP->>CFG: read DHCPSD_WAITIF flag
  alt DHCPSD_WAITIF set
    DHCP->>Priv: priv_sendbpf(packet)
    Priv->>BPF: write to BPF
    BPF->>IF: deliver to kernel/interface
  else DHCPSD_WAITIF clear
    DHCP->>IF: if_output(packet)
    IF->>BPF: (kernel handling / direct BPF if configured)
    BPF-->>IF: (optional BPF presence)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Description check ❓ Inconclusive No pull request description was provided by the author. Add a description explaining the rationale for making privileged helper initialization conditional and the benefits of this change.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: making the privileged helper initialization conditional on the DHCPSD_WAITIF flag.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nopriv

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/dhcp.c`:
- Around line 376-378: The code dereferences ifp->if_bpf->bpf_fd unconditionally
when calling ifp->if_output in the non-DHCPSD_WAITIF path; add a guard to test
ifp->if_bpf before using its bpf_fd and handle the absence (e.g. pass an invalid
fd like -1 or take the same error-path used elsewhere) so that a missing BPF
handle won’t cause a crash; update the call site in the same block where nbytes
= ifp->if_output(ifp, ifp->if_bpf->bpf_fd, iov, ARRAYCOUNT(iov)) to use
ifp->if_bpf only when non-NULL and otherwise invoke the safe fallback used
elsewhere in the codebase (referencing ifp, ifp->if_bpf, ifp->if_output,
if_bpf->bpf_fd, nbytes, iov, ARRAYCOUNT and the DHCPSD_WAITIF branch).
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e32a659f-376c-4c20-a13b-944ad8b60fb8

📥 Commits

Reviewing files that changed from the base of the PR and between 2f51e43 and a60fda6.

📒 Files selected for processing (4)
  • src/dhcp.c
  • src/dhcpsd.8.in
  • src/dhcpsd.c
  • src/if.c

Comment thread src/dhcp.c Outdated
@rsmarples rsmarples merged commit db1eb6f into master Apr 21, 2026
7 checks passed
@rsmarples rsmarples deleted the nopriv branch April 21, 2026 16:15
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