From: martijn Date: Fri, 9 Apr 2021 14:46:39 +0000 (+0000) Subject: When a DHCP server sends an invalid T1 or T2 default back to the default X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2edea3cb9c69e2f348bc9a4d27a3bfd51e4e1bce;p=openbsd When a DHCP server sends an invalid T1 or T2 default back to the default values as specified in RFC2131 section 4.4.5. Allows my Comtrend VI-3223u to work. OK florian@ --- diff --git a/sbin/dhcpleased/engine.c b/sbin/dhcpleased/engine.c index a98dc3d59e7..e301c20939c 100644 --- a/sbin/dhcpleased/engine.c +++ b/sbin/dhcpleased/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.11 2021/03/22 15:34:07 otto Exp $ */ +/* $OpenBSD: engine.c,v 1.12 2021/04/09 14:46:39 martijn Exp $ */ /* * Copyright (c) 2017, 2021 Florian Obser @@ -972,23 +972,24 @@ parse_dhcp(struct dhcpleased_iface *iface, struct imsg_dhcp *dhcp) } /* RFC 2131 4.4.5 */ + /* Ignore invalid T1/T2 options */ + if (renewal_time >= rebinding_time) { + log_warnx("%s: renewal_time(%u) >= rebinding_time(%u) " + "from %s: using defaults", + __func__, renewal_time, rebinding_time, from); + renewal_time = rebinding_time = 0; + } else if (rebinding_time >= lease_time) { + log_warnx("%s: rebinding_time(%u) >= lease_time(%u) " + "from %s: using defaults", + __func__, rebinding_time, lease_time, from); + renewal_time = rebinding_time = 0; + } + if(renewal_time == 0) renewal_time = lease_time / 2; if (rebinding_time == 0) rebinding_time = lease_time - (lease_time / 8); - if (renewal_time >= rebinding_time) { - log_warnx("%s: renewal_time >= rebinding_time " - "(%u >= %u) from %s", __func__, renewal_time, - rebinding_time, from); - return; - } - if (rebinding_time >= lease_time) { - log_warnx("%s: rebinding_time >= lease_time" - "(%u >= %u) from %s", __func__, rebinding_time, - lease_time, from); - return; - } clock_gettime(CLOCK_MONOTONIC, &iface->request_time); iface->server_identifier.s_addr = server_identifier.s_addr; iface->requested_ip.s_addr = dhcp_hdr->yiaddr.s_addr;