summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2019-11-19 14:49:36 +0000
committerflorian <florian@openbsd.org>2019-11-19 14:49:36 +0000
commitecfbee2cb26347583238f8ae4cc7226f90b260e3 (patch)
treea1a89318e2d3a0c28692da8afec0df5976637426
parentProposals from dhclient are sometimes replacements. (diff)
downloadwireguard-openbsd-ecfbee2cb26347583238f8ae4cc7226f90b260e3.tar.xz
wireguard-openbsd-ecfbee2cb26347583238f8ae4cc7226f90b260e3.zip
Print learned forwarders in unwindctl.
Someone please make this pretty. Tested by deraadt as part of a larger diff.
-rw-r--r--sbin/unwind/frontend.c3
-rw-r--r--sbin/unwind/resolver.c18
-rw-r--r--sbin/unwind/resolver.h7
-rw-r--r--sbin/unwind/unwind.h3
-rw-r--r--usr.sbin/unwindctl/unwindctl.c12
5 files changed, 35 insertions, 8 deletions
diff --git a/sbin/unwind/frontend.c b/sbin/unwind/frontend.c
index edc019d0567..d48d51db94e 100644
--- a/sbin/unwind/frontend.c
+++ b/sbin/unwind/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.36 2019/11/19 14:47:46 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.37 2019/11/19 14:49:36 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -536,6 +536,7 @@ frontend_dispatch_resolver(int fd, short event, void *bula)
case IMSG_CTL_CAPTIVEPORTAL_INFO:
case IMSG_CTL_RESOLVER_WHY_BOGUS:
case IMSG_CTL_RESOLVER_HISTOGRAM:
+ case IMSG_CTL_AUTOCONF_RESOLVER_INFO:
case IMSG_CTL_END:
control_imsg_relay(&imsg);
break;
diff --git a/sbin/unwind/resolver.c b/sbin/unwind/resolver.c
index ead3861fbd5..816a5944e48 100644
--- a/sbin/unwind/resolver.c
+++ b/sbin/unwind/resolver.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolver.c,v 1.68 2019/11/19 14:47:46 florian Exp $ */
+/* $OpenBSD: resolver.c,v 1.69 2019/11/19 14:49:36 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -1557,8 +1557,10 @@ restart_resolvers(void)
void
show_status(enum uw_resolver_type type, pid_t pid)
{
- struct uw_resolver *best;
- int i;
+ struct uw_resolver *best;
+ struct uw_forwarder *uw_forwarder;
+ struct ctl_forwarder_info cfi;
+ int i;
best = best_resolver();
@@ -1571,6 +1573,16 @@ show_status(enum uw_resolver_type type, pid_t pid)
resolvers[resolver_conf->res_pref[i]],
resolvers[resolver_conf->res_pref[i]] ==
best, pid);
+ TAILQ_FOREACH(uw_forwarder, &autoconf_forwarder_list, entry) {
+ memset(&cfi, 0, sizeof(cfi));
+ cfi.src = uw_forwarder->src;
+ /* no truncation, structs are in sync */
+ strlcpy(cfi.name, uw_forwarder->name,
+ sizeof(cfi.name));
+ resolver_imsg_compose_frontend(
+ IMSG_CTL_AUTOCONF_RESOLVER_INFO,
+ pid, &cfi, sizeof(cfi));
+ }
break;
case UW_RES_RECURSOR:
case UW_RES_DHCP:
diff --git a/sbin/unwind/resolver.h b/sbin/unwind/resolver.h
index cb0e166381c..1ffc053cf0f 100644
--- a/sbin/unwind/resolver.h
+++ b/sbin/unwind/resolver.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolver.h,v 1.7 2019/11/03 09:46:11 otto Exp $ */
+/* $OpenBSD: resolver.h,v 1.8 2019/11/19 14:49:36 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -54,6 +54,11 @@ struct ctl_resolver_info {
int oppdot;
};
+struct ctl_forwarder_info {
+ char name[1024]; /* XXX, keep in sync with uw_forwarder */
+ int src;
+};
+
void resolver(int, int);
int resolver_imsg_compose_main(int, pid_t, void *, uint16_t);
int resolver_imsg_compose_frontend(int, pid_t, void *, uint16_t);
diff --git a/sbin/unwind/unwind.h b/sbin/unwind/unwind.h
index 36090986d64..95085da1345 100644
--- a/sbin/unwind/unwind.h
+++ b/sbin/unwind/unwind.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: unwind.h,v 1.30 2019/11/19 14:47:46 florian Exp $ */
+/* $OpenBSD: unwind.h,v 1.31 2019/11/19 14:49:36 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -107,6 +107,7 @@ enum imsg_type {
IMSG_CTL_RESOLVER_INFO,
IMSG_CTL_RESOLVER_WHY_BOGUS,
IMSG_CTL_RESOLVER_HISTOGRAM,
+ IMSG_CTL_AUTOCONF_RESOLVER_INFO,
IMSG_CTL_END,
IMSG_CTL_RECHECK_CAPTIVEPORTAL,
IMSG_HTTPSOCK,
diff --git a/usr.sbin/unwindctl/unwindctl.c b/usr.sbin/unwindctl/unwindctl.c
index e2c7b7e877f..1371d74d889 100644
--- a/usr.sbin/unwindctl/unwindctl.c
+++ b/usr.sbin/unwindctl/unwindctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: unwindctl.c,v 1.11 2019/11/11 05:51:06 florian Exp $ */
+/* $OpenBSD: unwindctl.c,v 1.12 2019/11/19 14:49:36 florian Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -222,8 +222,9 @@ main(int argc, char *argv[])
int
show_status_msg(struct imsg *imsg)
{
- static int header;
+ static int header, autoconf_forwarders;
struct ctl_resolver_info *cri;
+ struct ctl_forwarder_info *cfi;
enum captive_portal_state captive_portal_state;
if (imsg->hdr.type != IMSG_CTL_CAPTIVEPORTAL_INFO && !header++)
@@ -253,6 +254,13 @@ show_status_msg(struct imsg *imsg)
uw_resolver_state_str[cri->state],
cri->oppdot ? " (opportunistic DoT)" : "");
break;
+ case IMSG_CTL_AUTOCONF_RESOLVER_INFO:
+ cfi = imsg->data;
+ if (!autoconf_forwarders++)
+ printf("\nlearned forwarders:\n");
+ printf("[%s] %s\n", cfi->src == RTP_PROPOSAL_DHCLIENT
+ ? " DHCP" : "SLAAC", cfi->name);
+ break;
case IMSG_CTL_RESOLVER_WHY_BOGUS:
/* make sure this is a string */
((char *)imsg->data)[imsg->hdr.len - IMSG_HEADER_SIZE -1] =