@@ -8,7 +8,7 @@ use tokio::sync::oneshot;
88
99use crate :: dynch:: { DynCh , DynRequestSender } ;
1010use crate :: namespace:: helpers:: current_netns;
11- use crate :: network:: RuntimeMakerFn ;
11+ use crate :: network:: RuntimeFactory ;
1212
1313/// Base directory for named network namespaces.
1414///
@@ -231,7 +231,7 @@ impl NetworkNamespaceInner {
231231 /// `setns(2)`, which is thread-local.
232232 pub fn spawn < Ctx : ' static > (
233233 self ,
234- make_runtime : RuntimeMakerFn ,
234+ runtime_factory : RuntimeFactory ,
235235 make_ctx : impl FnOnce ( ) -> Ctx + Send + ' static ,
236236 ) -> ( std:: thread:: JoinHandle < Result < ( ) > > , DynRequestSender < Ctx > ) {
237237 let ( tx, mut rx) = DynCh :: < Ctx > :: channel ( 8 ) ;
@@ -247,7 +247,7 @@ impl NetworkNamespaceInner {
247247 // Create mount namespace and remount /proc for namespace-specific sysctl access
248248 helpers:: setup_mount_namespace ( ) ?;
249249
250- let rt = make_runtime ( ) ;
250+ let rt = runtime_factory ( ) ;
251251
252252 tracing:: debug!( "started runtime" ) ;
253253 drop ( _span) ;
@@ -288,7 +288,7 @@ pub struct NetworkNamespace<Ctx = ()> {
288288impl NetworkNamespace {
289289 pub async fn new < Ctx : ' static > (
290290 name : impl Into < String > ,
291- make_runtime : RuntimeMakerFn ,
291+ runtime_factory : RuntimeFactory ,
292292 make_ctx : impl FnOnce ( ) -> Ctx + Send + ' static ,
293293 ) -> Result < NetworkNamespace < Ctx > > {
294294 let name = name. into ( ) ;
@@ -299,7 +299,7 @@ impl NetworkNamespace {
299299 let file = tokio:: fs:: File :: open ( path) . await ?. into_std ( ) . await ;
300300
301301 let inner = NetworkNamespaceInner { name, file } ;
302- let ( _receiver_task, task_sender) = inner. try_clone ( ) ?. spawn ( make_runtime , make_ctx) ;
302+ let ( _receiver_task, task_sender) = inner. try_clone ( ) ?. spawn ( runtime_factory , make_ctx) ;
303303
304304 Ok ( NetworkNamespace :: < Ctx > { inner, task_sender, _receiver_task } )
305305 }
@@ -353,17 +353,18 @@ mod tests {
353353 const TCP_SLOW_START_AFTER_IDLE : & str = "/proc/sys/net/ipv4/tcp_slow_start_after_idle" ;
354354
355355 fn default_runtime ( ) -> tokio:: runtime:: Runtime {
356- tokio:: runtime:: Builder :: new_multi_thread ( )
357- . enable_all ( )
358- . build ( )
359- . expect ( "to create runtime" )
356+ tokio:: runtime:: Builder :: new_multi_thread ( ) . enable_all ( ) . build ( ) . expect ( "to create runtime" )
360357 }
361358
362359 #[ tokio:: test( flavor = "multi_thread" ) ]
363360 async fn mount_namespace_isolates_proc ( ) {
364361 // Create two namespaces
365- let ns1 = NetworkNamespace :: new ( "test-ns-mount-1" , Box :: new ( default_runtime) , || ( ) ) . await . unwrap ( ) ;
366- let ns2 = NetworkNamespace :: new ( "test-ns-mount-2" , Box :: new ( default_runtime) , || ( ) ) . await . unwrap ( ) ;
362+ let ns1 = NetworkNamespace :: new ( "test-ns-mount-1" , Box :: new ( default_runtime) , || ( ) )
363+ . await
364+ . unwrap ( ) ;
365+ let ns2 = NetworkNamespace :: new ( "test-ns-mount-2" , Box :: new ( default_runtime) , || ( ) )
366+ . await
367+ . unwrap ( ) ;
367368
368369 // Verify /proc is mounted in ns1 by checking /proc/self/ns/net exists
369370 let proc_mounted_ns1: bool = ns1
@@ -395,8 +396,12 @@ mod tests {
395396 #[ tokio:: test( flavor = "multi_thread" ) ]
396397 async fn sysctl_values_are_namespace_specific ( ) {
397398 // Create two namespaces
398- let ns1 = NetworkNamespace :: new ( "test-ns-sysctl-1" , Box :: new ( default_runtime) , || ( ) ) . await . unwrap ( ) ;
399- let ns2 = NetworkNamespace :: new ( "test-ns-sysctl-2" , Box :: new ( default_runtime) , || ( ) ) . await . unwrap ( ) ;
399+ let ns1 = NetworkNamespace :: new ( "test-ns-sysctl-1" , Box :: new ( default_runtime) , || ( ) )
400+ . await
401+ . unwrap ( ) ;
402+ let ns2 = NetworkNamespace :: new ( "test-ns-sysctl-2" , Box :: new ( default_runtime) , || ( ) )
403+ . await
404+ . unwrap ( ) ;
400405
401406 // Set different values in each namespace
402407 let write_result_ns1: std:: io:: Result < ( ) > = ns1
@@ -462,7 +467,9 @@ mod tests {
462467 #[ tokio:: test( flavor = "multi_thread" ) ]
463468 async fn namespace_has_isolated_network_identity ( ) {
464469 // Create a namespace
465- let ns = NetworkNamespace :: new ( "test-ns-identity" , Box :: new ( default_runtime) , || ( ) ) . await . unwrap ( ) ;
470+ let ns = NetworkNamespace :: new ( "test-ns-identity" , Box :: new ( default_runtime) , || ( ) )
471+ . await
472+ . unwrap ( ) ;
466473
467474 // Get the network namespace inode from inside the namespace
468475 let ns_inode_inside: u64 = ns
0 commit comments