Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jun 2018 15:51:24 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org
Subject:   svn commit: r334789 - releng/11.2/sbin/dhclient
Message-ID:  <201806071551.w57FpOBs005445@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Thu Jun  7 15:51:23 2018
New Revision: 334789
URL: https://svnweb.freebsd.org/changeset/base/334789

Log:
  MFC: r334443 (by cem@) MF stable/11: r334787
  
  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:	<jimp AT pfsense.org>
  Approved by:	re (gjb)
  Relnotes:	yes (potentially surprising behavior change w/ broken dhcpd mtu)
  Differential Revision:	https://reviews.freebsd.org/D15484

Modified:
  releng/11.2/sbin/dhclient/dhclient.c
  releng/11.2/sbin/dhclient/dhclient.conf.5
Directory Properties:
  releng/11.2/   (props changed)

Modified: releng/11.2/sbin/dhclient/dhclient.c
==============================================================================
--- releng/11.2/sbin/dhclient/dhclient.c	Thu Jun  7 15:27:07 2018	(r334788)
+++ releng/11.2/sbin/dhclient/dhclient.c	Thu Jun  7 15:51:23 2018	(r334789)
@@ -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: releng/11.2/sbin/dhclient/dhclient.conf.5
==============================================================================
--- releng/11.2/sbin/dhclient/dhclient.conf.5	Thu Jun  7 15:27:07 2018	(r334788)
+++ releng/11.2/sbin/dhclient/dhclient.conf.5	Thu Jun  7 15:51:23 2018	(r334789)
@@ -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 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806071551.w57FpOBs005445>