Blob Blame History Raw
From 00a25deaba41cd34a2143b5324d22a7c35098c1c Mon Sep 17 00:00:00 2001
From: Jan Jansky <jjansky@redhat.com>
Date: Thu, 21 Jan 2021 09:48:29 +0100
Subject: [PATCH] [networking] Collect 'ethtool -e <device>' conditionally only

EEPROM dump collection might hang on specific types of devices, or
negatively impact the system otherwise. As a safe option, sos report
should collect the command when explicitly asked via a plugopt only.

Related: #2376
Resolved: #2380

Signed-off-by: Jan Jansky <jjansky@redhat.com>
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
 sos/plugins/networking.py | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py
index b04bb98..40f8b2f 100644
--- a/sos/plugins/networking.py
+++ b/sos/plugins/networking.py
@@ -27,7 +27,8 @@ class Networking(Plugin):
         ("namespaces", "Number of namespaces to collect, 0 for unlimited. " +
          "Incompatible with the namespace_pattern plugin option", "slow", 0),
         ("ethtool_namespaces", "Define if ethtool commands should be " +
-         "collected for namespaces", "slow", True)
+         "collected for namespaces", "slow", True),
+        ("eepromdump", "collect 'ethtool -e' for all devices", "slow", False)
     ]
 
     # switch to enable netstat "wide" (non-truncated) output mode
@@ -186,16 +187,15 @@ class Networking(Plugin):
                 "ethtool --show-eee " + eth
             ])
 
-            # skip EEPROM collection for 'bnx2x' NICs as this command
-            # can pause the NIC and is not production safe.
-            bnx_output = {
-                "cmd": "ethtool -i %s" % eth,
-                "output": "bnx2x"
-            }
-            bnx_pred = SoSPredicate(self,
-                                    cmd_outputs=bnx_output,
-                                    required={'cmd_outputs': 'none'})
-            self.add_cmd_output("ethtool -e %s" % eth, pred=bnx_pred)
+            # skip EEPROM collection by default, as it might hang or
+            # negatively impact the system on some device types
+            if self.get_option("eepromdump"):
+                cmd = "ethtool -e %s" % eth
+                self._log_warn("WARNING (about to collect '%s'): collecting "
+                               "an eeprom dump is known to cause certain NIC "
+                               "drivers (e.g. bnx2x/tg3) to interrupt device "
+                               "operation" % cmd)
+                self.add_cmd_output(cmd)
 
         # Collect information about bridges (some data already collected via
         # "ip .." commands)
-- 
1.8.3.1