Changeset View
Changeset View
Standalone View
Standalone View
sbin/dhclient/dhclient.c
Show First 20 Lines • Show All 823 Lines • ▼ Show 20 Lines | bind_lease(struct interface_info *ip) | ||||
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 = 0; | u_int16_t mtu = 0; | ||||
u_int16_t old_mtu = 0; | |||||
bool supersede = (ip->client->config->default_actions[DHO_INTERFACE_MTU] == | bool supersede = (ip->client->config->default_actions[DHO_INTERFACE_MTU] == | ||||
ACTION_SUPERSEDE); | ACTION_SUPERSEDE); | ||||
if (supersede) | if (supersede) | ||||
mtu = getUShort(ip->client->config->defaults[DHO_INTERFACE_MTU].data); | mtu = getUShort(ip->client->config->defaults[DHO_INTERFACE_MTU].data); | ||||
else | else | ||||
mtu = be16dec(opt->data); | mtu = be16dec(opt->data); | ||||
if (ip->client->active) { | |||||
opt = &ip->client->active->options[DHO_INTERFACE_MTU]; | |||||
if (opt->len == sizeof(u_int16_t)) { | |||||
old_mtu = be16dec(opt->data); | |||||
} | |||||
} | |||||
if (mtu < MIN_MTU) { | if (mtu < MIN_MTU) { | ||||
/* Treat 0 like a user intentionally doesn't want to change MTU and, | /* Treat 0 like a user intentionally doesn't want to change MTU and, | ||||
* therefore, warning is not needed */ | * therefore, warning is not needed */ | ||||
if (!supersede || mtu != 0) | if (!supersede || mtu != 0) | ||||
warning("mtu size %u < %d: ignored", (unsigned)mtu, MIN_MTU); | warning("mtu size %u < %d: ignored", (unsigned)mtu, MIN_MTU); | ||||
} else { | } else if (ip->client->state != S_RENEWING || mtu != old_mtu) { | ||||
cem: could this be simplified to `} else if (mtu != old_mtu) {`? What is the benefit of the state… | |||||
sobomaxAuthorUnsubmitted Done Inline ActionsNo, the check is actually needed here. The dhclient(8) saves its lease info, so upon reboot (state == S_REBOOTING) you might still see the same old_mtu, while interface would be in its default state. sobomax: No, the check is actually needed here. The dhclient(8) saves its lease info, so upon reboot… | |||||
cemUnsubmitted Done Inline ActionsI see, thanks. cem: I see, thanks. | |||||
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. */ | ||||
▲ Show 20 Lines • Show All 1,959 Lines • Show Last 20 Lines |
could this be simplified to } else if (mtu != old_mtu) {? What is the benefit of the state check?