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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 10 Feb 2014 09:11:46 +0100 (CET)
From:	Michal Kubecek <mkubecek@...e.cz>
To:	Stephen Hemminger <stephen@...workplumber.org>
Cc:	netdev@...r.kernel.org
Subject: [PATCH iproute2 net-next-for-3.13 1/2] iplink: display slave
 information

Add print_slave_opt() callback and maxslattr value to struct
link_util. These are analogous to print_opt() and maxattr but
relate to slave info (IFLA_INFO_SLAVE_{KIND,DATA}).

Display the slave specific info in output of "ip -d link show".

Signed-off-by: Michal Kubecek <mkubecek@...e.cz>
---
 ip/ip_common.h |  3 +++
 ip/ipaddress.c | 27 +++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/ip/ip_common.h b/ip/ip_common.h
index f9b4734..b1703a7 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -66,12 +66,15 @@ struct link_util
 	struct link_util	*next;
 	const char		*id;
 	int			maxattr;
+	int			maxslattr;
 	int			(*parse_opt)(struct link_util *, int, char **,
 					     struct nlmsghdr *);
 	void			(*print_opt)(struct link_util *, FILE *,
 					     struct rtattr *[]);
 	void			(*print_xstats)(struct link_util *, FILE *,
 					     struct rtattr *);
+	void			(*print_slave_opt)(struct link_util *, FILE *,
+					     struct rtattr *[]);
 };
 
 struct link_util *get_link_kind(const char *kind);
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index f794fa1..3cb7ee7 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -197,7 +197,7 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
 	parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb);
 
 	if (!linkinfo[IFLA_INFO_KIND])
-		return;
+		goto no_info;
 	kind = RTA_DATA(linkinfo[IFLA_INFO_KIND]);
 
 	fprintf(fp, "%s", _SL_);
@@ -205,7 +205,7 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
 
 	lu = get_link_kind(kind);
 	if (!lu || !lu->print_opt)
-		return;
+		goto no_info;
 
 	if (1) {
 		struct rtattr *attr[lu->maxattr+1], **data = NULL;
@@ -221,6 +221,29 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
 		    lu->print_xstats)
 			lu->print_xstats(lu, fp, linkinfo[IFLA_INFO_XSTATS]);
 	}
+
+no_info:
+	if (!linkinfo[IFLA_INFO_SLAVE_KIND])
+		return;
+	kind = RTA_DATA(linkinfo[IFLA_INFO_SLAVE_KIND]);
+
+	fprintf(fp, "%s", _SL_);
+	fprintf(fp, "    %s_slave ", kind);
+
+	lu = get_link_kind(kind);
+	if (!lu || !lu->print_slave_opt)
+		return;
+
+	if (1) {
+		struct rtattr *attr[lu->maxslattr+1], **data = NULL;
+
+		if (linkinfo[IFLA_INFO_SLAVE_DATA]) {
+			parse_rtattr_nested(attr, lu->maxslattr,
+					    linkinfo[IFLA_INFO_SLAVE_DATA]);
+			data = attr;
+		}
+		lu->print_slave_opt(lu, fp, data);
+	}
 }
 
 static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