netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: [PATCH iproute2 net-next-for-3.13 1/2] iplink: display slave information
Date: Mon, 10 Feb 2014 09:11:46 +0100 (CET)	[thread overview]
Message-ID: <20140210081146.6F4FEE5697@unicorn.suse.cz> (raw)

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@suse.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

             reply	other threads:[~2014-02-10  8:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-10  8:11 Michal Kubecek [this message]
2014-02-10 13:34 ` [PATCH iproute2 net-next-for-3.13 1/2] iplink: display slave information Sergei Shtylyov
2014-02-10 17:09 ` Stephen Hemminger
2014-02-10 18:24   ` Michal Kubecek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140210081146.6F4FEE5697@unicorn.suse.cz \
    --to=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).