[patch]: zcip: Fix for link local IP conflict detection

Ken Sharp ken.sharp at ni.com
Fri Dec 14 20:05:24 UTC 2012


This is my first patch submission to busybox so if there is any changes I 
need to make or I did something wrong please let me know.

I found a bug during link local IP resolution.  If a regular ARP request 
is received during the ARP probe period it will incorrectly cause a target 
IP conflict.  This then leads to a new IP being picked unnecessarily.

Here's how I reproduced it:
- Connect two machines via a crossover cable or on a network with no DHCP 
server available.
- Continuously ping the machine running busybox from the other
- Reboot the busybox machine (the one being pinged)
- When the busybox machine comes back up it will have a different IP 
address because of the incorrect target IP conflict

I tested my fix on an ARM A9 based board.

Regards,
Ken Sharp


Here's my patch:

diff -urN a/networking/zcip.c b/networking/zcip.c
--- a/networking/zcip.c 2012-12-14 12:11:07.858998337 -0600
+++ b/networking/zcip.c 2012-12-14 13:12:46.508094320 -0600
@@ -506,9 +506,18 @@
                        ) {
                                source_ip_conflict = 1;
                        }
+
+                       /*
+                        * According to RFC 3927, section 2.2.1:
+                        * Check if packet is an ARP probe by checking for 
a null source IP
+                        * then check that target IP is equal to ours and 
source hw addr
+                        * is not equal to ours. This condition should 
cause a conflict only
+                        * during probe.
+                        */
                        if (p.arp.arp_op == htons(ARPOP_REQUEST)
+                        && memcmp(p.arp.arp_spa, &null_ip, sizeof(struct 
in_addr)) == 0
                         && memcmp(p.arp.arp_tpa, &ip.s_addr, 
sizeof(struct in_addr)) == 0
-                        && memcmp(&p.arp.arp_tha, &eth_addr, ETH_ALEN) != 
0
+                        && memcmp(&p.arp.arp_sha, &eth_addr, ETH_ALEN) != 
0
                        ) {
                                target_ip_conflict = 1;
                        }




More information about the busybox mailing list