From owner-svn-src-all@freebsd.org Thu Jun 7 15:03:49 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 098D4FDD92C; Thu, 7 Jun 2018 15:03:49 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AEAAB6E3B6; Thu, 7 Jun 2018 15:03:48 +0000 (UTC) (envelope-from marius@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7598F21BD1; Thu, 7 Jun 2018 15:03:48 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w57F3mLp081932; Thu, 7 Jun 2018 15:03:48 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w57F3mpY081930; Thu, 7 Jun 2018 15:03:48 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201806071503.w57F3mpY081930@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 7 Jun 2018 15:03:48 +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: r334787 - stable/11/sbin/dhclient X-SVN-Group: stable-11 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/11/sbin/dhclient X-SVN-Commit-Revision: 334787 X-SVN-Commit-Repository: base 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.26 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: Thu, 07 Jun 2018 15:03:49 -0000 Author: marius Date: Thu Jun 7 15:03:47 2018 New Revision: 334787 URL: https://svnweb.freebsd.org/changeset/base/334787 Log: MFC: r334443 (by cem@) dhclient(8): allow to supersede interface-mtu option In some cases broken DHCP servers might send invalid MTU value, so allow to use 'supersede' in dhclient.conf to override this. When superseded value is 0, MTU value is not updated at all. PR: 206721 Submitted by: novel@ Reported by: Relnotes: yes (potentially surprising behavior change w/ broken dhcpd mtu) Differential Revision: https://reviews.freebsd.org/D15484 Modified: stable/11/sbin/dhclient/dhclient.c stable/11/sbin/dhclient/dhclient.conf.5 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/dhclient/dhclient.c ============================================================================== --- stable/11/sbin/dhclient/dhclient.c Thu Jun 7 14:46:52 2018 (r334786) +++ stable/11/sbin/dhclient/dhclient.c Thu Jun 7 15:03:47 2018 (r334787) @@ -828,11 +828,23 @@ bind_lease(struct interface_info *ip) opt = &ip->client->new->options[DHO_INTERFACE_MTU]; if (opt->len == sizeof(u_int16_t)) { - u_int16_t mtu = be16dec(opt->data); - if (mtu < MIN_MTU) - warning("mtu size %u < %d: ignored", (unsigned)mtu, MIN_MTU); + u_int16_t mtu = 0; + bool supersede = (ip->client->config->default_actions[DHO_INTERFACE_MTU] == + ACTION_SUPERSEDE); + + if (supersede) + mtu = getUShort(ip->client->config->defaults[DHO_INTERFACE_MTU].data); else + mtu = be16dec(opt->data); + + if (mtu < MIN_MTU) { + /* Treat 0 like a user intentionally doesn't want to change MTU and, + * therefore, warning is not needed */ + if (!supersede || mtu != 0) + warning("mtu size %u < %d: ignored", (unsigned)mtu, MIN_MTU); + } else { interface_set_mtu_unpriv(privfd, mtu); + } } /* Write out the new lease. */ Modified: stable/11/sbin/dhclient/dhclient.conf.5 ============================================================================== --- stable/11/sbin/dhclient/dhclient.conf.5 Thu Jun 7 14:46:52 2018 (r334786) +++ stable/11/sbin/dhclient/dhclient.conf.5 Thu Jun 7 15:03:47 2018 (r334787) @@ -38,7 +38,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 1, 1997 +.Dd May 31, 2018 .Dt DHCLIENT.CONF 5 .Os .Sh NAME @@ -227,6 +227,14 @@ rather than any value supplied by the server, these va in the .Ic supersede statement. +.Pp +Some options values have special meaning: +.Bl -tag -width indent +.It Ar interface-mtu +Any server-supplied interface MTU is ignored by the client if a +.Ic supersede +zero value is configured. +.El .It Xo .Ic prepend No { Op Ar option declaration .Oo , Ar ... option declaration Oc }