Blame SOURCES/sos-bz2004929-openvswitch-offline-analysis.patch

900e1b
From 3f0ec3e55e7dcec89dd7fad10084ea7f16178608 Mon Sep 17 00:00:00 2001
900e1b
From: Salvatore Daniele <sdaniele@redhat.com>
900e1b
Date: Tue, 7 Sep 2021 13:48:22 -0400
900e1b
Subject: [PATCH 1/2] [openvswitch] add ovs default OpenFlow protocols
900e1b
900e1b
ovs-vsctl list bridge can return an empty 'protocol' column even when
900e1b
there are OpenFlow protocols in place by default.
900e1b
900e1b
ovs-ofctl --version will return the range of supported ofp and should
900e1b
also be used to ensure flow information for relevant protocol versions
900e1b
is collected.
900e1b
900e1b
OpenFlow default versions:
900e1b
https://docs.openvswitch.org/en/latest/faq/openflow/
900e1b
900e1b
Signed-off-by: Salvatore Daniele <sdaniele@redhat.com>
900e1b
---
900e1b
 sos/report/plugins/openvswitch.py | 26 ++++++++++++++++++++++++++
900e1b
 1 file changed, 26 insertions(+)
900e1b
900e1b
diff --git a/sos/report/plugins/openvswitch.py b/sos/report/plugins/openvswitch.py
900e1b
index cd897db2..92cc7259 100644
900e1b
--- a/sos/report/plugins/openvswitch.py
900e1b
+++ b/sos/report/plugins/openvswitch.py
900e1b
@@ -206,6 +206,7 @@ class OpenVSwitch(Plugin):
900e1b
 
900e1b
         # Gather additional output for each OVS bridge on the host.
900e1b
         br_list_result = self.collect_cmd_output("ovs-vsctl -t 5 list-br")
900e1b
+        ofp_ver_result = self.collect_cmd_output("ovs-ofctl -t 5 --version")
900e1b
         if br_list_result['status'] == 0:
900e1b
             for br in br_list_result['output'].splitlines():
900e1b
                 self.add_cmd_output([
900e1b
@@ -232,6 +233,16 @@ class OpenVSwitch(Plugin):
900e1b
                     "OpenFlow15"
900e1b
                 ]
900e1b
 
900e1b
+                # Flow protocol hex identifiers
900e1b
+                ofp_versions = {
900e1b
+                    0x01: "OpenFlow10",
900e1b
+                    0x02: "OpenFlow11",
900e1b
+                    0x03: "OpenFlow12",
900e1b
+                    0x04: "OpenFlow13",
900e1b
+                    0x05: "OpenFlow14",
900e1b
+                    0x06: "OpenFlow15",
900e1b
+                }
900e1b
+
900e1b
                 # List protocols currently in use, if any
900e1b
                 ovs_list_bridge_cmd = "ovs-vsctl -t 5 list bridge %s" % br
900e1b
                 br_info = self.collect_cmd_output(ovs_list_bridge_cmd)
900e1b
@@ -242,6 +253,21 @@ class OpenVSwitch(Plugin):
900e1b
                         br_protos_ln = line[line.find("[")+1:line.find("]")]
900e1b
                         br_protos = br_protos_ln.replace('"', '').split(", ")
900e1b
 
900e1b
+                # If 'list bridge' yeilded no protocols, use the range of
900e1b
+                # protocols enabled by default on this version of ovs.
900e1b
+                if br_protos == [''] and ofp_ver_result['output']:
900e1b
+                    ofp_version_range = ofp_ver_result['output'].splitlines()
900e1b
+                    ver_range = []
900e1b
+
900e1b
+                    for line in ofp_version_range:
900e1b
+                        if "OpenFlow versions" in line:
900e1b
+                            v = line.split("OpenFlow versions ")[1].split(":")
900e1b
+                            ver_range = range(int(v[0], 16), int(v[1], 16)+1)
900e1b
+
900e1b
+                    for protocol in ver_range:
900e1b
+                        if protocol in ofp_versions:
900e1b
+                            br_protos.append(ofp_versions[protocol])
900e1b
+
900e1b
                 # Collect flow information for relevant protocol versions only
900e1b
                 for flow in flow_versions:
900e1b
                     if flow in br_protos:
900e1b
-- 
900e1b
2.31.1
900e1b
900e1b
900e1b
From 5a006024f730213a726c70e82c5ecd2daf685b2b Mon Sep 17 00:00:00 2001
900e1b
From: Salvatore Daniele <sdaniele@redhat.com>
900e1b
Date: Tue, 7 Sep 2021 14:17:19 -0400
900e1b
Subject: [PATCH 2/2] [openvswitch] add commands for offline analysis
900e1b
900e1b
Replicas of ovs-vswitchd and ovsdb-server can be recreated offline
900e1b
using flow, group, and tlv dumps, and ovs conf.db. This allows for
900e1b
offline anaylsis and the use of tools such as ovs-appctl
900e1b
ofproto/trace and ovs-ofctl for debugging.
900e1b
900e1b
This patch ensures this information is available in the sos report.
900e1b
The db is copied rather than collected using ovsdb-client list dump
900e1b
for two reasons:
900e1b
900e1b
ovsdb-client requires interacting with the ovsdb-server which could
900e1b
take it 'down' for some time, and impact large, busy clusters.
900e1b
900e1b
The list-dump is not in a format that can be used to restore the db
900e1b
offline. All of the information in the list dump is available and more
900e1b
by copying the db.
900e1b
900e1b
Signed-off-by: Salvatore Daniele <sdaniele@redhat.com>
900e1b
---
900e1b
 sos/report/plugins/openvswitch.py | 12 ++++++++++--
900e1b
 sos/report/plugins/ovn_central.py |  1 +
900e1b
 2 files changed, 11 insertions(+), 2 deletions(-)
900e1b
900e1b
diff --git a/sos/report/plugins/openvswitch.py b/sos/report/plugins/openvswitch.py
900e1b
index 92cc7259..003596c6 100644
900e1b
--- a/sos/report/plugins/openvswitch.py
900e1b
+++ b/sos/report/plugins/openvswitch.py
900e1b
@@ -75,12 +75,19 @@ class OpenVSwitch(Plugin):
900e1b
             "/run/openvswitch/ovs-monitor-ipsec.pid"
900e1b
         ])
