use alloc::sync::Arc;
use core::sync::atomic::AtomicU64;
use crate::sync::IrqMutex;
static NEXT_NET_NS_ID: AtomicU64 = AtomicU64::new(0);
pub static ROOT_NET_NS: ax_lazyinit::LazyLock<Arc<IrqMutex<NetNamespace>>> =
ax_lazyinit::LazyLock::new(|| Arc::new(IrqMutex::new(NetNamespace::new_root())));
pub struct NetNamespace {
pub ns_id: u64,
}
impl NetNamespace {
pub fn new_root() -> Self {
Self {
ns_id: NEXT_NET_NS_ID.fetch_add(1, core::sync::atomic::Ordering::Relaxed),
}
}
pub fn clone_ns(&self) -> Self {
Self {
ns_id: NEXT_NET_NS_ID.fetch_add(1, core::sync::atomic::Ordering::Relaxed),
}
}
}