Blob Blame History Raw
From 4c377f04f571c2d265a564bb27961bac5fd4a854 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Mon, 5 Nov 2018 14:33:50 +0100
Subject: [PATCH] [networking] Replace "brctl: by "bridge" commands

As bridge-utils containing brctl command are being deprecated,
sosreport should call bridge command instead.

Although the mapping of the commands is not 1:1, the data collected
(together with few "ip .." commands) will remain the same.

Resolves: #1472

Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
 sos/plugins/networking.py | 38 ++++++++------------------------------
 sos/plugins/xen.py        |  2 +-
 2 files changed, 9 insertions(+), 31 deletions(-)

diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py
index fa3d0cda..5f532707 100644
--- a/sos/plugins/networking.py
+++ b/sos/plugins/networking.py
@@ -25,24 +25,6 @@ class Networking(Plugin):
     # switch to enable netstat "wide" (non-truncated) output mode
     ns_wide = "-W"
 
-    def get_bridge_name(self, brctl_file):
-        """Return a list for which items are bridge name according to the
-        output of brctl show stored in brctl_file.
-        """
-        out = []
-        try:
-            brctl_out = open(brctl_file).read()
-        except IOError:
-            return out
-        for line in brctl_out.splitlines():
-            if line.startswith("bridge name") \
-               or line.isspace() \
-               or line[:1].isspace():
-                continue
-            br_name, br_rest = line.split(None, 1)
-            out.append(br_name)
-        return out
-
     def get_eth_interfaces(self, ip_link_out):
         """Return a dictionary for which keys are ethernet interface
         names taken from the output of "ip -o link".
@@ -215,18 +197,14 @@ class Networking(Plugin):
                     "ethtool -g "+eth
                 ])
 
-        # brctl command will load bridge and related kernel modules
-        # if those modules are not loaded at the time of brctl command running
-        # This behaviour causes an unexpected configuration change for system.
-        # sosreport should aovid such situation.
-        if self.is_module_loaded("bridge"):
-            brctl_file = self.get_cmd_output_now("brctl show")
-            if brctl_file:
-                for br_name in self.get_bridge_name(brctl_file):
-                    self.add_cmd_output([
-                        "brctl showstp "+br_name,
-                        "brctl showmacs "+br_name
-                    ])
+        # Collect information about bridges (some data already collected via
+        # "ip .." commands)
+        self.add_cmd_output([
+            "bridge -s -s -d link show",
+            "bridge -s -s -d -t fdb show",
+            "bridge -s -s -d -t mdb show",
+            "bridge -d vlan show"
+        ])
 
         if self.get_option("traceroute"):
             self.add_cmd_output("/bin/traceroute -n %s" % self.trace_host)
diff --git a/sos/plugins/xen.py b/sos/plugins/xen.py
index 2ad8dae9..ace6c362 100644
--- a/sos/plugins/xen.py
+++ b/sos/plugins/xen.py
@@ -78,7 +78,7 @@ class Xen(Plugin, RedHatPlugin):
                 "xm info",
                 "xm list",
                 "xm list --long",
-                "brctl show"
+                "bridge link show"
             ])
             self.dom_collect_proc()
             if self.is_running_xenstored():
-- 
2.17.2