diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-11-22 22:45:53 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-11-22 22:45:53 +0000 |
commit | 06ac63ea11d7cde65a501ff78af0df1eff86165e (patch) | |
tree | 4c7644750b42790021bc568d5217af3de19c5ae0 /sbin/dhclient | |
parent | 39bb0becea26653581c6e73b886e214cd2dd7d1d (diff) |
Polish logic talking to unwind.
ok florian@
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/dhclient.c | 16 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 4 | ||||
-rw-r--r-- | sbin/dhclient/kroute.c | 21 | ||||
-rw-r--r-- | sbin/dhclient/privsep.h | 3 |
4 files changed, 19 insertions, 25 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 1e78194af2e..4d870a3adcc 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.653 2019/11/19 14:35:07 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.654 2019/11/22 22:45:52 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -351,7 +351,7 @@ rtm_dispatch(struct interface_info *ifi, struct rt_msghdr *rtm) case RTM_PROPOSAL: if (rtm->rtm_priority == RTP_PROPOSAL_SOLICIT) { if (quit == 0 && ifi->active != NULL) - tell_unwind(ifi->unwind_info, RTF_UP, ifi->flags); + tell_unwind(ifi->unwind_info, ifi->flags); return; } if (rtm->rtm_index != ifi->index || @@ -388,7 +388,7 @@ rtm_dispatch(struct interface_info *ifi, struct rt_msghdr *rtm) if ((ifm->ifm_xflags & IFXF_AUTOCONF4) == 0 && (ifi->flags & IFI_AUTOCONF) != 0) { /* Tell unwind when IFI_AUTOCONF is cleared. */ - tell_unwind(ifi->unwind_info, 0, ifi->flags); + tell_unwind(NULL, ifi->flags); ifi->flags &= ~IFI_AUTOCONF; } else if ((ifm->ifm_xflags & IFXF_AUTOCONF4) != 0 && (ifi->flags & IFI_AUTOCONF) == 0) { @@ -987,18 +987,18 @@ bind_lease(struct interface_info *ifi) unwind_info = lease_as_unwind_info(ifi->active); if (ifi->unwind_info == NULL && unwind_info != NULL) { ifi->unwind_info = unwind_info; - tell_unwind(ifi->unwind_info, RTF_UP, ifi->flags); + tell_unwind(ifi->unwind_info, ifi->flags); } else if (ifi->unwind_info != NULL && unwind_info == NULL) { - tell_unwind(ifi->unwind_info, 0, ifi->flags); + tell_unwind(NULL, ifi->flags); free(ifi->unwind_info); ifi->unwind_info = NULL; } else if (ifi->unwind_info != NULL && unwind_info != NULL) { if (memcmp(ifi->unwind_info, unwind_info, sizeof(*ifi->unwind_info)) != 0) { - tell_unwind(ifi->unwind_info, 0, ifi->flags); + tell_unwind(NULL, ifi->flags); free(ifi->unwind_info); ifi->unwind_info = unwind_info; - tell_unwind(ifi->unwind_info, RTF_UP, ifi->flags); + tell_unwind(ifi->unwind_info, ifi->flags); } } @@ -2762,7 +2762,7 @@ release_lease(struct interface_info *ifi) make_release(ifi, ifi->active); send_release(ifi); - tell_unwind(ifi->unwind_info, 0, ifi->flags); + tell_unwind(NULL, ifi->flags); revoke_proposal(ifi->configured); imsg_flush(unpriv_ibuf); diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 3328e17b63a..b8d6c852bce 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.283 2019/11/19 14:35:08 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.284 2019/11/22 22:45:52 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -250,4 +250,4 @@ void write_resolv_conf(void); void propose(struct proposal *); void revoke_proposal(struct proposal *); -void tell_unwind(struct unwind_info *, int, int); +void tell_unwind(struct unwind_info *, int); diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c index 2ac509f1373..31560904a27 100644 --- a/sbin/dhclient/kroute.c +++ b/sbin/dhclient/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.171 2019/11/22 15:32:42 florian Exp $ */ +/* $OpenBSD: kroute.c,v 1.172 2019/11/22 22:45:52 krw Exp $ */ /* * Copyright 2012 Kenneth R Westerback <krw@openbsd.org> @@ -1012,20 +1012,18 @@ priv_revoke_proposal(char *name, int ioctlfd, struct imsg_revoke *imsg, * [priv_]tell_unwind sends out inforation unwind may be intereted in. */ void -tell_unwind(struct unwind_info *unwind_info, int rtm_flags, int ifi_flags) +tell_unwind(struct unwind_info *unwind_info, int ifi_flags) { struct imsg_tell_unwind imsg; int rslt; - if (unwind_info == NULL || - (ifi_flags & IFI_AUTOCONF) == 0 || + if ((ifi_flags & IFI_AUTOCONF) == 0 || (ifi_flags & IFI_IN_CHARGE) == 0) return; memset(&imsg, 0, sizeof(imsg)); - - imsg.rtm_flags = rtm_flags; - memcpy(&imsg.unwind_info, unwind_info, sizeof(imsg.unwind_info)); + 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, &imsg, sizeof(imsg)); @@ -1060,12 +1058,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; - if (imsg->rtm_flags == RTF_UP) { - 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)); - } else - rtdns.sr_len = 2; + 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)); iov[iovcnt].iov_base = &rtdns; iov[iovcnt++].iov_len = sizeof(rtdns); diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h index b2e0a74d5ee..3e8850580a4 100644 --- a/sbin/dhclient/privsep.h +++ b/sbin/dhclient/privsep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.h,v 1.60 2019/11/19 14:35:08 krw Exp $ */ +/* $OpenBSD: privsep.h,v 1.61 2019/11/22 22:45:52 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -55,7 +55,6 @@ struct imsg_revoke { struct imsg_tell_unwind { struct unwind_info unwind_info; - uint8_t rtm_flags; }; void dispatch_imsg(char *, int, int, int, struct imsgbuf *); |