From 34dda98a5e788638a4468e1340fb790f03c9bdf6 Mon Sep 17 00:00:00 2001 From: Jake Hunsaker Date: Tue, 27 Aug 2024 21:22:38 -0400 Subject: [PATCH] [networking] Add devlink commands from #1541 This commit brings forward PR #1541, updated for the current design of sos plugins, and ultimately adds several devlink commands for collection. Additionally included is some lingering fixups to f-strings. Closes: #1541 Co-authored-by: Alexander Petrovskiy Co-authored-by: Jake Hunsaker Signed-off-by: Jake Hunsaker --- sos/report/plugins/networking.py | 55 ++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/sos/report/plugins/networking.py b/sos/report/plugins/networking.py index 848cf7562d..2ab4f5ae43 100644 --- a/sos/report/plugins/networking.py +++ b/sos/report/plugins/networking.py @@ -118,13 +118,35 @@ def setup(self): "devlink dev param show", "devlink dev info", "devlink port show", + "devlink sb show", + "devlink sb pool show", + "devlink sb port pool show", + "devlink sb tc bind show", + "devlink -s -v trap show", ]) devlinks = self.collect_cmd_output("devlink dev") if devlinks['status'] == 0: devlinks_list = devlinks['output'].splitlines() for devlink in devlinks_list: - self.add_cmd_output(f"devlink dev eswitch show {devlink}") + self.add_cmd_output([ + f"devlink dev eswitch show {devlink}", + f"devlink sb occupancy snapshot {devlink}", + f"devlink sb occupancy show {devlink}", + f"devlink -v resource show {devlink}" + ]) + dev_tables = [] + dpipe = self.collect_cmd_output( + f"devlink dpipe table show {devlink}" + ) + if dpipe['status'] == 0: + for tableln in dpipe['output'].splitlines(): + if tableln.startswith('name'): + dev_tables.append(tableln.split()[1]) + self.add_cmd_output([ + f"devlink dpipe table show {devlink} name {dname}" + for dname in dev_tables + ]) # below commands require some kernel module(s) to be loaded # run them only if the modules are loaded, or if explicitly requested @@ -227,17 +249,17 @@ def collect_ss_ip_ethtool_info(self): _subdir = f"namespaces/{namespace}" ns_cmd_prefix = cmd_prefix + namespace + " " self.add_cmd_output([ - ns_cmd_prefix + "ip -d address show", - ns_cmd_prefix + "ip route show table all", - ns_cmd_prefix + "ip -s -s neigh show", - ns_cmd_prefix + "ip -4 rule list", - ns_cmd_prefix + "ip -6 rule list", - ns_cmd_prefix + "ip vrf show", - ns_cmd_prefix + "sysctl -a", - ns_cmd_prefix + f"netstat {self.ns_wide} -neopa", - ns_cmd_prefix + "netstat -s", - ns_cmd_prefix + f"netstat {self.ns_wide} -agn", - ns_cmd_prefix + "nstat -zas", + f"{ns_cmd_prefix} ip -d address show", + f"{ns_cmd_prefix} ip route show table all", + f"{ns_cmd_prefix} ip -s -s neigh show", + f"{ns_cmd_prefix} ip -4 rule list", + f"{ns_cmd_prefix} ip -6 rule list", + f"{ns_cmd_prefix} ip vrf show", + f"{ns_cmd_prefix} sysctl -a", + f"{ns_cmd_prefix} netstat {self.ns_wide} -neopa", + f"{ns_cmd_prefix} netstat -s", + f"{ns_cmd_prefix} netstat {self.ns_wide} -agn", + f"{ns_cmd_prefix} nstat -zas", ], priority=50, subdir=_subdir) self.add_cmd_output([ns_cmd_prefix + "iptables-save"], pred=iptables_with_nft, @@ -260,10 +282,11 @@ def collect_ss_ip_ethtool_info(self): # Devices that exist in a namespace use less ethtool # parameters. Run this per namespace. self.add_device_cmd([ - ns_cmd_prefix + "ethtool %(dev)s", - ns_cmd_prefix + "ethtool -i %(dev)s", - ns_cmd_prefix + "ethtool -k %(dev)s", - ns_cmd_prefix + "ethtool -S %(dev)s" + f"{ns_cmd_prefix} ethtool %(dev)s", + f"{ns_cmd_prefix} ethtool -i %(dev)s", + f"{ns_cmd_prefix} ethtool -k %(dev)s", + f"{ns_cmd_prefix} ethtool -S %(dev)s", + f"{ns_cmd_prefix} ethtool -m %(dev)s" ], devices=_devs['ethernet'], priority=50, subdir=_subdir) self.add_command_tags()