[PATCH] add IP check functionality to udhcpc

Denys Vlasenko vda.linux at googlemail.com
Wed Nov 21 14:36:57 PST 2007


On Wednesday 21 November 2007 05:30, Jonas Danielsson wrote:
> Hi,
>
> as part of a project at Axis I've modified the busybox udhcp client to
> make it perform a final check of
> the offered IP.
>
> The final check is mentioned in the DHCP rfc as:
>
>   The client SHOULD perform a check on the suggested address to
>   ensure that the address is not already in use.  For example, if the
>   client is on a network that supports ARP, the client may issue an
>   ARP request for the suggested request.  When broadcasting an ARP
>   request for the suggested address, the client must fill in its own
>   hardware address as the sender's hardware address, and 0 as the
>   sender's IP address, to avoid confusing ARP caches in other hosts
>   on the same subnet.  If the network address appears to be in use,
>   the client MUST send a DHCPDECLINE message to the server. The
>   client SHOULD broadcast an ARP reply to announce the client's new
>   IP address and clear any outdated ARP cache entries in hosts on the
>   client's subnet.
>
> I've added a CONFIGURE_FEATURE_UDHCPC_ARPING to enable this
> functionality and
> command-line-options -a, --arping to use it. I've also added a -W,
> --wait to set how long to wait after sending
> the DHCPDECLINE before restarting the discovery process (minimum 10
> seconds).
>
> The client uses the arpping function from arpping.c. And I've modified
> the arpping function.
> Why? The arpping-function performed validation on the arp reply by
> checking the target hardware address field in
> the arp reply against the client mac address. This will not work when
> working with Linux machines.
>
> When the Linux kernel receives an arp probe (arp request with sender ip
> 0) it will return an arp reply with the target ip field and target
> hardware field set to the same as the source fields. I've sent a patch
> to the Linux kernel to fix this, the discussion about it
> can be seen here: http://thread.gmane.org/gmane.linux.kernel/603586. The
> patch has been applied to David Millers tree.
>
> In the discussion I mention the check performed in udhcp arping (and
> also dhcpcd from Debian) and got the following response from Alexey
> Kuznetov:
> "Do not do this. Mainly, because you already know that this does not work
>  with linux. :-) Logically, target hw address in arp reply is just
>  a nonsensial redundancy, it should not be checked and even looked at."
>
> So the check of target hardware address in arpping has been removed in
> my patch.
>
> Revision used: The patch is from the daily snapshot from 071120.
>
> Is this something you would consider to apply?


Had to edit it quite a bit. You added #include's which were not needed.
You removed memcmp without explaining why.
send_decline()'s stype was different from surrounding code.

+static int arpcheck = 0;
+static int decline_wait = 10;

These statics are not needed, local variables will work as well.

I fixed these things, and possibly added my own bugs ;)

Please test attached patch, is it still doing what you need?

Question: do you really need "-W seconds"?
Why not reuse "-A seconds" value?
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2.patch
Type: text/x-diff
Size: 17108 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20071121/9fba32ed/attachment-0001.bin 


More information about the busybox mailing list