Changeset View
Changeset View
Standalone View
Standalone View
dhclient/dhclient.c
Show First 20 Lines • Show All 822 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct option_data *opt; | struct option_data *opt; | ||||
/* Remember the medium. */ | /* Remember the medium. */ | ||||
ip->client->new->medium = ip->client->medium; | ip->client->new->medium = ip->client->medium; | ||||
opt = &ip->client->new->options[DHO_INTERFACE_MTU]; | opt = &ip->client->new->options[DHO_INTERFACE_MTU]; | ||||
if (opt->len == sizeof(u_int16_t)) { | if (opt->len == sizeof(u_int16_t)) { | ||||
u_int16_t mtu = be16dec(opt->data); | u_int16_t mtu = 0; | ||||
if (mtu < MIN_MTU) | bool supersede = (ip->client->config->default_actions[DHO_INTERFACE_MTU] == | ||||
warning("mtu size %u < %d: ignored", (unsigned)mtu, MIN_MTU); | ACTION_SUPERSEDE); | ||||
if (supersede) | |||||
mtu = getUShort(ip->client->config->defaults[DHO_INTERFACE_MTU].data); | |||||
else | 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) | |||||
cem: Maybe we should still warn if the server sends zero, vs the user configuring it. But I don't… | |||||
Not Done Inline ActionsAll of these parentheses seem excessive -- just if (!supersede || mtu == 0) would do. cem: All of these parentheses seem excessive -- just `if (!supersede || mtu == 0)` would do. | |||||
Not Done Inline ActionsThis way it'll still print a warning for superseded value because 'mtu == 0' will be true. novel: This way it'll still print a warning for superseded value because 'mtu == 0' will be true. | |||||
Not Done Inline ActionsAh, sorry, I meant '!= 0' and I see you got that right :-). LGTM. cem: Ah, sorry, I meant '!= 0' and I see you got that right :-). LGTM. | |||||
warning("mtu size %u < %d: ignored", (unsigned)mtu, MIN_MTU); | |||||
} else { | |||||
interface_set_mtu_unpriv(privfd, mtu); | interface_set_mtu_unpriv(privfd, mtu); | ||||
} | |||||
} | } | ||||
/* Write out the new lease. */ | /* Write out the new lease. */ | ||||
write_client_lease(ip, ip->client->new, 0); | write_client_lease(ip, ip->client->new, 0); | ||||
/* Run the client script with the new parameters. */ | /* Run the client script with the new parameters. */ | ||||
script_init((ip->client->state == S_REQUESTING ? "BOUND" : | script_init((ip->client->state == S_REQUESTING ? "BOUND" : | ||||
(ip->client->state == S_RENEWING ? "RENEW" : | (ip->client->state == S_RENEWING ? "RENEW" : | ||||
▲ Show 20 Lines • Show All 1,957 Lines • Show Last 20 Lines |
Maybe we should still warn if the server sends zero, vs the user configuring it. But I don't feel strongly about it.