[patch] cope with buggy dhcp servers
Cristian Ionescu-Idbohrn
cristian.ionescu-idbohrn at axis.com
Sun Nov 25 00:21:07 UTC 2007
On Sat, 24 Nov 2007, Denys Vlasenko wrote:
> +#define UDHCP_UDP_PACKET_SIZE_MIN ((sizeof(struct udp_dhcp_packet)) - \
> + (CONFIG_UDHCP_OPTIONS_SLACK_FOR_BUGGY_SERVERS))
> +
> /* Let's see whether compiler understood us right */
> struct BUG_bad_sizeof_struct_udp_dhcp_packet {
> char BUG_bad_sizeof_struct_udp_dhcp_packet
> - [sizeof(struct udp_dhcp_packet) != 576 ? -1 : 1];
> + [sizeof(struct udp_dhcp_packet) !=
> + ((UDHCP_UDP_PACKET_SIZE_MIN) +
> + (CONFIG_UDHCP_OPTIONS_SLACK_FOR_BUGGY_SERVERS)) ? -1 : 1];
>
> This check as written above can never fail.
Yes.
> The check should have literal 576 - we are checking than neither we nor
> compiler goof up.
That's fine.
> Maximum allowed slack size seems to be wrong, should be 1500 - 576 = 924.
Double checked, and you're right.
> See attached patch.
>
> I changed the default from 0 to 300, it doesn't seem to have any effect
> on code size:
That should not be necessary. 0 shuld be fine in most cases.
> $ make bloatcheck
> function old new delta
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0) Total: 0 bytes
> text data bss dec hex filename
> 776551 929 9100 786580 c0094 busybox_old
> 776551 929 9100 786580 c0094 busybox_unstripped
>
> Please test whether patch works for you.
I'll do that as soon as possible. I have to get my hands on one of those
routers.
This comment:
+ maximum size of entire IP packet, and sends packets which are
+ 268 bytes too large.
does not seem to match the real behaviour. The packet size difference
is _exactly_ 28 bytes:
I: sizeof(struct struct dhcpMessage): 548
I: sizeof(struct iphdr): 20
I: sizeof(struct udphdr): 8
I: sizeof(struct udp_dhcp_packet): 576
It looks like they confuse the dhcpMessage and udp_dhcp_packet sizes.
There also seems to be whitespace damage in Config.in (plain space
characters instead of 'TAB, space, space' in your patch).
Cheers,
--
Cristian
More information about the busybox
mailing list