From 42505f64d29e73106dc29658fe7e852b9a5421c5 Mon Sep 17 00:00:00 2001
From: Matthew Heon <matthew.heon@pm.me>
Date: Tue, 2 Jun 2020 16:31:01 -0400
Subject: 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>
---
 libpod/networking_linux.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'libpod')

diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index 83344ebbe..0c9d28701 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -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
 }
-- 
cgit v1.2.3-54-g00ecf