Skip to content

if: if_init inits the interface from the kernel#628

Merged
rsmarples merged 1 commit into
masterfrom
if_init
Jun 7, 2026
Merged

if: if_init inits the interface from the kernel#628
rsmarples merged 1 commit into
masterfrom
if_init

Conversation

@rsmarples

Copy link
Copy Markdown
Member

if_init_os inits the OS from the interface

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@rsmarples, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 13 minutes and 27 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 690855aa-2b17-4e12-b66d-b49854f27d85

📥 Commits

Reviewing files that changed from the base of the PR and between 123b9f3 and 2690f80.

📒 Files selected for processing (5)
  • src/if-bsd.c
  • src/if-linux.c
  • src/if-sun.c
  • src/if.c
  • src/if.h

Walkthrough

The PR separates OS-specific interface setup into a new if_init_os() entrypoint, implements Linux if_init() to probe hwtype/index via ioctl, makes BSD/Solaris if_init() no-ops with OS logic moved to if_init_os(), and reorders if_discover to call if_init() earlier while broadening an ARP/AF guard.

Changes

Interface Initialization Refactoring

Layer / File(s) Summary
Interface initialization contract and declarations
src/if.h
Header adds int if_init_os(struct interface *);, reorders if_init() / if_conf() declarations, and documents initialization directions.
Linux interface initialization via ioctl
src/if-linux.c
if_init() now uses SIOCGIFHWADDR and SIOCGIFINDEX ioctls to set ifp->hwtype and ifp->index, logs ioctl failures, tracks errors, and returns early when index is already set; if_init_os() declaration remains after the implementation.
BSD and Solaris interface initialization stubs
src/if-bsd.c, src/if-sun.c
if_init() is a no-op returning 0 on BSD and Solaris. Solaris' previous plumbing moved into new if_init_os(). BSD's if_init_os() declaration now marks its parameter __unused.
Core discovery flow refactoring and guard broadening
src/if.c
if_check_arphrd is compiled when AF_LINK is not defined. if_discover calls if_init(ifp) earlier, then updates active via if_check_arphrd(). The prior Linux ioctl fallback code in this region was removed.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 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: refactoring interface initialization to have if_init initialize the interface from kernel data and if_init_os initialize OS-specific state.
Description check ✅ Passed The description complements the title by clarifying the complementary role of if_init_os, which initializes the OS from the interface configuration.
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 if_init

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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 `@src/if.c`:
- Around line 672-673: Remove the stray blank line immediately following the
preprocessor directive (`#endif`) in src/if.c (the blank line after the shown
`#endif`) to satisfy clang-format; ensure there is no empty line after that `#endif`
so the file ends/continues without the extra newline that caused the formatting
violation.

In `@src/if.h`:
- Line 209: Run clang-format on src/if.h (or reformat the line declaring int
if_init(struct interface *);) to fix the spacing/alignment around the trailing
comment. Ensure the declaration and its comment follow project style — either
place the comment on the previous line or adjust spacing so the inline comment
is properly aligned — then save the file and re-run the pipeline.
- Line 211: Fix the typo in the comment for the function declaration if_conf:
change "finish configuration from kermel" to "finish configuration from kernel"
in the comment immediately following the prototype for if_conf(struct interface
*) to correct the spelling.
🪄 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: a0cb98e4-d194-4125-b12e-1aaae8c87e90

📥 Commits

Reviewing files that changed from the base of the PR and between 9066456 and ee827e8.

📒 Files selected for processing (5)
  • src/if-bsd.c
  • src/if-linux.c
  • src/if-sun.c
  • src/if.c
  • src/if.h

Comment thread src/if.c Outdated
Comment thread src/if.h Outdated
Comment thread src/if.h Outdated
if_init_os inits the OS from the interface
@rsmarples rsmarples merged commit 5417ec9 into master Jun 7, 2026
6 checks passed
@rsmarples rsmarples deleted the if_init branch June 7, 2026 11:21
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