Close opened netns
This commit is contained in:
1 parent
fd5e1970e1
commit
9b32bc2ab3
1 file changed
+2
@@ -130,6 +130,7 @@ func GetNetDevsWithPredicate(processID int, predicate func(link netlink.Link) bo
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to open root namespace: %s", err)
|
||||
}
|
||||
defer nsToplevel.Close()
|
||||
nsContainr, err := netns.GetFromPid(processID)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
@@ -137,6 +138,7 @@ func GetNetDevsWithPredicate(processID int, predicate func(link netlink.Link) bo
|
||||
}
|
||||
return nil, fmt.Errorf("unable to open process %d namespace: %s", processID, err)
|
||||
}
|
||||
defer nsContainr.Close()
|
||||
if nsToplevel.Equal(nsContainr) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user