summaryrefslogtreecommitdiff
path: root/sbin/unwind
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2019-12-02 06:26:53 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2019-12-02 06:26:53 +0000
commit13a1905802d3a7711a54f8379593a8f292b13742 (patch)
treefc3e899c9e7f85c961b72efb52b2315744b960a9 /sbin/unwind
parent50de43aba5d4474723b4571b57f533310777b15a (diff)
Add an "all" mode for status and a much more compact and readable histogram
display; remove the why bogus status message; ok florian@
Diffstat (limited to 'sbin/unwind')
-rw-r--r--sbin/unwind/frontend.c5
-rw-r--r--sbin/unwind/resolver.c42
-rw-r--r--sbin/unwind/resolver.h4
-rw-r--r--sbin/unwind/unwind.h13
4 files changed, 26 insertions, 38 deletions
diff --git a/sbin/unwind/frontend.c b/sbin/unwind/frontend.c
index 9799c2defba..5758341d959 100644
--- a/sbin/unwind/frontend.c
+++ b/sbin/unwind/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.42 2019/12/01 14:37:34 otto Exp $ */
+/* $OpenBSD: frontend.c,v 1.43 2019/12/02 06:26:52 otto Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -486,9 +486,6 @@ frontend_dispatch_resolver(int fd, short event, void *bula)
send_answer(pq);
break;
case IMSG_CTL_RESOLVER_INFO:
- case IMSG_CTL_RESOLVER_WHY_BOGUS:
- case IMSG_CTL_RESOLVER_HISTOGRAM:
- case IMSG_CTL_RESOLVER_DECAYING_HISTOGRAM:
case IMSG_CTL_AUTOCONF_RESOLVER_INFO:
case IMSG_CTL_END:
control_imsg_relay(&imsg);
diff --git a/sbin/unwind/resolver.c b/sbin/unwind/resolver.c
index 91437d9d1a0..ea5e5939ede 100644
--- a/sbin/unwind/resolver.c
+++ b/sbin/unwind/resolver.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolver.c,v 1.87 2019/12/01 14:37:34 otto Exp $ */
+/* $OpenBSD: resolver.c,v 1.88 2019/12/02 06:26:52 otto Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -1703,7 +1703,6 @@ show_status(enum uw_resolver_type type, pid_t pid)
case UW_RES_DOT:
case UW_RES_ASR:
send_resolver_info(resolvers[type], pid);
- send_detailed_resolver_info(resolvers[type], pid);
break;
default:
fatalx("unknown resolver type %d", type);
@@ -1716,6 +1715,7 @@ void
send_resolver_info(struct uw_resolver *res, pid_t pid)
{
struct ctl_resolver_info cri;
+ size_t i;
if (res == NULL)
return;
@@ -1724,35 +1724,16 @@ send_resolver_info(struct uw_resolver *res, pid_t pid)
cri.type = res->type;
cri.oppdot = res->oppdot;
cri.median = histogram_median(res->latest_histogram);
- resolver_imsg_compose_frontend(IMSG_CTL_RESOLVER_INFO, pid, &cri,
- sizeof(cri));
-}
-
-void
-send_detailed_resolver_info(struct uw_resolver *res, pid_t pid)
-{
- int64_t histogram[nitems(histogram_limits)];
- size_t i;
- char buf[1024];
-
- if (res == NULL)
- return;
-
- if (res->state == RESOLVING) {
- (void)strlcpy(buf, res->why_bogus, sizeof(buf));
- resolver_imsg_compose_frontend(IMSG_CTL_RESOLVER_WHY_BOGUS,
- pid, buf, sizeof(buf));
- }
- memcpy(histogram, res->histogram, sizeof(histogram));
- resolver_imsg_compose_frontend(IMSG_CTL_RESOLVER_HISTOGRAM,
- pid, histogram, sizeof(histogram));
-
- memcpy(histogram, res->latest_histogram, sizeof(histogram));
+ memcpy(cri.histogram, res->histogram, sizeof(cri.histogram));
+ memcpy(cri.latest_histogram, res->latest_histogram,
+ sizeof(cri.latest_histogram));
for (i = 0; i < nitems(histogram_limits); i++)
- histogram[i] /= 1000;
- resolver_imsg_compose_frontend(IMSG_CTL_RESOLVER_DECAYING_HISTOGRAM,
- pid, histogram, sizeof(histogram));
+ cri.latest_histogram[i] =
+ (cri.latest_histogram[i] + 500) / 1000;
+
+ resolver_imsg_compose_frontend(IMSG_CTL_RESOLVER_INFO, pid, &cri,
+ sizeof(cri));
}
void
@@ -2026,6 +2007,9 @@ histogram_median(int64_t *histogram)
for (i = 1; i < nitems(histogram_limits); i++)
sample_count += histogram[i];
+ if (sample_count == 0)
+ return 0;
+
for (i = 1; i < nitems(histogram_limits); i++) {
running_count += histogram[i];
if (running_count >= sample_count / 2)
diff --git a/sbin/unwind/resolver.h b/sbin/unwind/resolver.h
index 27c712fe8ad..9478ae9395c 100644
--- a/sbin/unwind/resolver.h
+++ b/sbin/unwind/resolver.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolver.h,v 1.14 2019/11/28 10:40:29 florian Exp $ */
+/* $OpenBSD: resolver.h,v 1.15 2019/12/02 06:26:52 otto Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -51,6 +51,8 @@ struct ctl_resolver_info {
enum uw_resolver_type type;
int64_t median;
int oppdot;
+ int64_t histogram[nitems(histogram_limits)];
+ int64_t latest_histogram[nitems(histogram_limits)];
};
struct ctl_forwarder_info {
diff --git a/sbin/unwind/unwind.h b/sbin/unwind/unwind.h
index edda7b7a92b..ace4136b067 100644
--- a/sbin/unwind/unwind.h
+++ b/sbin/unwind/unwind.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: unwind.h,v 1.41 2019/12/01 14:37:34 otto Exp $ */
+/* $OpenBSD: unwind.h,v 1.42 2019/12/02 06:26:52 otto Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -72,6 +72,14 @@ static const char * const uw_resolver_type_str[] = {
"DoT"
};
+static const char * const uw_resolver_type_short[] = {
+ "rec",
+ "dhcp",
+ "stub",
+ "forw",
+ "DoT"
+};
+
struct imsgev {
struct imsgbuf ibuf;
void (*handler)(int, short, void *);
@@ -102,9 +110,6 @@ enum imsg_type {
IMSG_ANSWER_HEADER,
IMSG_ANSWER,
IMSG_CTL_RESOLVER_INFO,
- IMSG_CTL_RESOLVER_WHY_BOGUS,
- IMSG_CTL_RESOLVER_HISTOGRAM,
- IMSG_CTL_RESOLVER_DECAYING_HISTOGRAM,
IMSG_CTL_AUTOCONF_RESOLVER_INFO,
IMSG_CTL_END,
IMSG_HTTPSOCK,