From: Nikolay Aleksandrov <razor@blackwall.org>
To: netdev@vger.kernel.org
Cc: roopa@cumulusnetworks.com, stephen@networkplumber.org,
Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Subject: [PATCH iproute2 1/5] iplink: bridge_slave: export read-only values
Date: Tue, 16 Feb 2016 16:08:51 +0100 [thread overview]
Message-ID: <1455635335-9973-2-git-send-email-razor@blackwall.org> (raw)
In-Reply-To: <1455635335-9973-1-git-send-email-razor@blackwall.org>
From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Export all the read-only values that get returned about a bridge port
such as the timers, the ids, designated_port and cost,
topology_change_ack and config_pending. For the bridge ids the
br_dump_bridge_id function is exported from iplink_bridge.
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
ip/ip_common.h | 2 ++
ip/iplink_bridge.c | 3 +--
ip/iplink_bridge_slave.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/ip/ip_common.h b/ip/ip_common.h
index 9a846df348fe..815487a07b8a 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -87,6 +87,8 @@ struct link_util
struct link_util *get_link_kind(const char *kind);
struct link_util *get_link_slave_kind(const char *slave_kind);
+void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf, size_t len);
+
#ifndef INFINITY_LIFE_TIME
#define INFINITY_LIFE_TIME 0xFFFFFFFFU
#endif
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
index 1b666f0adef4..79f15eff7c39 100644
--- a/ip/iplink_bridge.c
+++ b/ip/iplink_bridge.c
@@ -60,8 +60,7 @@ static void explain(void)
print_explain(stderr);
}
-static void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf,
- size_t len)
+void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf, size_t len)
{
char eaddr[32];
diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c
index 4593872ecd84..c58f55294261 100644
--- a/ip/iplink_bridge_slave.c
+++ b/ip/iplink_bridge_slave.c
@@ -98,6 +98,76 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
if (tb[IFLA_BRPORT_UNICAST_FLOOD])
print_onoff(f, "flood",
rta_getattr_u8(tb[IFLA_BRPORT_UNICAST_FLOOD]));
+
+ if (tb[IFLA_BRPORT_ID])
+ fprintf(f, "port_id 0x%x ",
+ rta_getattr_u16(tb[IFLA_BRPORT_ID]));
+
+ if (tb[IFLA_BRPORT_NO])
+ fprintf(f, "port_no 0x%x ",
+ rta_getattr_u16(tb[IFLA_BRPORT_NO]));
+
+ if (tb[IFLA_BRPORT_DESIGNATED_PORT])
+ fprintf(f, "designated_port %u ",
+ rta_getattr_u16(tb[IFLA_BRPORT_DESIGNATED_PORT]));
+
+ if (tb[IFLA_BRPORT_DESIGNATED_COST])
+ fprintf(f, "designated_cost %u ",
+ rta_getattr_u16(tb[IFLA_BRPORT_DESIGNATED_COST]));
+
+ if (tb[IFLA_BRPORT_BRIDGE_ID]) {
+ char bridge_id[32];
+
+ br_dump_bridge_id(RTA_DATA(tb[IFLA_BRPORT_BRIDGE_ID]),
+ bridge_id, sizeof(bridge_id));
+ fprintf(f, "designated_bridge %s ", bridge_id);
+ }
+
+ if (tb[IFLA_BRPORT_ROOT_ID]) {
+ char root_id[32];
+
+ br_dump_bridge_id(RTA_DATA(tb[IFLA_BRPORT_ROOT_ID]),
+ root_id, sizeof(root_id));
+ fprintf(f, "designated_root %s ", root_id);
+ }
+
+ if (tb[IFLA_BRPORT_HOLD_TIMER]) {
+ struct timeval tv;
+ __u64 htimer;
+
+ htimer = rta_getattr_u64(tb[IFLA_BRPORT_HOLD_TIMER]);
+ __jiffies_to_tv(&tv, htimer);
+ fprintf(f, "hold_timer %4i.%.2i ", (int)tv.tv_sec,
+ (int)tv.tv_usec/10000);
+ }
+
+ if (tb[IFLA_BRPORT_MESSAGE_AGE_TIMER]) {
+ struct timeval tv;
+ __u64 agetimer;
+
+ agetimer = rta_getattr_u64(tb[IFLA_BRPORT_MESSAGE_AGE_TIMER]);
+ __jiffies_to_tv(&tv, agetimer);
+ fprintf(f, "message_age_timer %4i.%.2i ", (int)tv.tv_sec,
+ (int)tv.tv_usec/10000);
+ }
+
+ if (tb[IFLA_BRPORT_FORWARD_DELAY_TIMER]) {
+ struct timeval tv;
+ __u64 fwdtimer;
+
+ fwdtimer = rta_getattr_u64(tb[IFLA_BRPORT_FORWARD_DELAY_TIMER]);
+ __jiffies_to_tv(&tv, fwdtimer);
+ fprintf(f, "forward_delay_timer %4i.%.2i ", (int)tv.tv_sec,
+ (int)tv.tv_usec/10000);
+ }
+
+ if (tb[IFLA_BRPORT_TOPOLOGY_CHANGE_ACK])
+ fprintf(f, "topology_change_ack %u ",
+ rta_getattr_u8(tb[IFLA_BRPORT_TOPOLOGY_CHANGE_ACK]));
+
+ if (tb[IFLA_BRPORT_CONFIG_PENDING])
+ fprintf(f, "config_pending %u ",
+ rta_getattr_u8(tb[IFLA_BRPORT_CONFIG_PENDING]));
}
static void bridge_slave_parse_on_off(char *arg_name, char *arg_val,
--
2.4.3
next prev parent reply other threads:[~2016-02-16 15:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 15:08 [PATCH iproute2 0/5] bridge: complete port netlink support Nikolay Aleksandrov
2016-02-16 15:08 ` Nikolay Aleksandrov [this message]
2016-02-18 1:52 ` [PATCH iproute2 1/5] iplink: bridge_slave: export read-only values Stephen Hemminger
2016-02-16 15:08 ` [PATCH iproute2 2/5] iplink: bridge_slave: add support for IFLA_BRPORT_PROXYARP Nikolay Aleksandrov
2016-02-16 15:08 ` [PATCH iproute2 3/5] iplink: bridge_slave: add support for IFLA_BRPORT_PROXYARP_WIFI Nikolay Aleksandrov
2016-02-16 15:08 ` [PATCH iproute2 4/5] iplink: bridge_slave: add support for IFLA_BRPORT_MULTICAST_ROUTER Nikolay Aleksandrov
2016-02-16 15:08 ` [PATCH iproute2 5/5] iplink: bridge_slave: add support for IFLA_BRPORT_FAST_LEAVE Nikolay Aleksandrov
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=1455635335-9973-2-git-send-email-razor@blackwall.org \
--to=razor@blackwall.org \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=roopa@cumulusnetworks.com \
--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).