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 |
} |