diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-04-04 09:36:57 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-04-04 14:46:23 +0200 |
commit | de8a76da2f374792594ce03a203b3f30e4889f6f (patch) | |
tree | 12b5e1e59358005c3c522955c08aee4795e4829c /freebsd/sbin/dhclient | |
parent | Enable bridging by default (diff) | |
download | rtems-libbsd-de8a76da2f374792594ce03a203b3f30e4889f6f.tar.bz2 |
Update to FreeBSD head 2017-04-04
Git mirror commit 642b174daddbd0efd9bb5f242c43f4ab4db6869f.
Diffstat (limited to 'freebsd/sbin/dhclient')
-rw-r--r-- | freebsd/sbin/dhclient/clparse.c | 4 | ||||
-rw-r--r-- | freebsd/sbin/dhclient/dhclient.c | 31 |
2 files changed, 28 insertions, 7 deletions
diff --git a/freebsd/sbin/dhclient/clparse.c b/freebsd/sbin/dhclient/clparse.c index 10df53b3..1bb0f957 100644 --- a/freebsd/sbin/dhclient/clparse.c +++ b/freebsd/sbin/dhclient/clparse.c @@ -514,6 +514,7 @@ parse_client_lease_statement(FILE *cfile, int is_static) token = peek_token(&val, cfile); if (token == EOF) { parse_warn("unterminated lease declaration."); + free_client_lease(lease); return; } if (token == RBRACE) @@ -715,6 +716,7 @@ parse_option_decl(FILE *cfile, struct option_data *options) parse_warn("expecting identifier after '.'"); if (token != SEMI) skip_to_semi(cfile); + free(vendor); return (NULL); } @@ -727,6 +729,7 @@ parse_option_decl(FILE *cfile, struct option_data *options) if (!universe) { parse_warn("no vendor named %s.", vendor); skip_to_semi(cfile); + free(vendor); return (NULL); } } else { @@ -748,6 +751,7 @@ parse_option_decl(FILE *cfile, struct option_data *options) parse_warn("no option named %s for vendor %s", val, vendor); skip_to_semi(cfile); + free(vendor); return (NULL); } diff --git a/freebsd/sbin/dhclient/dhclient.c b/freebsd/sbin/dhclient/dhclient.c index 46ffaffc..56d7cbf7 100644 --- a/freebsd/sbin/dhclient/dhclient.c +++ b/freebsd/sbin/dhclient/dhclient.c @@ -758,7 +758,11 @@ dhcpack(struct packet *packet) cancel_timeout(send_request, ip); /* Figure out the lease time. */ - if (ip->client->new->options[DHO_DHCP_LEASE_TIME].data) + if (ip->client->config->default_actions[DHO_DHCP_LEASE_TIME] == + ACTION_SUPERSEDE) + ip->client->new->expiry = getULong( + ip->client->config->defaults[DHO_DHCP_LEASE_TIME].data); + else if (ip->client->new->options[DHO_DHCP_LEASE_TIME].data) ip->client->new->expiry = getULong( ip->client->new->options[DHO_DHCP_LEASE_TIME].data); else @@ -771,21 +775,34 @@ dhcpack(struct packet *packet) if (ip->client->new->expiry < 60) ip->client->new->expiry = 60; - /* Take the server-provided renewal time if there is one; - otherwise figure it out according to the spec. */ - if (ip->client->new->options[DHO_DHCP_RENEWAL_TIME].len) + /* Unless overridden in the config, take the server-provided renewal + * time if there is one; otherwise figure it out according to the spec. + * Also make sure the renewal time does not exceed the expiry time. + */ + if (ip->client->config->default_actions[DHO_DHCP_RENEWAL_TIME] == + ACTION_SUPERSEDE) + ip->client->new->renewal = getULong( + ip->client->config->defaults[DHO_DHCP_RENEWAL_TIME].data); + else if (ip->client->new->options[DHO_DHCP_RENEWAL_TIME].len) ip->client->new->renewal = getULong( ip->client->new->options[DHO_DHCP_RENEWAL_TIME].data); else ip->client->new->renewal = ip->client->new->expiry / 2; + if (ip->client->new->renewal > ip->client->new->expiry / 2) + ip->client->new->renewal = ip->client->new->expiry / 2; /* Same deal with the rebind time. */ - if (ip->client->new->options[DHO_DHCP_REBINDING_TIME].len) + if (ip->client->config->default_actions[DHO_DHCP_REBINDING_TIME] == + ACTION_SUPERSEDE) + ip->client->new->rebind = getULong( + ip->client->config->defaults[DHO_DHCP_REBINDING_TIME].data); + else if (ip->client->new->options[DHO_DHCP_REBINDING_TIME].len) ip->client->new->rebind = getULong( ip->client->new->options[DHO_DHCP_REBINDING_TIME].data); else - ip->client->new->rebind = ip->client->new->renewal + - ip->client->new->renewal / 2 + ip->client->new->renewal / 4; + ip->client->new->rebind = ip->client->new->renewal * 7 / 4; + if (ip->client->new->rebind > ip->client->new->renewal * 7 / 4) + ip->client->new->rebind = ip->client->new->renewal * 7 / 4; ip->client->new->expiry += cur_time; /* Lease lengths can never be negative. */ |