File tree Expand file tree Collapse file tree 1 file changed +0
-29
lines changed Expand file tree Collapse file tree 1 file changed +0
-29
lines changed Original file line number Diff line number Diff line change @@ -107,35 +107,6 @@ pub fn delete_netns(name: &str) -> Result<()> {
107107 Ok ( ( ) )
108108}
109109
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-
139110/// Create a veth pair (mimics `ip link add <name1> type veth peer name <name2>`)
140111pub async fn create_veth_pair ( name1 : & str , name2 : & str ) -> Result < ( ) > {
141112 let ( connection, handle, _) = new_connection ( ) ?;
You can’t perform that action at this time.
0 commit comments