lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  9 Aug 2022 15:17:30 +0200
From:   Jiri Pirko <jiri@...nulli.us>
To:     netdev@...r.kernel.org
Cc:     sthemmin@...rosoft.com, dsahern@...il.com, mlxsw@...dia.com,
        idosch@...dia.com
Subject: [patch iproute2-next] devlink: expose nested devlink for a line card object

From: Jiri Pirko <jiri@...dia.com>

If line card object contains a nested devlink, expose it.

Example:

$ devlink lc show pci/0000:01:00.0 lc 1
pci/0000:01:00.0:
  lc 1 state active type 16x100G nested_devlink auxiliary/mlxsw_core.lc.0
    supported_types:
      16x100G
$ devlink dev show auxiliary/mlxsw_core.lc.0
auxiliary/mlxsw_core.lc.0

Signed-off-by: Jiri Pirko <jiri@...dia.com>
---
 devlink/devlink.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 21f26246f91b..1ccb669c423b 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -703,6 +703,7 @@ static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = {
 	[DEVLINK_ATTR_LINECARD_STATE] = MNL_TYPE_U8,
 	[DEVLINK_ATTR_LINECARD_TYPE] = MNL_TYPE_STRING,
 	[DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES] = MNL_TYPE_NESTED,
+	[DEVLINK_ATTR_NESTED_DEVLINK] = MNL_TYPE_NESTED,
 	[DEVLINK_ATTR_SELFTESTS] = MNL_TYPE_NESTED,
 };
 
@@ -2423,6 +2424,25 @@ static bool should_arr_last_handle_end(struct dl *dl, const char *bus_name,
 	       !cmp_arr_last_handle(dl, bus_name, dev_name);
 }
 
+static void pr_out_nested_handle(struct nlattr *nla_nested_dl)
+{
+	struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
+	char buf[64];
+	int err;
+
+	err = mnl_attr_parse_nested(nla_nested_dl, attr_cb, tb);
+	if (err != MNL_CB_OK)
+		return;
+
+	if (!tb[DEVLINK_ATTR_BUS_NAME] ||
+	    !tb[DEVLINK_ATTR_DEV_NAME])
+		return;
+
+	sprintf(buf, "%s/%s", mnl_attr_get_str(tb[DEVLINK_ATTR_BUS_NAME]),
+		mnl_attr_get_str(tb[DEVLINK_ATTR_DEV_NAME]));
+	print_string(PRINT_ANY, "nested_devlink", " nested_devlink %s", buf);
+}
+
 static void __pr_out_handle_start(struct dl *dl, struct nlattr **tb,
 				  bool content, bool array)
 {
@@ -5278,6 +5298,9 @@ static void pr_out_linecard(struct dl *dl, struct nlattr **tb)
 	if (tb[DEVLINK_ATTR_LINECARD_TYPE])
 		print_string(PRINT_ANY, "type", " type %s",
 			     mnl_attr_get_str(tb[DEVLINK_ATTR_LINECARD_TYPE]));
+	if (tb[DEVLINK_ATTR_NESTED_DEVLINK])
+		pr_out_nested_handle(tb[DEVLINK_ATTR_NESTED_DEVLINK]);
+
 	pr_out_linecard_supported_types(dl, tb);
 	pr_out_handle_end(dl);
 }
-- 
2.35.3

Powered by blists - more mailing lists