From 46337b4708362e9fe2915c7efddc353d88a2cb5e Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 8 Dec 2020 09:59:00 -0500 Subject: Make `podman stats` slirp check more robust Just checking for `rootless.IsRootless()` does not catch all the cases where slirp4netns is in use - we actually allow it to be used as root as well. Fortify the conditional here so we don't fail in the root + slirp case. Fixes #7883 Signed-off-by: Matthew Heon --- libpod/networking_linux.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libpod') diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index 2171a9208..bf27989bf 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -900,10 +900,9 @@ func (r *Runtime) reloadContainerNetwork(ctr *Container) ([]*cnitypes.Result, er func getContainerNetIO(ctr *Container) (*netlink.LinkStatistics, error) { var netStats *netlink.LinkStatistics - // rootless v2 cannot seem to resolve its network connection to - // collect statistics. For now, we allow stats to at least run - // by returning nil - if rootless.IsRootless() { + // With slirp4netns, we can't collect statistics at present. + // For now, we allow stats to at least run by returning nil + if rootless.IsRootless() || ctr.config.NetMode.IsSlirp4netns() { return netStats, nil } netNSPath, netPathErr := getContainerNetNS(ctr) -- cgit v1.2.3-54-g00ecf