[PATCH RFC] udhcpc: pad packets to work around broken routers
Johannes Stezenbach
js at sig21.net
Wed Oct 23 10:20:30 UTC 2013
Commit b8b72f02 removed all padding from DHCP packets
to fix operation with buggy servers which can't handle
maximum sized packets. But it introduced a regression
with buggy routers which drop DHCP packets smaller
than 300 bytes (i.e. 342 byte ethernet packets).
Add back some padding to work around.
Signed-off-by: Johannes Stezenbach <js at sig21.net>
---
This is the minimal patch which fixes the issue, but
I'm not sure about hardcoding the 300 byte size.
Maybe add a commandline parameter?
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index 33c9585..efee970 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -146,6 +146,12 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
*/
padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(packet.data.options);
+ /* work around issue with some routers which drop DHCP packets
+ * smaller than 300 bytes (342 byte eth packet)
+ */
+ if (DHCP_SIZE - padding < 300)
+ padding = DHCP_SIZE - 300;
+
packet.ip.protocol = IPPROTO_UDP;
packet.ip.saddr = source_nip;
packet.ip.daddr = dest_nip;
@@ -215,6 +221,13 @@ int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
udhcp_dump_packet(dhcp_pkt);
padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options);
+
+ /* work around issue with some routers which drop DHCP packets
+ * smaller than 300 bytes (342 byte eth packet)
+ */
+ if (DHCP_SIZE - padding < 300)
+ padding = DHCP_SIZE - 300;
+
result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding);
msg = "write";
ret_close:
More information about the busybox
mailing list