From c56cf43d221997798ab1371691162aeebc2f42dd Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 9 Mar 2025 19:57:56 +0100 Subject: [PATCH 1/3] Update to smoltcp 0.11 --- Cargo.lock | 70 +++++------------------------------------------------- Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79ec928a66..f1d09d3248 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,15 +28,6 @@ name = "arg_parser" version = "0.1.0" source = "git+https://gitlab.redox-os.org/redox-os/arg-parser.git#1c434b55f3e1a0375ebcca85b3e88db7378e82fa" -[[package]] -name = "atomic-polyfill" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" -dependencies = [ - "critical-section", -] - [[package]] name = "autocfg" version = "1.4.0" @@ -114,12 +105,6 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" -[[package]] -name = "critical-section" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" - [[package]] name = "crossbeam-channel" version = "0.5.13" @@ -179,23 +164,20 @@ dependencies = [ [[package]] name = "hash32" -version = "0.2.1" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" dependencies = [ "byteorder 1.5.0", ] [[package]] name = "heapless" -version = "0.7.17" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" dependencies = [ - "atomic-polyfill", "hash32", - "rustc_version", - "spin", "stable_deref_trait", ] @@ -270,16 +252,6 @@ dependencies = [ "redox_syscall", ] -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.22" @@ -486,27 +458,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20145670ba436b55d91fc92d25e71160fbfbdd57831631c8d7d36377a476f1cb" -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - [[package]] name = "shlex" version = "1.3.0" @@ -521,9 +472,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smoltcp" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2e3a36ac8fea7b94e666dfa3871063d6e0a5c9d5d4fec9a1a6b7b6760f0229" +checksum = "5a1a996951e50b5971a2c8c0fa05a381480d70a933064245c4a223ddc87ccc97" dependencies = [ "bitflags 1.3.2", "byteorder 1.5.0", @@ -534,15 +485,6 @@ dependencies = [ "managed", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/Cargo.toml b/Cargo.toml index 221b2ec6a3..73e9390b05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ default-features = false features = ["release_max_level_warn"] [dependencies.smoltcp] -version = "0.10.0" +version = "0.11.0" default-features = false features = [ "std", From b92be2e7d96dbff0f24043ce2bad031c491b2d3c Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 9 Mar 2025 20:07:19 +0100 Subject: [PATCH 2/3] Update to smoltcp 0.12 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/smolnetd/link/ethernet.rs | 6 +++++- src/smolnetd/router/mod.rs | 2 +- src/smolnetd/scheme/netcfg/mod.rs | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f1d09d3248..e12d606f91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -472,9 +472,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smoltcp" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a1a996951e50b5971a2c8c0fa05a381480d70a933064245c4a223ddc87ccc97" +checksum = "dad095989c1533c1c266d9b1e8d70a1329dd3723c3edac6d03bbd67e7bf6f4bb" dependencies = [ "bitflags 1.3.2", "byteorder 1.5.0", diff --git a/Cargo.toml b/Cargo.toml index 73e9390b05..24da1df44b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ default-features = false features = ["release_max_level_warn"] [dependencies.smoltcp] -version = "0.11.0" +version = "0.12.0" default-features = false features = [ "std", diff --git a/src/smolnetd/link/ethernet.rs b/src/smolnetd/link/ethernet.rs index 58dfab3d13..5f32a479dd 100644 --- a/src/smolnetd/link/ethernet.rs +++ b/src/smolnetd/link/ethernet.rs @@ -137,7 +137,11 @@ impl EthernetLink { return; } - if !source_hardware_addr.is_unicast() || !source_protocol_addr.is_unicast() { + if !source_hardware_addr.is_unicast() + || source_protocol_addr.is_broadcast() + || source_protocol_addr.is_multicast() + || source_protocol_addr.is_unspecified() + { return; } diff --git a/src/smolnetd/router/mod.rs b/src/smolnetd/router/mod.rs index 40a360ecf0..3cfd0a2fea 100644 --- a/src/smolnetd/router/mod.rs +++ b/src/smolnetd/router/mod.rs @@ -178,7 +178,7 @@ pub struct RxToken<'a> { impl<'a> smoltcp::phy::RxToken for RxToken<'a> { fn consume(self, f: F) -> R where - F: FnOnce(&mut [u8]) -> R, + F: FnOnce(&[u8]) -> R, { let ((), buf) = self .rx_buffer diff --git a/src/smolnetd/scheme/netcfg/mod.rs b/src/smolnetd/scheme/netcfg/mod.rs index 95492838ef..846bcddfdb 100644 --- a/src/smolnetd/scheme/netcfg/mod.rs +++ b/src/smolnetd/scheme/netcfg/mod.rs @@ -82,7 +82,7 @@ fn mk_root_node( if cur_value.is_none() { let ip = Ipv4Address::from_str(line.trim()) .map_err(|_| SyscallError::new(syscall::EINVAL))?; - if !ip.is_unicast() { + if ip.is_broadcast() || ip.is_multicast() || ip.is_unspecified() { return Err(SyscallError::new(syscall::EINVAL)); } *cur_value = Some(ip); From d7c128684d8e030e678bab8277653bb6e2c2e908 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 9 Mar 2025 20:12:37 +0100 Subject: [PATCH 3/3] Use CUBIC as TCP congestion controller Support for TCP congestion control has been introduced in smoltcp 0.12. Smoltcp supports Reno and CUBIC. Of the two CUBIC has higher throughput. Enabling the socket-tcp-cubic feature is enough to default to CUBIC. With this change pkg install libgcc is about 35% faster than previously without congestion control. (5.5MiB/s vs 4MiB/s previously) --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 24da1df44b..a1efb585eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ features = [ "std", "medium-ethernet", "medium-ip", "proto-ipv4", - "socket-raw", "socket-icmp", "socket-udp", "socket-tcp", + "socket-raw", "socket-icmp", "socket-udp", "socket-tcp", "socket-tcp-cubic", "iface-max-addr-count-8", "log" ]