mirror of
https://codeberg.org/icewind/netnsd.git
synced 2026-06-03 17:14:06 +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,4 +1,5 @@
|
|||
use crate::config::{Config, NamespaceName};
|
||||
use crate::link::{LinkError, LinkManager};
|
||||
use crate::namespace::NetNs;
|
||||
use main_error::MainResult;
|
||||
use tracing::error;
|
||||
|
|
@ -24,6 +25,14 @@ pub fn up(config: Config) -> MainResult {
|
|||
error!(%error, "failed to move device into namespace");
|
||||
}
|
||||
}
|
||||
for route in new.routes {
|
||||
namespace.handle().run_in(|| {
|
||||
let manager = LinkManager::new()?;
|
||||
let link = manager.get_link(&route.device)?;
|
||||
manager.add_route(&link, route.destination)?;
|
||||
Ok::<_, LinkError>(())
|
||||
})??;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue