naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0192-devlink-introduce-dump-filtering-function.patch

049c96
From 548573fb441d1b7752cb54065841c3d30aff8cc2 Mon Sep 17 00:00:00 2001
049c96
From: Phil Sutter <psutter@redhat.com>
049c96
Date: Sat, 9 Jul 2016 11:33:14 +0200
049c96
Subject: [PATCH] devlink: introduce dump filtering function
049c96
049c96
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1342515
049c96
Upstream Status: iproute2.git commit 707a91c549496
049c96
049c96
commit 707a91c5494962e3f5b358fc866ebb79dc28c3e3
049c96
Author: Jiri Pirko <jiri@mellanox.com>
049c96
Date:   Fri Apr 15 09:51:49 2016 +0200
049c96
049c96
    devlink: introduce dump filtering function
049c96
049c96
    This function is to be used from dump callbacks to decide if the output
049c96
    currect output should be filtered off or not. Filtering is based on
049c96
    previously parsed and stored command line options.
049c96
049c96
    Signed-off-by: Jiri Pirko <jiri@mellanox.com>
049c96
---
049c96
 devlink/devlink.c | 30 ++++++++++++++++++++++++++++++
049c96
 1 file changed, 30 insertions(+)
049c96
049c96
diff --git a/devlink/devlink.c b/devlink/devlink.c
049c96
index 0c2132f..d436bbf 100644
049c96
--- a/devlink/devlink.c
049c96
+++ b/devlink/devlink.c
049c96
@@ -563,6 +563,36 @@ static int dl_argv_parse_put(struct nlmsghdr *nlh, struct dl *dl,
049c96
 	return 0;
049c96
 }
049c96
 
049c96
+static bool dl_dump_filter(struct dl *dl, struct nlattr **tb)
049c96
+{
049c96
+	struct dl_opts *opts = &dl->opts;
049c96
+	struct nlattr *attr_bus_name = tb[DEVLINK_ATTR_BUS_NAME];
049c96
+	struct nlattr *attr_dev_name = tb[DEVLINK_ATTR_DEV_NAME];
049c96
+	struct nlattr *attr_port_index = tb[DEVLINK_ATTR_PORT_INDEX];
049c96
+
049c96
+	if (opts->present & DL_OPT_HANDLE &&
049c96
+	    attr_bus_name && attr_dev_name) {
049c96
+		const char *bus_name = mnl_attr_get_str(attr_bus_name);
049c96
+		const char *dev_name = mnl_attr_get_str(attr_dev_name);
049c96
+
049c96
+		if (strcmp(bus_name, opts->bus_name) != 0 ||
049c96
+		    strcmp(dev_name, opts->dev_name) != 0)
049c96
+			return false;
049c96
+	}
049c96
+	if (opts->present & DL_OPT_HANDLEP &&
049c96
+	    attr_bus_name && attr_dev_name && attr_port_index) {
049c96
+		const char *bus_name = mnl_attr_get_str(attr_bus_name);
049c96
+		const char *dev_name = mnl_attr_get_str(attr_dev_name);
049c96
+		uint32_t port_index = mnl_attr_get_u32(attr_port_index);
049c96
+
049c96
+		if (strcmp(bus_name, opts->bus_name) != 0 ||
049c96
+		    strcmp(dev_name, opts->dev_name) != 0 ||
049c96
+		    port_index != opts->port_index)
049c96
+			return false;
049c96
+	}
049c96
+	return true;
049c96
+}
049c96
+
049c96
 static void cmd_dev_help(void)
049c96
 {
049c96
 	pr_out("Usage: devlink dev show [ DEV ]\n");
049c96
-- 
049c96
1.8.3.1
049c96