[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: dhcp: keep padding packets to 300 bytes as per RFC 1542
From: "Vladislav Grishenko" <themiron () mail ! ru>
Date: 2013-08-30 7:59:25
Message-ID: 001a01cea556$d9b79260$8d26b720$ () mail ! ru
[Download RAW message or body]
This is a multipart message in MIME format.
Hi Denys,
We've discovered a number of dhcp servers and relays check minimal dhcp
packet size and drops anything less than 300 octets long as per RFC 1542.
After commit "b8b72f02 dhcp: truncate packets instead of padding them to 574
bytes. closes bug 1849" dhcpc/dhcpd could generate packets with size less
than 300 bytes (bootp header + options), and under the circumstances above
they all will be dropped by that servers/firewalls/relays.
Refer patch against master attached.
Best Regards, Vladislav Grishenko
["0001-dhcp-keep-padding-packets-to-300-bytes-as-per-RFC-15.patch" (application/octet-stream)]
From c4764a19cb153dc0495c50d76606bc12e54f1185 Mon Sep 17 00:00:00 2001
From: Vladislav Grishenko <themiron@mail.ru>
Date: Fri, 30 Aug 2013 13:25:17 +0600
Subject: [PATCH] dhcp: keep padding packets to 300 bytes as per RFC 1542
function old new delta
udhcp_send_kernel_packet 251 272 +21
udhcp_send_raw_packet 445 448 +3
Signed-off-by: Vladislav Grishenko <themiron@mail.ru>
---
networking/udhcp/common.h | 3 +++
networking/udhcp/packet.c | 2 ++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index 0e8e45f..bc44b84 100644
--- a/networking/udhcp/common.h
+++ b/networking/udhcp/common.h
@@ -25,6 +25,9 @@ extern const uint8_t MAC_BCAST_ADDR[6] ALIGN2; /* six all-ones */
#define BOOTREQUEST 1
#define BOOTREPLY 2
+/* Minimal BOOTP message size. See RFC 1542 */
+#define DHCP_MIN_SIZE 300
+
//TODO: rename ciaddr/yiaddr/chaddr
struct dhcp_packet {
uint8_t op; /* BOOTREQUEST or BOOTREPLY */
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index 33c9585..277887c 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -145,6 +145,7 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
* we truncate packets after end option byte.
*/
padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(packet.data.options);
+ padding = MIN(DHCP_SIZE - DHCP_MIN_SIZE, padding);
packet.ip.protocol = IPPROTO_UDP;
packet.ip.saddr = source_nip;
@@ -215,6 +216,7 @@ 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);
+ padding = MIN(DHCP_SIZE - DHCP_MIN_SIZE, padding);
result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding);
msg = "write";
ret_close:
--
1.7.2.5
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic