mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00
Properly follow linked namespace container for stats
Podman containers can specify that they get their network namespace from another container. This is automatic in pods, but any container can do it. The problem is that these containers are not guaranteed to have a network namespace of their own; it is perfectly valid to join the network namespace of a --net=host container, and both containers will end up in the host namespace. The code for obtaining network stats did not account for this, and could cause segfaults as a result. Fortunately, the fix is simple - the function we use to get said stats already performs appropriate checks, so we just need to recursively call it. Fixes #5652 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
@ -550,7 +550,7 @@ func getContainerNetNS(ctr *Container) (string, error) {
|
||||
if err = c.syncContainer(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return c.state.NetNS.Path(), nil
|
||||
return getContainerNetNS(c)
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user