summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flowtop.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/flowtop.c b/flowtop.c
index 083d16b..a6f8fc1 100644
--- a/flowtop.c
+++ b/flowtop.c
@@ -806,6 +806,20 @@ static uint16_t presenter_get_port(uint16_t src, uint16_t dst, int tcp)
}
}
+static char *bandw2str(double bytes, char *buf, size_t len)
+{
+ if (bytes > 1000000000.)
+ snprintf(buf, len, "%.1fG", bytes / 1000000000.);
+ if (bytes > 1000000.)
+ snprintf(buf, len, "%.1fM", bytes / 1000000.);
+ else if (bytes > 1000.)
+ snprintf(buf, len, "%.1fK", bytes / 1000.);
+ else
+ snprintf(buf, len, "%g", bytes);
+
+ return buf;
+}
+
static void presenter_screen_do_line(WINDOW *screen, struct flow_entry *n,
unsigned int *line)
{
@@ -870,9 +884,13 @@ static void presenter_screen_do_line(WINDOW *screen, struct flow_entry *n,
printw(" ->");
/* Number packets, bytes */
- if (n->counter_pkts > 0 && n->counter_bytes > 0)
- printw(" (%"PRIu64" pkts, %"PRIu64" bytes) ->",
- n->counter_pkts, n->counter_bytes);
+ if (n->counter_pkts > 0 && n->counter_bytes > 0) {
+ char bytes_str[64];
+
+ printw(" (%"PRIu64" pkts, %s bytes) ->", n->counter_pkts,
+ bandw2str(n->counter_bytes, bytes_str,
+ sizeof(bytes_str) - 1));
+ }
/* Show source information: reverse DNS, port, country, city */
if (show_src) {
t calls the ExitBootServices() UEFI service (which is arguably a better place for it anyway) Note that disabling the MMU in ExitBootServices() is not compliant with the UEFI spec, and carries great risk due to the fact that switching from cached to uncached memory accesses halfway through compiler generated code (i.e., involving a stack) can never be done in a way that is architecturally safe. Fixes: abfb7b686a3e ("efi/libstub/arm*: Pass latest memory map to the kernel") Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Riku Voipio <riku.voipio@linaro.org> Cc: <stable@vger.kernel.org> Cc: mark.rutland@arm.com Cc: linux-efi@vger.kernel.org Cc: matt@codeblueprint.co.uk Cc: leif.lindholm@linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1485971102-23330-2-git-send-email-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/net/fib_rules.h')