@@ -103,39 +103,6 @@ pub fn delete_netns(name: &str) -> Result<()> {
103103 fs:: remove_file ( & netns_path)
104104 . with_context ( || format ! ( "Failed to remove namespace file {:?}" , netns_path) ) ?;
105105
106- debug ! ( "Deleted network namespace: {}" , name) ;
107- Ok ( ( ) )
108- }
109-
110- /// Execute a function within a network namespace
111- ///
112- /// This switches to the namespace, executes the function, then returns to the original namespace
113- pub fn with_netns < F , R > ( name : & str , f : F ) -> Result < R >
114- where
115- F : FnOnce ( ) -> Result < R > ,
116- {
117- let netns_path = PathBuf :: from ( NETNS_RUN_DIR ) . join ( name) ;
118-
119- // Open the namespace file
120- let netns_fd = fs:: File :: open ( & netns_path)
121- . with_context ( || format ! ( "Failed to open namespace {:?}" , netns_path) ) ?;
122-
123- // Open current namespace to restore later
124- let current_ns =
125- fs:: File :: open ( "/proc/self/ns/net" ) . context ( "Failed to open current network namespace" ) ?;
126-
127- // Enter the target namespace
128- setns ( & netns_fd, CloneFlags :: CLONE_NEWNET ) . context ( "Failed to enter namespace" ) ?;
129-
130- // Execute the function
131- let result = f ( ) ;
132-
133- // Return to original namespace
134- let _ = setns ( & current_ns, CloneFlags :: CLONE_NEWNET ) ;
135-
136- result
137- }
138-
139106/// Create a veth pair (mimics `ip link add <name1> type veth peer name <name2>`)
140107pub async fn create_veth_pair ( name1 : & str , name2 : & str ) -> Result < ( ) > {
141108 let ( connection, handle, _) = new_connection ( ) ?;
0 commit comments