summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2017-05-27 10:52:17 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2017-05-27 10:52:17 +0000
commit0e8ed440d30b8aee14e3e8bbc4147f6ce975bd17 (patch)
tree2542f591bd7ca8d9998a16176ce9580afc60b2c4 /usr.sbin
parent29006189bc121515291f765336ed57ff835358ec (diff)
show address proposals in slaacdctl show interface output
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/slaacctl/slaacctl.c34
-rw-r--r--usr.sbin/slaacd/engine.c46
-rw-r--r--usr.sbin/slaacd/frontend.c4
-rw-r--r--usr.sbin/slaacd/slaacd.c3
-rw-r--r--usr.sbin/slaacd/slaacd.h20
5 files changed, 96 insertions, 11 deletions
diff --git a/usr.sbin/slaacctl/slaacctl.c b/usr.sbin/slaacctl/slaacctl.c
index 1ab42a92c00..41a53e8837b 100644
--- a/usr.sbin/slaacctl/slaacctl.c
+++ b/usr.sbin/slaacctl/slaacctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slaacctl.c,v 1.2 2017/05/27 10:40:43 florian Exp $ */
+/* $OpenBSD: slaacctl.c,v 1.3 2017/05/27 10:52:16 florian Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -174,6 +174,7 @@ show_interface_msg(struct imsg *imsg)
struct ctl_engine_info_ra_prefix *cei_ra_prefix;
struct ctl_engine_info_ra_rdns *cei_ra_rdns;
struct ctl_engine_info_ra_dnssl *cei_ra_dnssl;
+ struct ctl_engine_info_address_proposal *cei_addr_proposal;
struct tm *t;
struct timespec now, diff;
char buf[IF_NAMESIZE], *bufp;
@@ -245,6 +246,37 @@ show_interface_msg(struct imsg *imsg)
printf("\t\tsearch: %s, lifetime: %u\n", cei_ra_dnssl->dnssl,
cei_ra_dnssl->lifetime);
break;
+ case IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSALS:
+ printf("\tAddress proposals\n");
+ break;
+ case IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSAL:
+ cei_addr_proposal = imsg->data;
+
+ if (getnameinfo((struct sockaddr *)&cei_addr_proposal->addr,
+ cei_addr_proposal->addr.sin6_len, hbuf, sizeof(hbuf),
+ NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV))
+ err(1, "cannot get router IP");
+
+ printf("\t\tid: %4lld, state: %15s, privacy: %s\n",
+ cei_addr_proposal->id, cei_addr_proposal->state,
+ cei_addr_proposal->privacy ? "y" : "n");
+ printf("\t\tvltime: %10u, pltime: %10u\n",
+ cei_addr_proposal->vltime, cei_addr_proposal->pltime);
+
+ if (clock_gettime(CLOCK_MONOTONIC, &now))
+ err(1, "clock_gettime");
+
+ timespecsub(&now, &cei_addr_proposal->uptime, &diff);
+
+ t = localtime(&cei_addr_proposal->when.tv_sec);
+ strftime(whenbuf, sizeof(whenbuf), "%F %T", t);
+ printf("\t\tupdated: %s.%09ld; %lld.%09lds ago\n",
+ whenbuf, cei_addr_proposal->when.tv_nsec, diff.tv_sec,
+ diff.tv_nsec);
+ printf("\t\t%s, %s/%u\n", hbuf, inet_ntop(AF_INET6,
+ &cei_addr_proposal->prefix, ntopbuf, INET6_ADDRSTRLEN),
+ cei_addr_proposal->prefix_len);
+ break;
case IMSG_CTL_END:
printf("\n");
return (1);
diff --git a/usr.sbin/slaacd/engine.c b/usr.sbin/slaacd/engine.c
index 8944f494306..ee35fcb959e 100644
--- a/usr.sbin/slaacd/engine.c
+++ b/usr.sbin/slaacd/engine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: engine.c,v 1.12 2017/05/27 10:50:25 florian Exp $ */
+/* $OpenBSD: engine.c,v 1.13 2017/05/27 10:52:16 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -104,15 +104,15 @@ enum proposal_state {
PROPOSAL_SENT,
PROPOSAL_CONFIGURED,
PROPOSAL_NEARLY_EXPIRED,
- PROPSAL_WITHDRAWN,
+ PROPOSAL_WITHDRAWN,
};
const char* proposal_state_name[] = {
- "PROPOSAL_NOT_CONFIGURED",
- "PROPOSAL_SENT",
- "PROPOSAL_CONFIGURED",
- "PROPOSAL_NEARLY_EXPIRED",
- "PROPSAL_WITHDRAWN",
+ "NOT_CONFIGURED",
+ "SENT",
+ "CONFIGURED",
+ "NEARLY_EXPIRED",
+ "WITHDRAWN",
};
struct radv_prefix {
@@ -645,10 +645,12 @@ send_interface_info(struct slaacd_iface *iface, pid_t pid)
struct ctl_engine_info_ra_prefix cei_ra_prefix;
struct ctl_engine_info_ra_rdns cei_ra_rdns;
struct ctl_engine_info_ra_dnssl cei_ra_dnssl;
+ struct ctl_engine_info_address_proposal cei_addr_proposal;
struct radv *ra;
struct radv_prefix *prefix;
struct radv_rdns *rdns;
struct radv_dnssl *dnssl;
+ struct address_proposal *addr_proposal;
memset(&cei, 0, sizeof(cei));
cei.if_index = iface->if_index;
@@ -708,6 +710,36 @@ send_interface_info(struct slaacd_iface *iface, pid_t pid)
&cei_ra_dnssl, sizeof(cei_ra_dnssl));
}
}
+
+ if (!LIST_EMPTY(&iface->addr_proposals))
+ engine_imsg_compose_frontend(
+ IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSALS, pid, NULL, 0);
+
+ LIST_FOREACH(addr_proposal, &iface->addr_proposals, entries) {
+ memset(&cei_addr_proposal, 0, sizeof(cei_addr_proposal));
+ cei_addr_proposal.id = addr_proposal->id;
+ if(strlcpy(cei_addr_proposal.state,
+ proposal_state_name[addr_proposal->state],
+ sizeof(cei_addr_proposal.state)) >=
+ sizeof(cei_addr_proposal.state))
+ log_warn("truncated state name");
+ cei_addr_proposal.next_timeout = addr_proposal->next_timeout;
+ cei_addr_proposal.timeout_count = addr_proposal->timeout_count;
+ cei_addr_proposal.when = addr_proposal->when;
+ cei_addr_proposal.uptime = addr_proposal->uptime;
+ memcpy(&cei_addr_proposal.addr, &addr_proposal->addr, sizeof(
+ cei_addr_proposal.addr));
+ memcpy(&cei_addr_proposal.prefix, &addr_proposal->prefix,
+ sizeof(cei_addr_proposal.prefix));
+ cei_addr_proposal.prefix_len = addr_proposal->prefix_len;
+ cei_addr_proposal.privacy = addr_proposal->privacy;
+ cei_addr_proposal.vltime = addr_proposal->vltime;
+ cei_addr_proposal.pltime = addr_proposal->pltime;
+
+ engine_imsg_compose_frontend(
+ IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSAL, pid,
+ &cei_addr_proposal, sizeof(cei_addr_proposal));
+ }
}
void
diff --git a/usr.sbin/slaacd/frontend.c b/usr.sbin/slaacd/frontend.c
index eaf07c4ef9e..5f3834ad734 100644
--- a/usr.sbin/slaacd/frontend.c
+++ b/usr.sbin/slaacd/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.8 2017/05/27 10:50:25 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.9 2017/05/27 10:52:16 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -429,6 +429,8 @@ frontend_dispatch_engine(int fd, short event, void *bula)
case IMSG_CTL_SHOW_INTERFACE_INFO_RA_PREFIX:
case IMSG_CTL_SHOW_INTERFACE_INFO_RA_RDNS:
case IMSG_CTL_SHOW_INTERFACE_INFO_RA_DNSSL:
+ case IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSALS:
+ case IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSAL:
control_imsg_relay(&imsg);
break;
case IMSG_CTL_SEND_SOLICITATION:
diff --git a/usr.sbin/slaacd/slaacd.c b/usr.sbin/slaacd/slaacd.c
index f3cbba70bf8..0bf1b1d15cd 100644
--- a/usr.sbin/slaacd/slaacd.c
+++ b/usr.sbin/slaacd/slaacd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slaacd.c,v 1.10 2017/05/27 10:50:25 florian Exp $ */
+/* $OpenBSD: slaacd.c,v 1.11 2017/05/27 10:52:16 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -71,6 +71,7 @@ const char* imsg_type_name[] = {
"IMSG_PROPOSAL_ACK",
"IMSG_CONFIGURE_ADDRESS",
"IMSG_DEL_ADDRESS",
+ "IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSAL",
};
__dead void usage(void);
diff --git a/usr.sbin/slaacd/slaacd.h b/usr.sbin/slaacd/slaacd.h
index c1bc8ade2cd..4c9693f86c8 100644
--- a/usr.sbin/slaacd/slaacd.h
+++ b/usr.sbin/slaacd/slaacd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: slaacd.h,v 1.10 2017/05/27 10:50:25 florian Exp $ */
+/* $OpenBSD: slaacd.h,v 1.11 2017/05/27 10:52:16 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -67,6 +67,8 @@ enum imsg_type {
IMSG_PROPOSAL_ACK,
IMSG_CONFIGURE_ADDRESS,
IMSG_DEL_ADDRESS,
+ IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSALS,
+ IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSAL,
};
extern const char* imsg_type_name[];
@@ -123,6 +125,22 @@ struct ctl_engine_info_ra_dnssl {
char dnssl[SLAACD_MAX_DNSSL];
};
+struct ctl_engine_info_address_proposal {
+ int64_t id;
+ char state[32];
+ int next_timeout;
+ int timeout_count;
+ struct timespec when;
+ struct timespec uptime;
+ struct sockaddr_in6 addr;
+ struct in6_addr prefix;
+ int privacy;
+ uint8_t prefix_len;
+ uint32_t vltime;
+ uint32_t pltime;
+};
+
+
struct imsg_ifinfo {
uint32_t if_index;
int running;