900e1b
 
900e1b
+        self.add_copy_spec([
900e1b
+            path_join('/usr/local/etc/openvswitch', 'conf.db'),
900e1b
+            path_join('/etc/openvswitch', 'conf.db'),
900e1b
+            path_join('/var/lib/openvswitch', 'conf.db'),
900e1b
+        ])
900e1b
+        ovs_dbdir = environ.get('OVS_DBDIR')
900e1b
+        if ovs_dbdir:
900e1b
+            self.add_copy_spec(path_join(ovs_dbdir, 'conf.db'))
900e1b
+
900e1b
         self.add_cmd_output([
900e1b
             # The '-t 5' adds an upper bound on how long to wait to connect
900e1b
             # to the Open vSwitch server, avoiding hangs when running sos.
900e1b
             "ovs-vsctl -t 5 show",
900e1b
-            # Gather the database.
900e1b
-            "ovsdb-client -f list dump",
900e1b
             # List the contents of important runtime directories
900e1b
             "ls -laZ /run/openvswitch",
900e1b
             "ls -laZ /dev/hugepages/",
900e1b
@@ -276,6 +283,7 @@ class OpenVSwitch(Plugin):
900e1b
                             "ovs-ofctl -O %s dump-groups %s" % (flow, br),
900e1b
                             "ovs-ofctl -O %s dump-group-stats %s" % (flow, br),
900e1b
                             "ovs-ofctl -O %s dump-flows %s" % (flow, br),
900e1b
+                            "ovs-ofctl -O %s dump-tlv-map %s" % (flow, br),
900e1b
                             "ovs-ofctl -O %s dump-ports-desc %s" % (flow, br)
900e1b
                         ])
900e1b
 
900e1b
diff --git a/sos/report/plugins/ovn_central.py b/sos/report/plugins/ovn_central.py
900e1b
index a4c483a9..d6647aad 100644
900e1b
--- a/sos/report/plugins/ovn_central.py
900e1b
+++ b/sos/report/plugins/ovn_central.py
900e1b
@@ -138,6 +138,7 @@ class OVNCentral(Plugin):
900e1b
                 os.path.join('/usr/local/etc/openvswitch', dbfile),
900e1b
                 os.path.join('/etc/openvswitch', dbfile),
900e1b
                 os.path.join('/var/lib/openvswitch', dbfile),
900e1b
+                os.path.join('/var/lib/ovn/etc', dbfile),
900e1b
             ])
900e1b
             if ovs_dbdir:
900e1b
                 self.add_copy_spec(os.path.join(ovs_dbdir, dbfile))
900e1b
-- 
900e1b
2.31.1
900e1b