From 7b94c0be3cd49cebff5d0ea3948c30934d524c78 Mon Sep 17 00:00:00 2001 From: Tommy McCormick Date: Mon, 19 Jan 2026 14:15:01 -0500 Subject: [PATCH] chore(deps): Update rtnetlink and related crates --- Cargo.lock | 63 +++++++++------------- auraed/Cargo.toml | 4 +- auraed/src/init/network/mod.rs | 99 ++++++++++++++-------------------- 3 files changed, 67 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ece9d496..128e32a64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2508,46 +2508,30 @@ dependencies = [ [[package]] name = "netlink-packet-core" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72724faf704479d67b388da142b186f916188505e7e0b26719019c525882eda4" +checksum = "3463cbb78394cb0141e2c926b93fc2197e473394b761986eca3b9da2c63ae0f4" dependencies = [ - "anyhow", - "byteorder", - "netlink-packet-utils", + "paste", ] [[package]] name = "netlink-packet-route" -version = "0.17.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053998cea5a306971f88580d0829e90f270f940befd7cf928da179d4187a5a66" +checksum = "4ce3636fa715e988114552619582b530481fd5ef176a1e5c1bf024077c2c9445" dependencies = [ - "anyhow", - "bitflags 1.3.2", - "byteorder", + "bitflags 2.9.0", "libc", + "log", "netlink-packet-core", - "netlink-packet-utils", -] - -[[package]] -name = "netlink-packet-utils" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" -dependencies = [ - "anyhow", - "byteorder", - "paste", - "thiserror 1.0.69", ] [[package]] name = "netlink-proto" -version = "0.11.5" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72452e012c2f8d612410d89eea01e2d9b56205274abb35d53f60200b2ec41d60" +checksum = "b65d130ee111430e47eed7896ea43ca693c387f097dd97376bffafbf25812128" dependencies = [ "bytes", "futures", @@ -2578,33 +2562,34 @@ checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "nix" -version = "0.26.4" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.9.0", "cfg-if", + "cfg_aliases 0.1.1", "libc", + "memoffset", ] [[package]] name = "nix" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.9.0", "cfg-if", - "cfg_aliases 0.1.1", + "cfg_aliases 0.2.1", "libc", - "memoffset", ] [[package]] name = "nix" -version = "0.29.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" dependencies = [ "bitflags 2.9.0", "cfg-if", @@ -3328,18 +3313,18 @@ dependencies = [ [[package]] name = "rtnetlink" -version = "0.13.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a552eb82d19f38c3beed3f786bd23aa434ceb9ac43ab44419ca6d67a7e186c0" +checksum = "4b960d5d873a75b5be9761b1e73b146f52dddcd27bac75263f40fba686d4d7b5" dependencies = [ - "futures", + "futures-channel", + "futures-util", "log", "netlink-packet-core", "netlink-packet-route", - "netlink-packet-utils", "netlink-proto", "netlink-sys", - "nix 0.26.4", + "nix 0.30.1", "thiserror 1.0.69", "tokio", ] diff --git a/auraed/Cargo.toml b/auraed/Cargo.toml index dab59944e..2d63e851c 100644 --- a/auraed/Cargo.toml +++ b/auraed/Cargo.toml @@ -47,13 +47,13 @@ libcontainer = { git = "https://github.com/containers/youki", tag = "v0.5.2", de "v2", ] } log = "0.4.21" -netlink-packet-route = "0.17.1" # Used for netlink_packet_route::rtnl::address::nlas definition +netlink-packet-route = "0.28.0" nix = { workspace = true, features = ["sched", "mount", "signal", "net"] } oci-spec = "0.7.1" once_cell = "1" procfs = "0.17.0" proto = { workspace = true } -rtnetlink = "0.13.1" +rtnetlink = "0.20.0" serde_json.workspace = true serde.workspace = true syslog-tracing = "0.3.1" diff --git a/auraed/src/init/network/mod.rs b/auraed/src/init/network/mod.rs index 249c287bc..58a0fed7b 100644 --- a/auraed/src/init/network/mod.rs +++ b/auraed/src/init/network/mod.rs @@ -16,10 +16,11 @@ use futures::stream::TryStreamExt; use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network}; use libc::EEXIST; -use netlink_packet_route::rtnl::link::nlas::Nla; -use rtnetlink::Handle; +use netlink_packet_route::address::AddressAttribute; +use netlink_packet_route::link::LinkAttribute; +use rtnetlink::{Handle, LinkUnspec, RouteMessageBuilder}; use std::collections::HashMap; -use std::net::IpAddr; +use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use std::str; use std::thread; use std::time::Duration; @@ -159,8 +160,8 @@ async fn configure_nic( add_route_v6( handle, config.device.clone(), - "::/0".parse::().expect("valid ipv6 address"), - gateway, + &"::/0".parse::().expect("valid ipv6 address"), + &gateway, ) .await?; @@ -206,11 +207,11 @@ async fn set_link_up( iface: String, ) -> Result<(), NetworkError> { let link_index = get_link_index(handle, iface.clone()).await?; + let msg = LinkUnspec::new_with_index(link_index).up().build(); handle .link() - .set(link_index) - .up() + .set(msg) .execute() .await .map(|_| { @@ -229,11 +230,11 @@ async fn set_link_down( iface: String, ) -> Result<(), NetworkError> { let link_index = get_link_index(handle, iface.clone()).await?; + let msg = LinkUnspec::new_with_index(link_index).down().build(); handle .link() - .set(link_index) - .down() + .set(msg) .execute() .await .map(|_| { @@ -265,26 +266,24 @@ async fn get_link_index( async fn add_route_v4( handle: &Handle, iface: String, - source: Ipv4Network, - dest: Ipv4Network, + source: &Ipv4Network, + dest: &Ipv4Network, ) -> Result<(), NetworkError> { let link_index = get_link_index(handle, iface.clone()).await?; - handle - .route() - .add() - .v4() + let route = RouteMessageBuilder::::new() .destination_prefix(dest.ip(), dest.prefix()) .output_interface(link_index) .pref_source(source.ip()) - .execute() - .await - .map_err(|e| NetworkError::ErrorAddingRoute { + .build(); + handle.route().add(route).execute().await.map_err(|e| { + NetworkError::ErrorAddingRoute { iface, - route_source: source.into(), - route_destination: dest.into(), + route_source: IpNetwork::V4(*source), + route_destination: IpNetwork::V4(*dest), source: e, - })?; + } + })?; Ok(()) } @@ -292,26 +291,24 @@ async fn add_route_v4( async fn add_route_v6( handle: &Handle, iface: String, - source: Ipv6Network, - dest: Ipv6Network, + source: &Ipv6Network, + dest: &Ipv6Network, ) -> Result<(), NetworkError> { let link_index = get_link_index(handle, iface.clone()).await?; - handle - .route() - .add() - .v6() - .source_prefix(source.ip(), source.prefix()) - .gateway(dest.ip()) + let route = RouteMessageBuilder::::new() + .destination_prefix(dest.ip(), dest.prefix()) .output_interface(link_index) - .execute() - .await - .map_err(|e| NetworkError::ErrorAddingRoute { + .pref_source(source.ip()) + .build(); + handle.route().add(route).execute().await.map_err(|e| { + NetworkError::ErrorAddingRoute { iface, - route_source: source.into(), - route_destination: dest.into(), + route_source: IpNetwork::V6(*source), + route_destination: IpNetwork::V6(*dest), source: e, - })?; + } + })?; Ok(()) } @@ -323,8 +320,8 @@ async fn get_links( let mut links = handle.link().get().execute(); 'outer: while let Some(link_msg) = links.try_next().await? { - for nla in link_msg.nlas.into_iter() { - if let Nla::IfName(name) = nla { + for nla in link_msg.attributes.into_iter() { + if let LinkAttribute::IfName(name) = nla { let _ = result.insert(link_msg.header.index, name); continue 'outer; } @@ -342,8 +339,8 @@ async fn dump_addresses( let mut links = handle.link().get().match_name(iface.to_string()).execute(); if let Some(link_msg) = links.try_next().await? { info!("{}:", iface); - for nla in link_msg.nlas.into_iter() { - if let Nla::IfName(name) = nla { + for nla in link_msg.attributes.into_iter() { + if let LinkAttribute::IfName(name) = nla { info!("\tindex: {}", link_msg.header.index); info!("\tname: {name}"); } @@ -356,29 +353,15 @@ async fn dump_addresses( .execute(); while let Some(msg) = address_msg.try_next().await? { - for nla_address in msg.nlas.into_iter() { - if let netlink_packet_route::address::Nla::Address(addr) = - nla_address - { - let ip_addr = addr.try_into() - .map(|ip: [u8; 4]| Some(IpAddr::from(ip))) - .unwrap_or_else(|addr| { - addr.try_into() - .map(|ip: [u8; 16]| Some(IpAddr::from(ip))) - .unwrap_or_else(|addr| { - warn!("Could not Convert vec: {addr:?} to ipv4 or ipv6"); - None - }) - }); - - match &ip_addr { - Some(IpAddr::V4(ip_addr)) => { + for nla_address in msg.attributes.into_iter() { + if let AddressAttribute::Address(addr) = nla_address { + match &addr { + IpAddr::V4(ip_addr) => { info!("\t ipv4: {ip_addr}"); } - Some(IpAddr::V6(ip_addr)) => { + IpAddr::V6(ip_addr) => { info!("\t ipv6: {ip_addr}"); } - None => {} } } }