Skip to content

Add ipv4 and ipv6 sections to SavedConnection - #534

Open
joshwd36 wants to merge 1 commit into
freedesktop-rs:masterfrom
PeakDesign:feat-524/saved-connection-ip-settings
Open

Add ipv4 and ipv6 sections to SavedConnection#534
joshwd36 wants to merge 1 commit into
freedesktop-rs:masterfrom
PeakDesign:feat-524/saved-connection-ip-settings

Conversation

@joshwd36

@joshwd36 joshwd36 commented Sep 1, 2026

Copy link
Copy Markdown

Fixes #524, though doesn't implement the other features discussed in the issue. Adds ipv4 and ipv6 sections to the SavedConnection struct. For address_data I use a new typed IpAddress<A> type, but I reuse the Route struct from the builder module for route_data, though it may be better to create a similar typed struct, as Route uses strings for dest and next_hop

@joshwd36
joshwd36 had a problem deploying to self-hosted-pr-integration September 1, 2026 16:54 — with GitHub Actions Error

@cachebag cachebag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM modulo comments below. Thank you

&& let Ok(Some(prefix)) = dict.get(&"prefix")
{
let mut route = Route::new(dest, prefix);
if let Ok(Some(next_hop)) = dict.get::<_, String>(&"next_hop") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if let Ok(Some(next_hop)) = dict.get::<_, String>(&"next_hop") {
if let Ok(Some(next_hop)) = dict.get::<_, String>(&"next-hop") {

https://networkmanager.dev/docs/api/latest/settings-ipv4.html#:~:text=%27next%2Dhop

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A regression test for this would be good as well

Comment on lines +243 to +245
/// Ignore the automatically configured DNS servers, and only use the saved configuration.
pub ignore_auto_dns: bool,
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

dns is missing from here? without it the struct is incoherent

also prefer dns-data
https://networkmanager.dev/docs/api/latest/settings-ipv4.html#:~:text=dns%2Ddata

&& let Ok(Some(address)) = dict.get::<_, &str>(&"address")
&& let Ok(Some(prefix)) = dict.get::<_, u32>(&"prefix")
{
if let Ok(address) = address.parse() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Malformed addresses and gateways are lost here. I believe we settled on dropping them with a warn! in #524

/// The list of DNS search domains.
pub dns_search: Vec<String>,
/// The list of IP routes.
pub route_data: Vec<Route>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's make this typed. We ruled out sharing structs between builders and reads in #524: builders hold only what the caller set, reads arrive fully populated with NM's defaults.

IpSettings<A> is generic and Route isn't, so an IpSettings<Ipv6Addr> can hold IPv4 route strings. And next_hop() / metric() are #[must_use] builder setters that mean nothing on decoded output.dest + prefix is already your IpAddress<A>:

IpRoute<A> { dest: IpAddress<A>, next_hop: Option<A>, metric: Option<u32> }

}
}
};
let gateway = take_str_ref(settings, "gateway").and_then(|gateway| gateway.parse().ok());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

InterfaceNotFound(String),

#[error("invalid IP address: {0}")]
AddressParse(IpAddressParseError),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Hmmm I don't think I understand what the point of this is, are you planning to use it in a follow up PR for this issue?ConnectionError is #[non_exhaustive], so we can add it back if a fallible path ever appears.

/// The method by which the connection obtains its IP address for this protocol.
pub method: IpMethod,
/// The list of IP addresses.
pub address_data: Vec<IpAddress<A>>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
pub address_data: Vec<IpAddress<A>>,
pub addresses: Vec<IpAddress<A>>,

? The current name leaks NM's wire keys into our public API. wdyt?

/// The list of DNS search domains.
pub dns_search: Vec<String>,
/// The list of IP routes.
pub route_data: Vec<Route>,

@cachebag cachebag Sep 2, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
pub route_data: Vec<Route>,
pub routes: Vec<IpRoute<A>>,

Same thing here


/// How the connection obtains its IP address.
#[derive(Debug, Clone)]
pub enum IpMethod {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
pub enum IpMethod {
#[non_exhaustive]
pub enum IpMethod {

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.

[FEATURE] Allow getting static IP address(es) for saved connections

2 participants