From d63fa3c3612c11f9c1484eec7e5e4e067fcfed3b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20H=C3=A4rdeman?= Date: Tue, 7 Oct 2025 09:49:10 +0200 Subject: [PATCH] dhcpv4: shrink struct dhcpv4_message MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The options padding can now be removed. Signed-off-by: David Härdeman Link: https://github.com/openwrt/odhcpd/pull/278 Signed-off-by: Álvaro Fernández Rojas --- src/dhcpv4.c | 4 ++-- src/dhcpv4.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dhcpv4.c b/src/dhcpv4.c index bc45ee6..509f9e7 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -219,7 +219,7 @@ static void dhcpv4_fr_send(struct dhcp_assignment *a) uint8_t fr_end = DHCPV4_OPT_END; struct iovec iov[IOV_FR_TOTAL] = { - [IOV_FR_HEADER] = { &fr, offsetof(typeof(fr), options) }, + [IOV_FR_HEADER] = { &fr, sizeof(fr) }, [IOV_FR_MESSAGE] = { &fr_msg, sizeof(fr_msg) }, [IOV_FR_AUTH] = { &fr_auth, 0 }, [IOV_FR_AUTH_BODY] = { &fr_auth_body, 0 }, @@ -784,7 +784,7 @@ void dhcpv4_handle_msg(void *src_addr, void *data, size_t len, size_t reply_opts_len = 0; struct iovec iov[IOV_TOTAL] = { - [IOV_HEADER] = { &reply, offsetof(typeof(reply), options) }, + [IOV_HEADER] = { &reply, sizeof(reply) }, [IOV_MESSAGE] = { &reply_msg, sizeof(reply_msg) }, [IOV_SERVERID] = { &reply_serverid, sizeof(reply_serverid) }, [IOV_NETMASK] = { &reply_netmask, 0 }, diff --git a/src/dhcpv4.h b/src/dhcpv4.h index 4f4679f..c3a9bcd 100644 --- a/src/dhcpv4.h +++ b/src/dhcpv4.h @@ -94,7 +94,7 @@ struct dhcpv4_message { char sname[64]; char file[128]; uint32_t cookie; - uint8_t options[308]; + uint8_t options[]; } _packed; // RFC2131, §3 -- 2.30.2