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 2/2] iplink_bond: add support for displaying bond slave attributes
Date: Mon, 10 Feb 2014 09:11:56 +0100 (CET) [thread overview]
Message-ID: <20140210081156.787D5E5697@unicorn.suse.cz> (raw)
A rtnetlink API providing read-only access to bond slave
attributes is available in 3.14-rc1 kernel. Display this info in
"ip -d link show" output.
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
ip/iplink_bond.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 57 insertions(+), 4 deletions(-)
diff --git a/ip/iplink_bond.c b/ip/iplink_bond.c
index f0e5ab1..321a941 100644
--- a/ip/iplink_bond.c
+++ b/ip/iplink_bond.c
@@ -84,6 +84,20 @@ static const char *ad_select_tbl[] = {
NULL,
};
+static const char *slave_state_tbl[] = {
+ "active",
+ "backup",
+ NULL
+};
+
+static const char *slave_mii_status_tbl[] = {
+ "up",
+ "going_down",
+ "down",
+ "going_back",
+ NULL,
+};
+
static const char *get_name(const char **tbl, int index)
{
int i;
@@ -528,9 +542,48 @@ static void bond_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
}
}
+static void bond_print_slave_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
+{
+ SPRINT_BUF(buff);
+ if (!tb)
+ return;
+
+ if (tb[IFLA_BOND_SLAVE_STATE]) {
+ const char *state = get_name(slave_state_tbl,
+ rta_getattr_u8(tb[IFLA_BOND_SLAVE_STATE]));
+ fprintf(f, "state %s ", state);
+ }
+
+ if (tb[IFLA_BOND_SLAVE_MII_STATUS]) {
+ const char *mii_status = get_name(slave_mii_status_tbl,
+ rta_getattr_u8(tb[IFLA_BOND_SLAVE_MII_STATUS]));
+ fprintf(f, "mii_status %s ", mii_status);
+ }
+
+ if (tb[IFLA_BOND_SLAVE_LINK_FAILURE_COUNT])
+ fprintf(f, "failure_count %u ",
+ rta_getattr_u32(tb[IFLA_BOND_SLAVE_LINK_FAILURE_COUNT]));
+
+ if (tb[IFLA_BOND_SLAVE_PERM_HWADDR])
+ fprintf(f, "perm_hwaddr %s ",
+ ll_addr_n2a(RTA_DATA(tb[IFLA_BOND_SLAVE_PERM_HWADDR]),
+ RTA_PAYLOAD(tb[IFLA_BOND_SLAVE_PERM_HWADDR]),
+ 0, buff, sizeof(buff)));
+
+ if (tb[IFLA_BOND_SLAVE_QUEUE_ID])
+ fprintf(f, "queue_id %u ",
+ rta_getattr_u16(tb[IFLA_BOND_SLAVE_QUEUE_ID]));
+
+ if (tb[IFLA_BOND_SLAVE_AD_AGGREGATOR_ID])
+ fprintf(f, "ad_aggregator_id %u ",
+ rta_getattr_u16(tb[IFLA_BOND_SLAVE_AD_AGGREGATOR_ID]));
+}
+
struct link_util bond_link_util = {
- .id = "bond",
- .maxattr = IFLA_BOND_MAX,
- .parse_opt = bond_parse_opt,
- .print_opt = bond_print_opt,
+ .id = "bond",
+ .maxattr = IFLA_BOND_MAX,
+ .maxslattr = IFLA_BOND_SLAVE_MAX,
+ .parse_opt = bond_parse_opt,
+ .print_opt = bond_print_opt,
+ .print_slave_opt = bond_print_slave_opt,
};
--
1.8.1.4
next reply other threads:[~2014-02-10 8:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-10 8:11 Michal Kubecek [this message]
2014-02-10 20:53 ` [PATCH iproute2 net-next-for-3.13 2/2] iplink_bond: add support for displaying bond slave attributes Stephen Hemminger
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=20140210081156.787D5E5697@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