Skip to content

Commit

Permalink
dhclient: support supersede statement for option 54
Browse files Browse the repository at this point in the history
Submitted by: Fabian Kurtz <fabian.kurtz@udo.edu>
  • Loading branch information
fichtner committed Mar 24, 2017
1 parent bfab6b0 commit 4af258d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion sbin/dhclient/dhclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include "privsep.h"

#include <sys/capsicum.h>
#include <sys/endian.h>

#include <net80211/ieee80211_freebsd.h>

Expand Down Expand Up @@ -132,6 +133,9 @@ int fork_privchld(int, int);
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))

/* Minimum MTU is 68 as per RFC791, p. 24 */
#define MIN_MTU 68

static time_t scripttime;

int
Expand Down Expand Up @@ -798,9 +802,20 @@ dhcpack(struct packet *packet)
void
bind_lease(struct interface_info *ip)
{
struct option_data *opt;

/* Remember the medium. */
ip->client->new->medium = ip->client->medium;

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);
else
interface_set_mtu_unpriv(privfd, mtu);
}

/* Write out the new lease. */
write_client_lease(ip, ip->client->new, 0);

Expand Down Expand Up @@ -850,7 +865,10 @@ state_bound(void *ipp)
make_request(ip, ip->client->active);
ip->client->xid = ip->client->packet.xid;

if (ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len == 4) {
if (ip->client->config->default_actions[DHO_DHCP_SERVER_IDENTIFIER] == ACTION_SUPERSEDE) {
memcpy(ip->client->destination.iabuf, ip->client->config->defaults[DHO_DHCP_SERVER_IDENTIFIER].data, 4);
ip->client->config->defaults[DHO_DHCP_SERVER_IDENTIFIER].len = 4;
} else if (ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len == 4) {
memcpy(ip->client->destination.iabuf, ip->client->active->
options[DHO_DHCP_SERVER_IDENTIFIER].data, 4);
ip->client->destination.len = 4;
Expand Down

0 comments on commit 4af258d

Please sign in to comment.