Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions rust/agama-network/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,36 @@ impl From<InvalidMacAddress> for zbus::fdo::Error {
}
}

#[derive(Debug, Default, Copy, Clone, PartialEq, Deserialize, Serialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub enum LinkLocal {
#[default]
Default = 0,
Auto = 1,
Disabled = 2,
Enabled = 3,
Fallback = 4,
}

#[derive(Debug, Error)]
#[error("Invalid link-local value: {0}")]
pub struct InvalidLinkLocalValue(i32);

impl TryFrom<i32> for LinkLocal {
type Error = InvalidLinkLocalValue;

fn try_from(value: i32) -> Result<Self, Self::Error> {
match value {
0 => Ok(LinkLocal::Default),
1 => Ok(LinkLocal::Auto),
2 => Ok(LinkLocal::Disabled),
3 => Ok(LinkLocal::Enabled),
4 => Ok(LinkLocal::Fallback),
_ => Err(InvalidLinkLocalValue(value)),
}
}
}

#[skip_serializing_none]
#[derive(Default, Debug, PartialEq, Clone, Deserialize, Serialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -899,6 +929,7 @@ pub struct IpConfig {
pub ip6_privacy: Option<i32>,
pub dns_priority4: Option<i32>,
pub dns_priority6: Option<i32>,
pub link_local4: LinkLocal,
}

#[skip_serializing_none]
Expand Down
13 changes: 13 additions & 0 deletions rust/agama-network/src/nm/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,21 @@ fn ip_config_to_ipv4_dbus<'a>(
.collect::<Vec<_>>()
.into();

let link_local = if ip_config.link_local4 == LinkLocal::Fallback
&& VersionReq::parse("<1.52.0").unwrap().matches(nm_version)
{
LinkLocal::Enabled
} else {
ip_config.link_local4
};

let mut ipv4_dbus = HashMap::from([
("address-data", address_data),
("dns-data", dns_data),
("dns-search", ip_config.dns_searchlist.clone().into()),
("ignore-auto-dns", ip_config.ignore_auto_dns.into()),
("method", ip_config.method4.to_string().into()),
("link-local", (link_local as i32).into()),
]);

if !ip_config.routes4.is_empty() {
Expand Down Expand Up @@ -1081,6 +1090,10 @@ fn ip_config_from_dbus(conn: &OwnedNestedHash) -> Result<IpConfig, NmError> {
ip_config.dns_priority4 = Some(dns_priority4);
}

if let Some(link_local4) = get_optional_property::<i32>(ipv4, "link-local")? {
ip_config.link_local4 = link_local4.try_into().unwrap_or_default();
}

let mut dhcp4_settings = Dhcp4Settings::default();
if let Some(dhcp_send_hostname) = get_optional_property(ipv4, "dhcp-send-hostname-v2")? {
dhcp4_settings.send_hostname = match dhcp_send_hostname {
Expand Down
1 change: 1 addition & 0 deletions rust/agama-server/src/web/docs/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl ApiDocBuilder for NetworkApiDocBuilder {
.schema_from::<agama_lib::network::model::DhcpIaid>()
.schema_from::<agama_lib::network::model::Dhcp6Settings>()
.schema_from::<agama_lib::network::model::DhcpDuid>()
.schema_from::<agama_lib::network::model::LinkLocal>()
.schema_from::<crate::network::web::PersistParams>()
.schema("IpAddr", schemas::ip_addr())
.schema("IpInet", schemas::ip_inet())
Expand Down
6 changes: 6 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Oct 7 09:55:46 UTC 2025 - Clemens Famulla-Conrad <cfamullaconrad@suse.com>

- Add IpConfig.link_local4 to specify ZeroConf/AutoIP behavior.
(gh#agama-project/agama#2792).

-------------------------------------------------------------------
Wed Oct 1 13:45:23 UTC 2025 - Ladislav Slezák <lslezak@suse.com>

Expand Down