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

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