Skip to content

Conversation

@Anekoique
Copy link

This PR introduces support for Netlink Route, referencing the implementations of Asterinas and DragonOS.

Some Linux apps rely on simple Netlink mechanisms to retrieve link or address information. This support is crucial for adapting FastDDS and ROS 2 to Starry.

Now, Starry can run ip link show and ip addr show normally:

starry:~# ip link show
1: lo: <LOOPBACK,UP> mtu 1500 qlen 65536
    link/loopback
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 65536
    link/ether
starry:~# ip addr show
1: lo: <LOOPBACK,UP> mtu 1500 qlen 65536
    link/loopback
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 65536
    link/ether
    inet 10.0.2.15/24 scope host eth0

Dependencies:

This PR is based on the API from the axio PR: https://github.com/Starry-OS/axio/pull/1. Considering that axio is currently being refactored, I am opening this as a Draft. I will mark it as ready for review once the refactoring is completed.

Additional Fix (FS):

The original function is_valid checked file open flags based on std::fs::OpenOptions, which does not conform to POSIX semantics (e.g., it was unable to create read-only files), leading to failures in some programs.
I have renamed is_valid to check_options to perform simple flag checks. More comprehensive checks may need to be added later, referencing https://man7.org/linux/man-pages/man2/open.2.html.

Copilot AI review requested due to automatic review settings December 4, 2025 17:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Netlink Route support to enable Linux applications to retrieve network interface and address information through the Netlink protocol. The implementation references Asterinas and DragonOS designs and is essential for adapting FastDDS and ROS 2 to Starry.

Key changes:

  • Implements Netlink Route protocol with support for ip link show and ip addr show commands
  • Adds comprehensive message parsing and attribute handling infrastructure
  • Fixes filesystem open flag validation to conform to POSIX semantics

Reviewed changes

Copilot reviewed 31 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
modules/axnet/src/socket.rs Adds Netlink socket variant and address type to socket infrastructure
modules/axnet/src/service.rs Exposes device iterator for Netlink route queries
modules/axnet/src/netlink/table.rs Implements bind table for managing Netlink socket bindings and multicast groups
modules/axnet/src/netlink/route/mod.rs Implements route transport layer with send/recv operations
modules/axnet/src/netlink/route/message/segment/*.rs Defines route message segment structures for links and addresses
modules/axnet/src/netlink/route/message/attr/*.rs Implements attribute parsing for link and address information
modules/axnet/src/netlink/route/handle.rs Handles GetLink and GetAddr requests with device filtering
modules/axnet/src/netlink/receiver.rs Implements message queue and receiver for async message handling
modules/axnet/src/netlink/mod.rs Main Netlink socket implementation with bind/connect/send/recv operations
modules/axnet/src/netlink/message/*.rs Core message parsing infrastructure with segments and attributes
modules/axnet/src/netlink/addr.rs Netlink socket addressing with port and multicast group support
modules/axnet/src/lib.rs Adds device index counter and Netlink module integration
modules/axnet/src/device/*.rs Extends device trait with type, flags, index, and IP information
modules/axnet/Cargo.toml Adds dependencies for Netlink feature
modules/axfs/src/highlevel/file.rs Refactors file open options validation to fix POSIX compliance
api/axfeat/Cargo.toml Adds netlink feature flag

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

align_up(payload_len, NLMSG_ALIGN) - payload_len
}

fn lecacy_padding_len() -> usize {
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'lecacy' to 'legacy'.

Suggested change
fn lecacy_padding_len() -> usize {
fn legacy_padding_len() -> usize {

Copilot uses AI. Check for mistakes.
Comment on lines +87 to +93
const DEPRECATED = 0x20;
const TENTATIVE = 0x40;
const PERMANENT = 0x80;
const MANAGETEMPADDR = 0x100;
const NOPREFIXROUTE = 0x200;
const MCAUTOJOIN = 0x400;
const STABLE_PRIVACY = 0x800;
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Inconsistent whitespace in flag definitions; use consistent spacing between flag name and value.

Suggested change
const DEPRECATED = 0x20;
const TENTATIVE = 0x40;
const PERMANENT = 0x80;
const MANAGETEMPADDR = 0x100;
const NOPREFIXROUTE = 0x200;
const MCAUTOJOIN = 0x400;
const STABLE_PRIVACY = 0x800;
const DEPRECATED = 0x20;
const TENTATIVE = 0x40;
const PERMANENT = 0x80;
const MANAGETEMPADDR = 0x100;
const NOPREFIXROUTE = 0x200;
const MCAUTOJOIN = 0x400;
const STABLE_PRIVACY = 0x800;

Copilot uses AI. Check for mistakes.
},
};

/// An helper function to access the route protocol bind table.
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Corrected grammar: 'An helper' should be 'A helper'.

Suggested change
/// An helper function to access the route protocol bind table.
/// A helper function to access the route protocol bind table.

Copilot uses AI. Check for mistakes.
self.index
}

fn ipv4_addr(&self) -> Option<Ipv4Addr> {
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Return type uses Ipv4Addr from std::net, but Device trait definition shows Option<Ipv4Address> from smoltcp. The trait definition should use the stdlib type for consistency, or this implementation should match the trait's smoltcp type.

Copilot uses AI. Check for mistakes.
self.index
}

fn ipv4_addr(&self) -> Option<Ipv4Address> {
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Return type uses Ipv4Address from smoltcp, which is inconsistent with loopback device's use of Ipv4Addr from std::net. Both implementations should use the same type for consistency.

Copilot uses AI. Check for mistakes.
/// Reference: <https://elixir.bootlin.com/linux/v6.13/source/include/uapi/linux/netlink.h#L86>.
pub struct AckFlags: u16 {
const CAPPED = 0x100;
const ACK_TLVS = 0x100;
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Two different flags have the same value 0x100. This appears to be a copy-paste error - these flags should have distinct values.

Suggested change
const ACK_TLVS = 0x100;
const ACK_TLVS = 0x200;

Copilot uses AI. Check for mistakes.
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.

5 participants