1
0
mirror of https://github.com/containers/netavark.git synced 2026-02-05 06:45:56 +01:00

mozim: do not use netlink feature

mozim uses rtnetlink which we do not otherwise. All mozim uses it for is
to get the interface index which can lookup easily ourselves.

This saves about 500KB in binary size.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2025-12-11 15:07:29 +01:00
parent 6f77f76ee9
commit f2c5265a3a
3 changed files with 18 additions and 85 deletions

88
Cargo.lock generated
View File

@@ -593,7 +593,6 @@ checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
@@ -616,17 +615,6 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
[[package]]
name = "futures-executor"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-io"
version = "0.3.31"
@@ -1019,9 +1007,8 @@ dependencies = [
"futures",
"libc",
"log",
"nix 0.30.1",
"nix",
"rand",
"rtnetlink",
"tokio",
]
@@ -1052,7 +1039,7 @@ dependencies = [
"netlink-packet-route",
"netlink-sys",
"nftables",
"nix 0.30.1",
"nix",
"once_cell",
"prost",
"rand",
@@ -1090,20 +1077,6 @@ dependencies = [
"netlink-packet-core",
]
[[package]]
name = "netlink-proto"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b65d130ee111430e47eed7896ea43ca693c387f097dd97376bffafbf25812128"
dependencies = [
"bytes",
"futures",
"log",
"netlink-packet-core",
"netlink-sys",
"thiserror 2.0.17",
]
[[package]]
name = "netlink-sys"
version = "0.8.7"
@@ -1111,10 +1084,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16c903aa70590cb93691bf97a767c8d1d6122d2cc9070433deb3bbf36ce8bd23"
dependencies = [
"bytes",
"futures",
"libc",
"log",
"tokio",
]
[[package]]
@@ -1129,19 +1100,7 @@ dependencies = [
"serde_path_to_error",
"strum",
"strum_macros",
"thiserror 2.0.17",
]
[[package]]
name = "nix"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [
"bitflags",
"cfg-if",
"cfg_aliases",
"libc",
"thiserror",
]
[[package]]
@@ -1492,23 +1451,6 @@ version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
[[package]]
name = "rtnetlink"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08fd15aa4c64c34d0b3178e45ec6dad313a9f02b193376d501668a7950264bb7"
dependencies = [
"futures",
"log",
"netlink-packet-core",
"netlink-packet-route",
"netlink-proto",
"netlink-sys",
"nix 0.29.0",
"thiserror 1.0.69",
"tokio",
]
[[package]]
name = "rustix"
version = "1.1.2"
@@ -1743,33 +1685,13 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "thiserror"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [
"thiserror-impl 1.0.69",
]
[[package]]
name = "thiserror"
version = "2.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
dependencies = [
"thiserror-impl 2.0.17",
]
[[package]]
name = "thiserror-impl"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [
"proc-macro2",
"quote",
"syn",
"thiserror-impl",
]
[[package]]
@@ -2320,7 +2242,7 @@ dependencies = [
"futures-core",
"futures-lite",
"hex",
"nix 0.30.1",
"nix",
"ordered-stream",
"serde",
"serde_repr",

View File

@@ -55,7 +55,7 @@ tokio-stream = { version = "0.1.17", features = ["net"] }
tonic = "0.14.2"
tonic-prost = "0.14.2"
prost = "0.14.1"
mozim = "0.3.1"
mozim = { version = "0.3.1", default-features = false }
futures-channel = "0.3.31"
futures-core = "0.3.31"
futures-util = "0.3.31"

View File

@@ -1,6 +1,9 @@
use std::{net::Ipv4Addr, sync::Arc};
use crate::network::netlink_route::{LinkID, Route};
use crate::network::{
netlink,
netlink_route::{LinkID, NetlinkRoute, Route},
};
use log::debug;
use mozim::{DhcpV4Client, DhcpV4Config, DhcpV4Lease as MozimV4Lease, DhcpV4State};
use tokio::sync::Mutex;
@@ -54,6 +57,14 @@ impl DhcpV4Service {
.map_err(|e| DhcpServiceError::new(InvalidArgument, e.to_string()))?;
config.set_timeout_sec(timeout);
let mut socket = netlink::Socket::<NetlinkRoute>::new()
.map_err(|e| DhcpServiceError::new(InvalidArgument, e.to_string()))?;
let link = socket
.get_link(LinkID::Name(nc.host_iface.clone()))
.map_err(|e| DhcpServiceError::new(InvalidArgument, e.to_string()))?;
config.set_iface_index(link.header.index);
// Sending the hostname to the DHCP server is optional but it can be
// useful in environments where DDNS is used to create or update
// DNS records.