summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2020-05-19 17:59:47 +0000
committerkrw <krw@openbsd.org>2020-05-19 17:59:47 +0000
commitd23c74a6e6f8a27984fb9e6eb45cfbdb80b38ea3 (patch)
tree2ccd448ea6c0f57839beba8575dab89b800ee9d7
parentsync libunbound fixes from unbound, ok florian@ (diff)
downloadwireguard-openbsd-d23c74a6e6f8a27984fb9e6eb45cfbdb80b38ea3.tar.xz
wireguard-openbsd-d23c74a6e6f8a27984fb9e6eb45cfbdb80b38ea3.zip
Eliminate imsg_propose{}, imsg_revoke{} and imsg_tell_unwind{} as
unnecessary wrappers, since they all contained a single field that could be used as is. Suggested by claudio@
-rw-r--r--sbin/dhclient/kroute.c44
-rw-r--r--sbin/dhclient/privsep.c8
-rw-r--r--sbin/dhclient/privsep.h20
3 files changed, 27 insertions, 45 deletions
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c
index 09d6836c8fe..a43dddeba9e 100644
--- a/sbin/dhclient/kroute.c
+++ b/sbin/dhclient/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.175 2020/05/15 11:14:00 krw Exp $ */
+/* $OpenBSD: kroute.c,v 1.176 2020/05/19 17:59:47 krw Exp $ */
/*
* Copyright 2012 Kenneth R Westerback <krw@openbsd.org>
@@ -881,24 +881,20 @@ priv_write_resolv_conf(int index, int routefd, int rdomain, char *contents,
void
propose(struct proposal *proposal)
{
- struct imsg_propose imsg;
int rslt;
- memcpy(&imsg.proposal, proposal, sizeof(imsg.proposal));
-
- rslt = imsg_compose(unpriv_ibuf, IMSG_PROPOSE, 0, 0, -1, &imsg,
- sizeof(imsg));
+ rslt = imsg_compose(unpriv_ibuf, IMSG_PROPOSE, 0, 0, -1, proposal,
+ sizeof(*proposal));
if (rslt == -1)
log_warn("%s: imsg_compose(IMSG_PROPOSE)", log_procname);
}
void
-priv_propose(char *name, int ioctlfd, struct imsg_propose *imsg,
+priv_propose(char *name, int ioctlfd, struct proposal *proposal,
char **resolv_conf, int routefd, int rdomain, int index)
{
struct unwind_info unwind_info;
struct ifreq ifr;
- struct proposal *proposal = &imsg->proposal;
char *search = NULL;
int rslt;
@@ -946,26 +942,21 @@ priv_propose(char *name, int ioctlfd, struct imsg_propose *imsg,
void
revoke_proposal(struct proposal *proposal)
{
- struct imsg_revoke imsg;
int rslt;
if (proposal == NULL)
return;
- memcpy(&imsg.proposal, proposal, sizeof(imsg.proposal));
-
- rslt = imsg_compose(unpriv_ibuf, IMSG_REVOKE, 0, 0, -1, &imsg,
- sizeof(imsg));
+ rslt = imsg_compose(unpriv_ibuf, IMSG_REVOKE, 0, 0, -1, proposal,
+ sizeof(*proposal));
if (rslt == -1)
log_warn("%s: imsg_compose(IMSG_REVOKE)", log_procname);
}
void
-priv_revoke_proposal(char *name, int ioctlfd, struct imsg_revoke *imsg,
+priv_revoke_proposal(char *name, int ioctlfd, struct proposal *proposal,
char **resolv_conf)
{
- struct proposal *proposal = &imsg->proposal;
-
free(*resolv_conf);
*resolv_conf = NULL;
@@ -978,25 +969,28 @@ priv_revoke_proposal(char *name, int ioctlfd, struct imsg_revoke *imsg,
void
tell_unwind(struct unwind_info *unwind_info, int ifi_flags)
{
- struct imsg_tell_unwind imsg;
+ struct unwind_info noinfo;
int rslt;
if ((ifi_flags & IFI_AUTOCONF) == 0 ||
(ifi_flags & IFI_IN_CHARGE) == 0)
return;
- memset(&imsg, 0, sizeof(imsg));
if (unwind_info != NULL)
- memcpy(&imsg.unwind_info, unwind_info, sizeof(imsg.unwind_info));
+ rslt = imsg_compose(unpriv_ibuf, IMSG_TELL_UNWIND, 0, 0, -1,
+ unwind_info, sizeof(*unwind_info));
+ else {
+ memset(&noinfo, 0, sizeof(noinfo));
+ rslt = imsg_compose(unpriv_ibuf, IMSG_TELL_UNWIND, 0, 0, -1,
+ &noinfo, sizeof(noinfo));
+ }
- rslt = imsg_compose(unpriv_ibuf, IMSG_TELL_UNWIND, 0, 0, -1, &imsg,
- sizeof(imsg));
if (rslt == -1)
log_warn("%s: imsg_compose(IMSG_TELL_UNWIND)", log_procname);
}
void
-priv_tell_unwind(int index, int routefd, int rdomain, struct imsg_tell_unwind *imsg)
+priv_tell_unwind(int index, int routefd, int rdomain, struct unwind_info *unwind_info)
{
struct rt_msghdr rtm;
struct sockaddr_rtdns rtdns;
@@ -1022,9 +1016,9 @@ priv_tell_unwind(int index, int routefd, int rdomain, struct imsg_tell_unwind *i
memset(&rtdns, 0, sizeof(rtdns));
rtdns.sr_family = AF_INET;
- rtdns.sr_len = 2 + imsg->unwind_info.count * sizeof(in_addr_t);
- memcpy(rtdns.sr_dns, imsg->unwind_info.ns,
- imsg->unwind_info.count * sizeof(in_addr_t));
+ rtdns.sr_len = 2 + unwind_info->count * sizeof(in_addr_t);
+ memcpy(rtdns.sr_dns, unwind_info->ns,
+ unwind_info->count * sizeof(in_addr_t));
iov[iovcnt].iov_base = &rtdns;
iov[iovcnt++].iov_len = sizeof(rtdns);
diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c
index 1a2d7250b70..e57268c2352 100644
--- a/sbin/dhclient/privsep.c
+++ b/sbin/dhclient/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.76 2019/11/19 14:35:08 krw Exp $ */
+/* $OpenBSD: privsep.c,v 1.77 2020/05/19 17:59:47 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -66,7 +66,7 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
switch (imsg.hdr.type) {
case IMSG_REVOKE:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct imsg_revoke))
+ sizeof(struct proposal))
log_warnx("%s: bad IMSG_REVOKE",
log_procname);
else
@@ -76,7 +76,7 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
case IMSG_PROPOSE:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct imsg_propose))
+ sizeof(struct proposal))
log_warnx("%s: bad IMSG_PROPOSE",
log_procname);
else {
@@ -97,7 +97,7 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
case IMSG_TELL_UNWIND:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct imsg_tell_unwind))
+ sizeof(struct unwind_info))
log_warnx("%s: bad IMSG_TELL_UNWIND",
log_procname);
else
diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h
index a5e991619f7..4bed6e29930 100644
--- a/sbin/dhclient/privsep.h
+++ b/sbin/dhclient/privsep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.h,v 1.63 2020/05/08 19:00:19 krw Exp $ */
+/* $OpenBSD: privsep.h,v 1.64 2020/05/19 17:59:47 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -43,23 +43,11 @@ struct unwind_info {
unsigned int count;
};
-struct imsg_propose {
- struct proposal proposal;
-};
-
-struct imsg_revoke {
- struct proposal proposal;
-};
-
-struct imsg_tell_unwind {
- struct unwind_info unwind_info;
-};
-
void dispatch_imsg(char *, int, int, int, struct imsgbuf *);
void priv_write_resolv_conf(int, int, int, char *, int *);
-void priv_propose(char *, int, struct imsg_propose *, char **, int, int, int);
+void priv_propose(char *, int, struct proposal *, char **, int, int, int);
-void priv_revoke_proposal(char *, int, struct imsg_revoke *, char **);
+void priv_revoke_proposal(char *, int, struct proposal *, char **);
-void priv_tell_unwind(int, int, int, struct imsg_tell_unwind *);
+void priv_tell_unwind(int, int, int, struct unwind_info *);