Skip to content

refactor(net): centralize interface address mutations - #2243

Merged
fslongjin merged 3 commits into
DragonOS-Community:masterfrom
fslongjin:codex/issue-2233-centralize-address-mutations
Sep 1, 2026
Merged

refactor(net): centralize interface address mutations#2243
fslongjin merged 3 commits into
DragonOS-Community:masterfrom
fslongjin:codex/issue-2233-centralize-address-mutations

Conversation

@fslongjin

Copy link
Copy Markdown
Member

Part of #2233.

Summary

  • add a typed, RTNL-protected interface address mutation core
  • commit smoltcp addresses, connected routes, and the router compatibility projection under one lock with rollback on capacity failure
  • migrate rtnetlink, the one-shot DHCP client, and construction-time veth/bridge initialization away from runtime direct writers
  • preserve Linux 6.6 IPv4/IPv6 address identity, replace/delete, errno, and notification semantics
  • add focused coverage for multi-address consistency, duplicate/replace/delete behavior, invalid input safety, explicit-route ownership, and capacity rollback

Architecture

Runtime mutations require an RtnlGuard and return typed outcomes. The core owns the single lock order RTNL -> smoltcp interface -> router projection; notifications are emitted only after a successful commit. Construction-only initialization is restricted to interfaces that have not yet been published in a network namespace.

This deliberately does not introduce a second address database, a generic transaction framework, route-owner metadata, or a full DHCP lease manager.

Validation

  • make fmt
  • make kernel
  • Linux reference run: 3 compatible tests passed; the DragonOS fixed-capacity case skipped as designed
  • DragonOS QEMU: rtnetlink_addr_semantics_test 4/4 passed
  • DragonOS QEMU: rtnetlink_route_semantics_test 5/5 passed
  • DragonOS QEMU: rtnetlink_serialization_semantics_test 2/2 passed
  • DragonOS QEMU: rtnetlink_permission_semantics_test 8/8 passed
  • normal boot completed and DHCP acquired 10.0.2.15/24

Introduce a typed, RTNL-protected address mutation core that commits interface addresses, connected routes, and the router compatibility projection under one smoltcp lock. Capacity failures now roll back without exposing partial state, and runtime callers can no longer bypass the centralized path.

Route rtnetlink and the one-shot DHCP client through the core, preserve Linux 6.6 address identity and notification semantics, and keep construction-only initialization explicitly separated from published-interface mutations.

Add focused dunitest coverage for duplicate, replace, delete, parser, invalid-address, multi-address data-plane, route ownership, and capacity rollback behavior.

Signed-off-by: longjin <longjin@dragonos.org>
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T02:01:34.027933Z d72f249 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d21a52819

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kernel/src/net/address.rs Outdated
Comment thread kernel/src/net/socket/netlink/route/kern/addr.rs Outdated
Comment thread kernel/src/net/net_core.rs Outdated
Track in-kernel address leases with opaque generations so DHCP cannot delete a userspace-recreated address after a cross-event ABA.

Persist Linux IFA_LABEL metadata across dumps, notifications, deletes, replaces, and interface renames, including length and empty-label semantics.

Share canonical smoltcp route projections across address and rtnetlink owners, retain them until the final logical owner disappears, and isolate DHCP default-route updates from userspace defaults.

Extend dunitest coverage for both owner orders, full-table rollback and sharing, alias labels, canonical prefixes, same-subnet addresses, and failed route replacement atomicity.

Signed-off-by: longjin <longjin@dragonos.org>
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36ea7c59db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kernel/src/net/address.rs
Preserve raw IFA_LABEL payloads until the address-family adapter can apply the matching Linux policy. Validate IPv4 labels before address and interface processing, retain explicit empty labels for deletion matching, and omit empty labels from rtnetlink output. Ignore IFA_LABEL for IPv6 requests and notifications as Linux does.

Extend rtnetlink address semantics coverage for empty and malformed IPv4 labels, error priority, IPv6 ignored labels, and attribute presence in dumps and notifications.

Signed-off-by: longjin <longjin@dragonos.org>
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: d72f24900f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fslongjin
fslongjin merged commit c00c0cc into DragonOS-Community:master Sep 1, 2026
15 of 16 checks passed
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