|
|
4aca6e |
From 58d4d6459347811ef8d75826221f94b3f56b824a Mon Sep 17 00:00:00 2001
|
|
|
4aca6e |
From: Phil Sutter <psutter@redhat.com>
|
|
|
4aca6e |
Date: Tue, 28 Feb 2017 16:12:00 +0100
|
|
|
4aca6e |
Subject: [PATCH] iplink: bridge: export read-only timers
|
|
|
4aca6e |
|
|
|
4aca6e |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
|
|
|
4aca6e |
Upstream Status: iproute2.git commit 8c0f7a16305f8
|
|
|
4aca6e |
|
|
|
4aca6e |
commit 8c0f7a16305f86baaefe16050139a03b1f3b24ee
|
|
|
4aca6e |
Author: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
|
|
|
4aca6e |
Date: Tue Feb 9 00:14:21 2016 +0100
|
|
|
4aca6e |
|
|
|
4aca6e |
iplink: bridge: export read-only timers
|
|
|
4aca6e |
|
|
|
4aca6e |
Netlink already provides hello_timer, tcn_timer, topology_change_timer
|
|
|
4aca6e |
and gc_timer, so let's make them visible.
|
|
|
4aca6e |
|
|
|
4aca6e |
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
|
|
|
4aca6e |
---
|
|
|
4aca6e |
include/utils.h | 18 ++++++++++++++++++
|
|
|
4aca6e |
ip/iplink_bridge.c | 34 ++++++++++++++++++++++++++++++++++
|
|
|
4aca6e |
2 files changed, 52 insertions(+)
|
|
|
4aca6e |
|
|
|
4aca6e |
diff --git a/include/utils.h b/include/utils.h
|
|
|
4aca6e |
index 22198cb..9839d9d 100644
|
|
|
4aca6e |
--- a/include/utils.h
|
|
|
4aca6e |
+++ b/include/utils.h
|
|
|
4aca6e |
@@ -159,6 +159,24 @@ static inline __u32 nl_mgrp(__u32 group)
|
|
|
4aca6e |
return group ? (1 << (group - 1)) : 0;
|
|
|
4aca6e |
}
|
|
|
4aca6e |
|
|
|
4aca6e |
+/* courtesy of bridge-utils */
|
|
|
4aca6e |
+static inline unsigned long __tv_to_jiffies(const struct timeval *tv)
|
|
|
4aca6e |
+{
|
|
|
4aca6e |
+ unsigned long long jif;
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+ jif = 1000000ULL * tv->tv_sec + tv->tv_usec;
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+ return jif/10000;
|
|
|
4aca6e |
+}
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+static inline void __jiffies_to_tv(struct timeval *tv, unsigned long jiffies)
|
|
|
4aca6e |
+{
|
|
|
4aca6e |
+ unsigned long long tvusec;
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+ tvusec = 10000ULL*jiffies;
|
|
|
4aca6e |
+ tv->tv_sec = tvusec/1000000;
|
|
|
4aca6e |
+ tv->tv_usec = tvusec - 1000000 * tv->tv_sec;
|
|
|
4aca6e |
+}
|
|
|
4aca6e |
|
|
|
4aca6e |
int print_timestamp(FILE *fp);
|
|
|
4aca6e |
|
|
|
4aca6e |
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
|
|
|
4aca6e |
index bf6cb71..2bd3182 100644
|
|
|
4aca6e |
--- a/ip/iplink_bridge.c
|
|
|
4aca6e |
+++ b/ip/iplink_bridge.c
|
|
|
4aca6e |
@@ -203,6 +203,40 @@ static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
|
|
4aca6e |
if (tb[IFLA_BR_TOPOLOGY_CHANGE_DETECTED])
|
|
|
4aca6e |
fprintf(f, "topology_change_detected %u ",
|
|
|
4aca6e |
rta_getattr_u8(tb[IFLA_BR_TOPOLOGY_CHANGE_DETECTED]));
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+ if (tb[IFLA_BR_HELLO_TIMER]) {
|
|
|
4aca6e |
+ struct timeval tv;
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+ __jiffies_to_tv(&tv, rta_getattr_u64(tb[IFLA_BR_HELLO_TIMER]));
|
|
|
4aca6e |
+ fprintf(f, "hello_timer %4i.%.2i ", (int)tv.tv_sec,
|
|
|
4aca6e |
+ (int)tv.tv_usec/10000);
|
|
|
4aca6e |
+ }
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+ if (tb[IFLA_BR_TCN_TIMER]) {
|
|
|
4aca6e |
+ struct timeval tv;
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+ __jiffies_to_tv(&tv, rta_getattr_u64(tb[IFLA_BR_TCN_TIMER]));
|
|
|
4aca6e |
+ fprintf(f, "tcn_timer %4i.%.2i ", (int)tv.tv_sec,
|
|
|
4aca6e |
+ (int)tv.tv_usec/10000);
|
|
|
4aca6e |
+ }
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+ if (tb[IFLA_BR_TOPOLOGY_CHANGE_TIMER]) {
|
|
|
4aca6e |
+ unsigned long jiffies;
|
|
|
4aca6e |
+ struct timeval tv;
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+ jiffies = rta_getattr_u64(tb[IFLA_BR_TOPOLOGY_CHANGE_TIMER]);
|
|
|
4aca6e |
+ __jiffies_to_tv(&tv, jiffies);
|
|
|
4aca6e |
+ fprintf(f, "topology_change_timer %4i.%.2i ", (int)tv.tv_sec,
|
|
|
4aca6e |
+ (int)tv.tv_usec/10000);
|
|
|
4aca6e |
+ }
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+ if (tb[IFLA_BR_GC_TIMER]) {
|
|
|
4aca6e |
+ struct timeval tv;
|
|
|
4aca6e |
+
|
|
|
4aca6e |
+ __jiffies_to_tv(&tv, rta_getattr_u64(tb[IFLA_BR_GC_TIMER]));
|
|
|
4aca6e |
+ fprintf(f, "gc_timer %4i.%.2i ", (int)tv.tv_sec,
|
|
|
4aca6e |
+ (int)tv.tv_usec/10000);
|
|
|
4aca6e |
+ }
|
|
|
4aca6e |
}
|
|
|
4aca6e |
|
|
|
4aca6e |
static void bridge_print_help(struct link_util *lu, int argc, char **argv,
|
|
|
4aca6e |
--
|
|
|
4aca6e |
1.8.3.1
|
|
|
4aca6e |
|