FreeBSD Bugzilla – Attachment 171088 Details for
Bug 208392
[ PATCH ] dhclient: add support for interface-mtu (26)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
proposed fix, v1
D5675.diff (text/plain), 3.85 KB, created by
Roman Bogorodskiy
on 2016-06-06 10:51:32 UTC
(
hide
)
Description:
proposed fix, v1
Filename:
MIME Type:
Creator:
Roman Bogorodskiy
Created:
2016-06-06 10:51:32 UTC
Size:
3.85 KB
patch
obsolete
>Index: sbin/dhclient/clparse.c >=================================================================== >--- sbin/dhclient/clparse.c >+++ sbin/dhclient/clparse.c >@@ -102,6 +102,8 @@ > [top_level_config.requested_option_count++] = DHO_HOST_NAME; > top_level_config.requested_options > [top_level_config.requested_option_count++] = DHO_DOMAIN_SEARCH; >+ top_level_config.requested_options >+ [top_level_config.requested_option_count++] = DHO_INTERFACE_MTU; > > if ((cfile = fopen(path_dhclient_conf, "r")) != NULL) { > do { >Index: sbin/dhclient/dhclient.c >=================================================================== >--- sbin/dhclient/dhclient.c >+++ sbin/dhclient/dhclient.c >@@ -798,9 +798,22 @@ > 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; >+ memcpy(&mtu, opt->data, sizeof(mtu)); >+ mtu = ntohs(mtu); >+ if (mtu < 68) >+ warning("mtu size %u < 68: ignored", mtu); >+ else >+ interface_set_mtu_unpriv(privfd, mtu); >+ } >+ > /* Write out the new lease. */ > write_client_lease(ip, ip->client->new, 0); > >Index: sbin/dhclient/dhcpd.h >=================================================================== >--- sbin/dhclient/dhcpd.h >+++ sbin/dhclient/dhcpd.h >@@ -319,6 +319,8 @@ > void add_protocol(char *, int, void (*)(struct protocol *), void *); > void remove_protocol(struct protocol *); > int interface_link_status(char *); >+void interface_set_mtu_unpriv(int, u_int16_t); >+void interface_set_mtu_priv(char *, u_int16_t); > > /* hash.c */ > struct hash_table *new_hash(void); >Index: sbin/dhclient/dispatch.c >=================================================================== >--- sbin/dhclient/dispatch.c >+++ sbin/dhclient/dispatch.c >@@ -43,6 +43,7 @@ > __FBSDID("$FreeBSD$"); > > #include "dhcpd.h" >+#include "privsep.h" > > #include <sys/ioctl.h> > >@@ -501,3 +502,46 @@ > } > return (1); > } >+ >+void >+interface_set_mtu_unpriv(int privfd, u_int16_t mtu) >+{ >+ struct imsg_hdr hdr; >+ struct buf *buf; >+ int errs = 0; >+ >+ hdr.code = IMSG_SET_INTERFACE_MTU; >+ hdr.len = sizeof(hdr) + >+ sizeof(u_int16_t); >+ >+ if ((buf = buf_open(hdr.len)) == NULL) >+ error("buf_open: %m"); >+ >+ errs += buf_add(buf, &hdr, sizeof(hdr)); >+ errs += buf_add(buf, &mtu, sizeof(mtu)); >+ if (errs) >+ error("buf_add: %m"); >+ >+ if (buf_close(privfd, buf) == -1) >+ error("buf_close: %m"); >+} >+ >+void >+interface_set_mtu_priv(char *ifname, u_int16_t mtu) >+{ >+ struct ifreq ifr; >+ int sock; >+ >+ if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) >+ error("Can't create socket"); >+ >+ memset(&ifr, 0, sizeof(ifr)); >+ >+ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); >+ ifr.ifr_mtu = mtu; >+ >+ if (ioctl(sock, SIOCSIFMTU, &ifr) == -1) >+ warning("SIOCSIFMTU failed (%d): %s", mtu, >+ strerror(errno)); >+ close(sock); >+} >Index: sbin/dhclient/privsep.h >=================================================================== >--- sbin/dhclient/privsep.h >+++ sbin/dhclient/privsep.h >@@ -36,7 +36,8 @@ > IMSG_SCRIPT_WRITE_PARAMS, > IMSG_SCRIPT_GO, > IMSG_SCRIPT_GO_RET, >- IMSG_SEND_PACKET >+ IMSG_SEND_PACKET, >+ IMSG_SET_INTERFACE_MTU, > }; > > struct imsg_hdr { >Index: sbin/dhclient/privsep.c >=================================================================== >--- sbin/dhclient/privsep.c >+++ sbin/dhclient/privsep.c >@@ -111,6 +111,7 @@ > struct client_lease lease; > int ret, i, optlen; > struct buf *buf; >+ u_int16_t mtu; > > buf_read(fd, &hdr, sizeof(hdr)); > >@@ -235,6 +236,13 @@ > case IMSG_SEND_PACKET: > send_packet_priv(ifi, &hdr, fd); > break; >+ case IMSG_SET_INTERFACE_MTU: >+ if (hdr.len < sizeof(hdr) + sizeof(u_int16_t)) >+ error("corrupted message received"); >+ >+ buf_read(fd, &mtu, sizeof(u_int16_t)); >+ interface_set_mtu_priv(ifi->name, mtu); >+ break; > default: > error("received unknown message, code %d", hdr.code); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 208392
: 171088