From 6a394a9a861c4837f7f030b15bdd5a29c79f3fa7 Mon Sep 17 00:00:00 2001 From: Chris Burger Date: Sun, 20 Sep 2020 15:57:46 -0500 Subject: [PATCH] Use IFF_RUNNING instead of IFF_UP for Linux --- psutil/_psutil_posix.c | 2 +- psutil/tests/test_linux.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/psutil/_psutil_posix.c b/psutil/_psutil_posix.c index f7f8b92dd..8fe7f6b7d 100644 --- a/psutil/_psutil_posix.c +++ b/psutil/_psutil_posix.c @@ -404,7 +404,7 @@ psutil_net_if_flags(PyObject *self, PyObject *args) { goto error; close(sock); - if ((ifr.ifr_flags & IFF_UP) != 0) + if ((ifr.ifr_flags & IFF_RUNNING) != 0) return Py_BuildValue("O", Py_True); else return Py_BuildValue("O", Py_False); diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index 9dd12890c..7e09bac0c 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -919,8 +919,7 @@ def test_against_ifconfig(self): except RuntimeError: pass else: - # Not always reliable. - # self.assertEqual(stats.isup, 'RUNNING' in out, msg=out) + self.assertEqual(stats.isup, 'RUNNING' in out, msg=out) self.assertEqual(stats.mtu, int(re.findall(r'(?i)MTU[: ](\d+)', out)[0]))