f-10: code: add create and delete netns #10
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
473e1d0108
commit
454005d6ac
7 changed files with 107 additions and 0 deletions
18
internal/netns/delete_linux.go
Normal file
18
internal/netns/delete_linux.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
//go:build linux
|
||||
|
||||
package netns
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func delete(name string) error {
|
||||
path := "/var/run/netns/" + name
|
||||
|
||||
if err := unix.Unmount(path, unix.MNT_DETACH); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Remove(path)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue