mirror of
https://codeberg.org/icewind/netnsd.git
synced 2026-06-03 09:04:07 +02:00
add support for setting up routing inside the netns
This commit is contained in:
parent
35c8f5cc6c
commit
7588b5db00
18 changed files with 272 additions and 53 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use crate::namespace::NamespaceEnterError;
|
||||
use nix::errno::Errno;
|
||||
use nix::sched::{setns, CloneFlags};
|
||||
use nix::sched::{CloneFlags, setns};
|
||||
use std::fs::File;
|
||||
use std::io::Error as IoError;
|
||||
use std::os::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd};
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ mod handle;
|
|||
mod raw;
|
||||
|
||||
use crate::config::{DeviceName, NamespaceName};
|
||||
use crate::link::{link_up, move_all_links, move_link_into, LinkError};
|
||||
use crate::link::{LinkError, link_up, move_all_links, move_link_into};
|
||||
pub use crate::namespace::handle::{NamespaceHandle, NamespaceHandleError};
|
||||
use crate::namespace::raw::{create_network_namespace, NamespaceSetupError};
|
||||
use crate::namespace::raw::{NamespaceSetupError, create_network_namespace};
|
||||
use either::Either;
|
||||
use nix::errno::Errno;
|
||||
use nix::mount::{mount, umount2, MntFlags, MsFlags};
|
||||
use std::fs::{create_dir, read_dir, remove_file, File};
|
||||
use nix::mount::{MntFlags, MsFlags, mount, umount2};
|
||||
use std::fs::{File, create_dir, read_dir, remove_file};
|
||||
use std::io::{Error as IoError, ErrorKind};
|
||||
use std::iter::empty;
|
||||
use std::os::unix::fs::symlink;
|
||||
|
|
@ -162,9 +162,7 @@ impl NetNs {
|
|||
pub fn delete(self) -> Result<(), NamespaceError> {
|
||||
let parent_namespace = NamespaceHandle::parent()?;
|
||||
|
||||
self.handle.run_in(|| {
|
||||
move_all_links(&parent_namespace)
|
||||
})??;
|
||||
self.handle.run_in(|| move_all_links(&parent_namespace))??;
|
||||
let name = self.path.file_name().unwrap().to_str().unwrap();
|
||||
info!(name, "deleting network namespace");
|
||||
match umount2(&self.path, MntFlags::MNT_DETACH) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use nix::errno::Errno;
|
||||
use nix::sched::{clone, CloneFlags};
|
||||
use nix::sched::{CloneFlags, clone};
|
||||
use nix::sys::signal::Signal;
|
||||
use nix::sys::wait::{waitpid, WaitStatus};
|
||||
use nix::sys::wait::{WaitStatus, waitpid};
|
||||
use std::path::PathBuf;
|
||||
use thiserror::Error;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue