View | Details | Raw Unified | Return to bug 208392
Collapse All | Expand All

(-)sbin/dhclient/clparse.c (+2 lines)
Lines 102-107 Link Here
102
	    [top_level_config.requested_option_count++] = DHO_HOST_NAME;
102
	    [top_level_config.requested_option_count++] = DHO_HOST_NAME;
103
	top_level_config.requested_options
103
	top_level_config.requested_options
104
	    [top_level_config.requested_option_count++] = DHO_DOMAIN_SEARCH;
104
	    [top_level_config.requested_option_count++] = DHO_DOMAIN_SEARCH;
105
	top_level_config.requested_options
106
	    [top_level_config.requested_option_count++] = DHO_INTERFACE_MTU;
105
107
106
	if ((cfile = fopen(path_dhclient_conf, "r")) != NULL) {
108
	if ((cfile = fopen(path_dhclient_conf, "r")) != NULL) {
107
		do {
109
		do {
(-)sbin/dhclient/dhclient.c (+13 lines)
Lines 798-806 Link Here
798
void
798
void
799
bind_lease(struct interface_info *ip)
799
bind_lease(struct interface_info *ip)
800
{
800
{
801
	struct option_data *opt;
802
801
	/* Remember the medium. */
803
	/* Remember the medium. */
802
	ip->client->new->medium = ip->client->medium;
804
	ip->client->new->medium = ip->client->medium;
803
805
806
	opt = &ip->client->new->options[DHO_INTERFACE_MTU];
807
	if (opt->len == sizeof(u_int16_t)) {
808
		u_int16_t mtu;
809
		memcpy(&mtu, opt->data, sizeof(mtu));
810
		mtu = ntohs(mtu);
811
		if (mtu < 68)
812
			warning("mtu size %u < 68: ignored", mtu);
813
		else
814
			interface_set_mtu_unpriv(privfd, mtu);
815
	}
816
804
	/* Write out the new lease. */
817
	/* Write out the new lease. */
805
	write_client_lease(ip, ip->client->new, 0);
818
	write_client_lease(ip, ip->client->new, 0);
806
819
(-)sbin/dhclient/dhcpd.h (+2 lines)
Lines 319-324 Link Here
319
void add_protocol(char *, int, void (*)(struct protocol *), void *);
319
void add_protocol(char *, int, void (*)(struct protocol *), void *);
320
void remove_protocol(struct protocol *);
320
void remove_protocol(struct protocol *);
321
int interface_link_status(char *);
321
int interface_link_status(char *);
322
void interface_set_mtu_unpriv(int, u_int16_t);
323
void interface_set_mtu_priv(char *, u_int16_t); 
322
324
323
/* hash.c */
325
/* hash.c */
324
struct hash_table *new_hash(void);
326
struct hash_table *new_hash(void);
(-)sbin/dhclient/dispatch.c (+44 lines)
Lines 43-48 Link Here
43
__FBSDID("$FreeBSD$");
43
__FBSDID("$FreeBSD$");
44
44
45
#include "dhcpd.h"
45
#include "dhcpd.h"
46
#include "privsep.h"
46
47
47
#include <sys/ioctl.h>
48
#include <sys/ioctl.h>
48
49
Lines 501-503 Link Here
501
	}
502
	}
502
	return (1);
503
	return (1);
503
}
504
}
505
506
void
507
interface_set_mtu_unpriv(int privfd, u_int16_t mtu)
508
{
509
	struct imsg_hdr hdr;
510
	struct buf *buf;
511
	int errs = 0;
512
513
	hdr.code = IMSG_SET_INTERFACE_MTU;
514
	hdr.len = sizeof(hdr) +
515
		sizeof(u_int16_t);
516
517
	if ((buf = buf_open(hdr.len)) == NULL)
518
		error("buf_open: %m");
519
520
	errs += buf_add(buf, &hdr, sizeof(hdr));
521
	errs += buf_add(buf, &mtu, sizeof(mtu));
522
	if (errs)
523
		error("buf_add: %m");
524
	
525
	if (buf_close(privfd, buf) == -1)
526
		error("buf_close: %m");
527
}
528
529
void
530
interface_set_mtu_priv(char *ifname, u_int16_t mtu)
531
{
532
	struct ifreq ifr;
533
	int sock;
534
535
	if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
536
		error("Can't create socket");
537
538
	memset(&ifr, 0, sizeof(ifr));
539
540
	strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
541
	ifr.ifr_mtu = mtu;
542
543
	if (ioctl(sock, SIOCSIFMTU, &ifr) == -1)
544
		warning("SIOCSIFMTU failed (%d): %s", mtu,
545
			strerror(errno));
546
	close(sock);
547
}
(-)sbin/dhclient/privsep.h (-1 / +2 lines)
Lines 36-42 Link Here
36
	IMSG_SCRIPT_WRITE_PARAMS,
36
	IMSG_SCRIPT_WRITE_PARAMS,
37
	IMSG_SCRIPT_GO,
37
	IMSG_SCRIPT_GO,
38
	IMSG_SCRIPT_GO_RET,
38
	IMSG_SCRIPT_GO_RET,
39
	IMSG_SEND_PACKET
39
	IMSG_SEND_PACKET,
40
	IMSG_SET_INTERFACE_MTU,
40
};
41
};
41
42
42
struct imsg_hdr {
43
struct imsg_hdr {
(-)sbin/dhclient/privsep.c (+8 lines)
Lines 111-116 Link Here
111
	struct client_lease	 lease;
111
	struct client_lease	 lease;
112
	int			 ret, i, optlen;
112
	int			 ret, i, optlen;
113
	struct buf		*buf;
113
	struct buf		*buf;
114
	u_int16_t		mtu;
114
115
115
	buf_read(fd, &hdr, sizeof(hdr));
116
	buf_read(fd, &hdr, sizeof(hdr));
116
117
Lines 235-240 Link Here
235
	case IMSG_SEND_PACKET:
236
	case IMSG_SEND_PACKET:
236
		send_packet_priv(ifi, &hdr, fd);
237
		send_packet_priv(ifi, &hdr, fd);
237
		break;
238
		break;
239
	case IMSG_SET_INTERFACE_MTU:
240
		if (hdr.len < sizeof(hdr) + sizeof(u_int16_t))
241
			error("corrupted message received");	
242
	
243
		buf_read(fd, &mtu, sizeof(u_int16_t));
244
		interface_set_mtu_priv(ifi->name, mtu);
245
		break;
238
	default:
246
	default:
239
		error("received unknown message, code %d", hdr.code);
247
		error("received unknown message, code %d", hdr.code);
240
	}
248
	}

Return to bug 208392