From 763c86b3b2e5fb34d4167cf13ed37de778134662 Mon Sep 17 00:00:00 2001 From: flouthoc Date: Wed, 28 May 2025 08:05:08 -0700 Subject: [PATCH 1/4] cargo: bump mozim to 0.2.6 Contains patch for https://github.com/nispor/mozim/issues/49 Fixes: https://github.com/containers/netavark/issues/811 Closes: RUN-2720 Signed-off-by: flouthoc (cherry picked from commit 769a2ac52829b9125c95254005aa21b252acae6b) (cherry-pick was clean but Cargo.lock had to be regenerated) Signed-off-by: Paul Holzinger --- Cargo.lock | 29 +++++++++-------------------- Cargo.toml | 2 +- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fbc5109..5c89ecf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -487,9 +487,9 @@ checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" [[package]] name = "dhcproto" -version = "0.9.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcee045385d5f7819022821f41209b9945d17550760b0b2349aaef4ecfa14bc3" +checksum = "f6794294f2c4665aae452e950c2803a1e487c5672dc8448f0bfa3f52ff67e270" dependencies = [ "dhcproto-macros", "hex", @@ -1221,7 +1221,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43b627935a2f5d654613bea2bcd677cc760b03ecf224ced0f1970c0d174813b9" dependencies = [ "lazy_static", - "nix 0.29.0", + "nix", "regex", ] @@ -1371,9 +1371,9 @@ dependencies = [ [[package]] name = "mozim" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "610e34113d007c3588631f879854c14fbf291f3ab7853b833220f7cbf6ece8ad" +checksum = "8232b853f83a0c76331d934627aeec172e9d5f2c82d1f9e7f86caa0df72cb304" dependencies = [ "byteorder", "dhcproto", @@ -1382,7 +1382,7 @@ dependencies = [ "libc", "log", "nispor", - "nix 0.27.1", + "nix", "rand 0.8.5", ] @@ -1435,7 +1435,7 @@ dependencies = [ "netlink-sys", "nftables", "nispor", - "nix 0.29.0", + "nix", "once_cell", "prost", "rand 0.9.1", @@ -1562,17 +1562,6 @@ dependencies = [ "wl-nl80211", ] -[[package]] -name = "nix" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" -dependencies = [ - "bitflags", - "cfg-if", - "libc", -] - [[package]] name = "nix" version = "0.29.0" @@ -1926,7 +1915,7 @@ dependencies = [ "netlink-packet-utils", "netlink-proto", "netlink-sys", - "nix 0.29.0", + "nix", "thiserror 1.0.69", "tokio", ] @@ -2927,7 +2916,7 @@ dependencies = [ "futures-core", "futures-lite", "hex", - "nix 0.29.0", + "nix", "ordered-stream", "serde", "serde_repr", diff --git a/Cargo.toml b/Cargo.toml index d536345..a5d89fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,7 @@ fs2 = "0.4.3" tokio = { version = "1.45.0", features = ["rt", "rt-multi-thread", "signal", "fs"] } tokio-stream = { version = "0.1.17", features = ["net"] } tonic = "0.13.1" -mozim = "0.2.5" +mozim = "0.2.6" prost = "0.13.5" futures-channel = "0.3.31" futures-core = "0.3.31" From 913bf55e2d55b7cd1cf582012a62658ccf16ef78 Mon Sep 17 00:00:00 2001 From: flouthoc Date: Wed, 28 May 2025 11:03:36 -0700 Subject: [PATCH 2/4] dhcp_proxy: set timeout_sender only if required When `--activity-timeout 0` there should be no reason to push messages on `activity_timeout_tx` as `activity_timeout_rx` is not receving any messages as a result all the messages pushed are just stuck in queue, resulting in `no available capacity` when queue becomes full. Closes: https://github.com/containers/netavark/issues/1262 Signed-off-by: flouthoc (cherry picked from commit acd3949531051840cc83beb8c54e11eb2c533495) Signed-off-by: Paul Holzinger --- src/commands/dhcp_proxy.rs | 73 ++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/src/commands/dhcp_proxy.rs b/src/commands/dhcp_proxy.rs index fc2d261..d55d046 100644 --- a/src/commands/dhcp_proxy.rs +++ b/src/commands/dhcp_proxy.rs @@ -56,7 +56,7 @@ struct NetavarkProxyService { // the timeout for the dora operation dora_timeout: u32, // channel send-side for resetting the inactivity timeout - timeout_sender: Arc>>, + timeout_sender: Option>>>, // All dhcp poll will be spawned on a new task, keep track of it so // we can remove it on teardown. The key is the container mac. task_map: Arc>>, @@ -64,17 +64,19 @@ struct NetavarkProxyService { impl NetavarkProxyService { fn reset_inactivity_timeout(&self) { - let sender = self.timeout_sender.clone(); - let locked_sender = match sender.lock() { - Ok(v) => v, - Err(e) => { - log::error!("{}", e); - return; + if let Some(sender) = &self.timeout_sender { + let sender_clone = sender.clone(); + let locked_sender = match sender_clone.lock() { + Ok(v) => v, + Err(e) => { + log::error!("{}", e); + return; + } + }; + match locked_sender.try_send(1) { + Ok(..) => {} + Err(e) => log::error!("{}", e), } - }; - match locked_sender.try_send(1) { - Ok(..) => {} - Err(e) => log::error!("{}", e), } } } @@ -285,11 +287,18 @@ pub async fn serve(opts: Opts) -> NetavarkResult<()> { // Create send and receive channels for activity timeout. If anything is // sent by the tx side, the inactivity timeout is reset - let (activity_timeout_tx, activity_timeout_rx) = mpsc::channel(5); + let (activity_timeout_tx, activity_timeout_rx) = if inactivity_timeout.as_secs() > 0 { + let (tx, rx) = mpsc::channel(5); + (Some(tx), Some(rx)) + } else { + (None, None) + }; let netavark_proxy_service = NetavarkProxyService { cache: cache.clone(), dora_timeout, - timeout_sender: Arc::new(Mutex::new(activity_timeout_tx.clone())), + timeout_sender: activity_timeout_tx + .clone() + .map(|tx| Arc::new(Mutex::new(tx))), task_map: Arc::new(Mutex::new(HashMap::new())), }; @@ -328,29 +337,31 @@ pub async fn serve(opts: Opts) -> NetavarkResult<()> { /// /// ``` async fn handle_wakeup( - mut rx: mpsc::Receiver, + rx: Option>, timeout_duration: Duration, current_cache: Arc>>, ) { - loop { - match timeout(timeout_duration, rx.recv()).await { - Ok(Some(_)) => { - debug!("timeout timer reset") - } - Ok(None) => { - println!("timeout channel closed"); - break; - } - Err(_) => { - // only 'exit' if the timeout is met AND there are no leases - // if we do not exit, the activity_timeout is reset - if is_catch_empty(current_cache.clone()) { - println!( - "timeout met: exiting after {} secs of inactivity", - timeout_duration.as_secs() - ); + if let Some(mut rx) = rx { + loop { + match timeout(timeout_duration, rx.recv()).await { + Ok(Some(_)) => { + debug!("timeout timer reset") + } + Ok(None) => { + println!("timeout channel closed"); break; } + Err(_) => { + // only 'exit' if the timeout is met AND there are no leases + // if we do not exit, the activity_timeout is reset + if is_catch_empty(current_cache.clone()) { + println!( + "timeout met: exiting after {} secs of inactivity", + timeout_duration.as_secs() + ); + break; + } + } } } } From 937edfbb57ce4f3234404b5170ee9f5c29f6fef3 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 4 Jun 2025 12:22:15 +0200 Subject: [PATCH 3/4] release notes for v1.15.2 Signed-off-by: Paul Holzinger --- RELEASE_NOTES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 12eecc9..4ff41c6 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,10 @@ # Release Notes +## v1.15.2 + +* Fixed a bug that caused a thread leak in the dhcp-proxy for each started container. ([#811](https://github.com/containers/netavark/issues/811)) +* Fixed a bug which printed bogus errors when the dhcp-proxy was run with an activity timeout of 0. ([#1262](https://github.com/containers/netavark/issues/1262)) + ## v1.15.1 * Fixed a regression that caused container name lookups to get the wrong ip address when the host's search domain responded for the same name. ([containers/podman#26198](https://github.com/containers/podman/issues/26198)) From 01b002ffea76934739836bddabe223908f48eb76 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 4 Jun 2025 12:24:28 +0200 Subject: [PATCH 4/4] release v1.15.2 Signed-off-by: Paul Holzinger --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c89ecf..751fba1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1414,7 +1414,7 @@ checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" [[package]] name = "netavark" -version = "1.15.1" +version = "1.15.2" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index a5d89fe..484cf89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "netavark" -version = "1.15.1" +version = "1.15.2" edition = "2021" authors = ["github.com/containers"] license = "Apache-2.0"