dhcpcd: Fix no lease acquired (truncated packet).
Upstream ticket: http://roy.marples.name/projects/dhcpcd/tktview?name=3f10c9b871 Upstream patch: http://roy.marples.name/projects/dhcpcd/info/3fd740f3ed Signed-off-by: Fredrik Rinnestam <fredrik@crux.nu>
This commit is contained in:
parent
82eb75ebae
commit
df64bc31ec
@ -1 +1,2 @@
|
|||||||
8c1340a53fd7e56d32bb6fef6e1354ee dhcpcd-6.11.0.tar.xz
|
8c1340a53fd7e56d32bb6fef6e1354ee dhcpcd-6.11.0.tar.xz
|
||||||
|
5c1e9f596840d38affc4bddbc5e6eeb6 dhcpcd-truncated-packet.patch
|
||||||
|
@ -5,12 +5,15 @@
|
|||||||
|
|
||||||
name=dhcpcd
|
name=dhcpcd
|
||||||
version=6.11.0
|
version=6.11.0
|
||||||
release=1
|
release=2
|
||||||
source=(http://roy.marples.name/downloads/dhcpcd/$name-$version.tar.xz)
|
source=(http://roy.marples.name/downloads/dhcpcd/$name-$version.tar.xz
|
||||||
|
dhcpcd-truncated-packet.patch)
|
||||||
|
|
||||||
build () {
|
build () {
|
||||||
cd $name-$version
|
cd $name-$version
|
||||||
|
|
||||||
|
patch -p0 <$SRC/dhcpcd-truncated-packet.patch
|
||||||
|
|
||||||
./configure --prefix= \
|
./configure --prefix= \
|
||||||
--libexecdir=/lib/dhcpcd \
|
--libexecdir=/lib/dhcpcd \
|
||||||
--dbdir=/var/lib/dhcpcd \
|
--dbdir=/var/lib/dhcpcd \
|
||||||
@ -18,7 +21,7 @@ build () {
|
|||||||
--os=linux \
|
--os=linux \
|
||||||
--with-hooks=
|
--with-hooks=
|
||||||
|
|
||||||
make
|
make
|
||||||
make DESTDIR=$PKG install
|
make DESTDIR=$PKG install
|
||||||
chmod -R u+w $PKG
|
chmod -R u+w $PKG
|
||||||
}
|
}
|
||||||
|
77
dhcpcd/dhcpcd-truncated-packet.patch
Normal file
77
dhcpcd/dhcpcd-truncated-packet.patch
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
Index: dhcp.c
|
||||||
|
==================================================================
|
||||||
|
--- dhcp.c
|
||||||
|
+++ dhcp.c
|
||||||
|
@@ -1082,13 +1082,16 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
*p++ = DHO_END;
|
||||||
|
len = (size_t)(p - (uint8_t *)bootp);
|
||||||
|
|
||||||
|
- /* Pad out to the BOOTP minimum message length.
|
||||||
|
- * Some DHCP servers incorrectly require this. */
|
||||||
|
- while (len < BOOTP_MESSAGE_LENTH_MIN) {
|
||||||
|
+ /* Pad out to the BOOTP message length.
|
||||||
|
+ * Even if we send a DHCP packet with a variable length vendor area,
|
||||||
|
+ * some servers / relay agents don't like packets smaller than
|
||||||
|
+ * a BOOTP message which is fine because that's stipulated
|
||||||
|
+ * in RFC1542 section 2.1. */
|
||||||
|
+ while (len < sizeof(*bootp)) {
|
||||||
|
*p++ = DHO_PAD;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ifo->auth.options & DHCPCD_AUTH_SEND && auth_len != 0)
|
||||||
|
@@ -3134,18 +3137,30 @@
|
||||||
|
{
|
||||||
|
logger(ifp->ctx, LOG_WARNING,
|
||||||
|
"%s: server %s is not destination",
|
||||||
|
ifp->name, inet_ntoa(from));
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+ /*
|
||||||
|
+ * DHCP has a variable option area rather than a fixed
|
||||||
|
+ * vendor area.
|
||||||
|
+ * Because DHCP uses the BOOTP protocol it should
|
||||||
|
+ * still send BOOTP sized packets to be RFC compliant.
|
||||||
|
+ * However some servers send a truncated vendor area.
|
||||||
|
+ * dhcpcd can work fine without the vendor area being sent.
|
||||||
|
+ */
|
||||||
|
bytes = get_udp_data(&bootp, buf);
|
||||||
|
- if (bytes < sizeof(struct bootp)) {
|
||||||
|
+ if (bytes < offsetof(struct bootp, vend)) {
|
||||||
|
logger(ifp->ctx, LOG_ERR,
|
||||||
|
"%s: truncated packet (%zu) from %s",
|
||||||
|
ifp->name, bytes, inet_ntoa(from));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
+ /* But to make our IS_DHCP macro easy, ensure the vendor
|
||||||
|
+ * area has at least 4 octets. */
|
||||||
|
+ while (bytes < offsetof(struct bootp, vend) + 4)
|
||||||
|
+ bootp[bytes++] = '\0';
|
||||||
|
+
|
||||||
|
dhcp_handledhcp(ifp, (struct bootp *)bootp, bytes, &from);
|
||||||
|
if (state->raw_fd == -1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Index: dhcp.h
|
||||||
|
==================================================================
|
||||||
|
--- dhcp.h
|
||||||
|
+++ dhcp.h
|
||||||
|
@@ -129,13 +129,10 @@
|
||||||
|
FQDN_NONE = 0x18,
|
||||||
|
FQDN_PTR = 0x20,
|
||||||
|
FQDN_BOTH = 0x31
|
||||||
|
};
|
||||||
|
|
||||||
|
-/* Some crappy DHCP servers require the BOOTP minimum length */
|
||||||
|
-#define BOOTP_MESSAGE_LENTH_MIN 300
|
||||||
|
-
|
||||||
|
/* Don't import common.h as that defines __unused which causes problems
|
||||||
|
* on some Linux systems which define it as part of a structure */
|
||||||
|
#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
|
||||||
|
# ifndef __packed
|
||||||
|
# define __packed __attribute__((__packed__))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user