|
@@ -5,7 +5,6 @@ import (
|
|
"net"
|
|
"net"
|
|
"os"
|
|
"os"
|
|
"os/exec"
|
|
"os/exec"
|
|
- "path/filepath"
|
|
|
|
"runtime"
|
|
"runtime"
|
|
"sync"
|
|
"sync"
|
|
"syscall"
|
|
"syscall"
|
|
@@ -48,9 +47,6 @@ func createBasePath() {
|
|
panic("Could not create net namespace path directory")
|
|
panic("Could not create net namespace path directory")
|
|
}
|
|
}
|
|
|
|
|
|
- // cleanup any stale namespace files if any
|
|
|
|
- cleanupNamespaceFiles()
|
|
|
|
-
|
|
|
|
// Start the garbage collection go routine
|
|
// Start the garbage collection go routine
|
|
go removeUnusedPaths()
|
|
go removeUnusedPaths()
|
|
}
|
|
}
|
|
@@ -155,24 +151,6 @@ func createNetworkNamespace(path string, osCreate bool) (*Info, error) {
|
|
return info, nil
|
|
return info, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func cleanupNamespaceFiles() {
|
|
|
|
- filepath.Walk(prefix, func(path string, info os.FileInfo, err error) error {
|
|
|
|
- stat, err := os.Stat(path)
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if stat.IsDir() {
|
|
|
|
- return filepath.SkipDir
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- syscall.Unmount(path, syscall.MNT_DETACH)
|
|
|
|
- os.Remove(path)
|
|
|
|
-
|
|
|
|
- return nil
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func unmountNamespaceFile(path string) {
|
|
func unmountNamespaceFile(path string) {
|
|
if _, err := os.Stat(path); err == nil {
|
|
if _, err := os.Stat(path); err == nil {
|
|
syscall.Unmount(path, syscall.MNT_DETACH)
|
|
syscall.Unmount(path, syscall.MNT_DETACH)
|