From owner-svn-src-all@freebsd.org Fri Apr 7 09:13:27 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A32D2D33C9C; Fri, 7 Apr 2017 09:13:27 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 804E0934; Fri, 7 Apr 2017 09:13:27 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v379DQbR059736; Fri, 7 Apr 2017 09:13:26 GMT (envelope-from n_hibma@FreeBSD.org) Received: (from n_hibma@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v379DQ0r059735; Fri, 7 Apr 2017 09:13:26 GMT (envelope-from n_hibma@FreeBSD.org) Message-Id: <201704070913.v379DQ0r059735@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: n_hibma set sender to n_hibma@FreeBSD.org using -f From: Nick Hibma Date: Fri, 7 Apr 2017 09:13:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r316604 - stable/11/sbin/dhclient X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Apr 2017 09:13:27 -0000 Author: n_hibma Date: Fri Apr 7 09:13:26 2017 New Revision: 316604 URL: https://svnweb.freebsd.org/changeset/base/316604 Log: MFC 316283: Allow superseding the lease renewal and rebind times. Also make sure that the renewal is never more than 1/2 * expiry and rebind never more than 7/4 * renewal (the default values in the spec). This should allow adjusting high values from the server as well as making sure the values from the server make sense. Renewal and rebind times will be adjusted down if the expiry time is set very high in a server, not the other way around. This change just makes sure the values keep making sense. and 316285: Make dhcp-lease-time option supersedable as well. Note: It is not recommended to set this value to above the value that the server provided, unless that value is bogus. Modified: stable/11/sbin/dhclient/dhclient.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/dhclient/dhclient.c ============================================================================== --- stable/11/sbin/dhclient/dhclient.c Fri Apr 7 07:46:21 2017 (r316603) +++ stable/11/sbin/dhclient/dhclient.c Fri Apr 7 09:13:26 2017 (r316604) @@ -752,7 +752,11 @@ dhcpack(struct packet *packet) cancel_timeout(send_request, ip); /* Figure out the lease time. */ - if (ip->client->new->options[DHO_DHCP_LEASE_TIME].data) + if (ip->client->config->default_actions[DHO_DHCP_LEASE_TIME] == + ACTION_SUPERSEDE) + ip->client->new->expiry = getULong( + ip->client->config->defaults[DHO_DHCP_LEASE_TIME].data); + else if (ip->client->new->options[DHO_DHCP_LEASE_TIME].data) ip->client->new->expiry = getULong( ip->client->new->options[DHO_DHCP_LEASE_TIME].data); else @@ -765,21 +769,34 @@ dhcpack(struct packet *packet) if (ip->client->new->expiry < 60) ip->client->new->expiry = 60; - /* Take the server-provided renewal time if there is one; - otherwise figure it out according to the spec. */ - if (ip->client->new->options[DHO_DHCP_RENEWAL_TIME].len) + /* Unless overridden in the config, take the server-provided renewal + * time if there is one; otherwise figure it out according to the spec. + * Also make sure the renewal time does not exceed the expiry time. + */ + if (ip->client->config->default_actions[DHO_DHCP_RENEWAL_TIME] == + ACTION_SUPERSEDE) + ip->client->new->renewal = getULong( + ip->client->config->defaults[DHO_DHCP_RENEWAL_TIME].data); + else if (ip->client->new->options[DHO_DHCP_RENEWAL_TIME].len) ip->client->new->renewal = getULong( ip->client->new->options[DHO_DHCP_RENEWAL_TIME].data); else ip->client->new->renewal = ip->client->new->expiry / 2; + if (ip->client->new->renewal > ip->client->new->expiry / 2) + ip->client->new->renewal = ip->client->new->expiry / 2; /* Same deal with the rebind time. */ - if (ip->client->new->options[DHO_DHCP_REBINDING_TIME].len) + if (ip->client->config->default_actions[DHO_DHCP_REBINDING_TIME] == + ACTION_SUPERSEDE) + ip->client->new->rebind = getULong( + ip->client->config->defaults[DHO_DHCP_REBINDING_TIME].data); + else if (ip->client->new->options[DHO_DHCP_REBINDING_TIME].len) ip->client->new->rebind = getULong( ip->client->new->options[DHO_DHCP_REBINDING_TIME].data); else - ip->client->new->rebind = ip->client->new->renewal + - ip->client->new->renewal / 2 + ip->client->new->renewal / 4; + ip->client->new->rebind = ip->client->new->renewal * 7 / 4; + if (ip->client->new->rebind > ip->client->new->renewal * 7 / 4) + ip->client->new->rebind = ip->client->new->renewal * 7 / 4; ip->client->new->expiry += cur_time; /* Lease lengths can never be negative. */