diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2018-05-31 19:36:24 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2018-05-31 19:36:24 +0000 |
commit | f93497fe64eb83f67670eff15000223a2e05b7d6 (patch) | |
tree | d02a1fa568c0c4a19a77dc82e112276fea91f45c /sbin/dhclient | |
parent | bbf8c8faf07cac63cce8cfaeecdeb1a168c86957 (diff) | |
download | src-f93497fe64eb83f67670eff15000223a2e05b7d6.tar.gz src-f93497fe64eb83f67670eff15000223a2e05b7d6.zip |
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>
MFC after: 37 minutes (if you care about 11, please MFC to 11.2)
Relnotes: yes (potentially surprising behavior change w/ broken dhcpd mtu)
Differential Revision: https://reviews.freebsd.org/D15484
Notes
Notes:
svn path=/head/; revision=334443
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/dhclient.c | 18 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.conf.5 | 10 |
2 files changed, 24 insertions, 4 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index de2d38649803..7150a0916499 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -849,11 +849,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. */ diff --git a/sbin/dhclient/dhclient.conf.5 b/sbin/dhclient/dhclient.conf.5 index fb9d9f17048c..2f28c5722574 100644 --- a/sbin/dhclient/dhclient.conf.5 +++ b/sbin/dhclient/dhclient.conf.5 @@ -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 values can be defined 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 } |