aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/arpping.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-06-16 10:20:27 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-06-16 10:20:27 +0200
commit47f2d7ef7d4dbeea19a55f9d73ef826f9d06650f (patch)
treea84db8f0215526b9728f2f2b94214100e853a98c /networking/udhcp/arpping.c
parent1f363a086779152ab04067e81484b8bb69e4af72 (diff)
downloadbusybox-47f2d7ef7d4dbeea19a55f9d73ef826f9d06650f.tar.gz
udhcpd: don't fail ARP check if returned MAC matches client's one
Also, do not unicast replies to yiaddr. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/arpping.c')
-rw-r--r--networking/udhcp/arpping.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index b10bff651..fa0989d0f 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -41,7 +41,11 @@ enum {
/* Returns 1 if no reply received */
-int FAST_FUNC arpping(uint32_t test_ip, uint32_t from_ip, uint8_t *from_mac, const char *interface)
+int FAST_FUNC arpping(uint32_t test_ip,
+ const uint8_t *safe_mac,
+ uint32_t from_ip,
+ uint8_t *from_mac,
+ const char *interface)
{
int timeout_ms;
struct pollfd pfd[1];
@@ -73,7 +77,7 @@ int FAST_FUNC arpping(uint32_t test_ip, uint32_t from_ip, uint8_t *from_mac, con
arp.operation = htons(ARPOP_REQUEST); /* ARP op code */
memcpy(arp.sHaddr, from_mac, 6); /* source hardware address */
memcpy(arp.sInaddr, &from_ip, sizeof(from_ip)); /* source IP address */
- /* tHaddr is zero-fiiled */ /* target hardware address */
+ /* tHaddr is zero-filled */ /* target hardware address */
memcpy(arp.tInaddr, &test_ip, sizeof(test_ip)); /* target IP address */
memset(&addr, 0, sizeof(addr));
@@ -98,13 +102,24 @@ int FAST_FUNC arpping(uint32_t test_ip, uint32_t from_ip, uint8_t *from_mac, con
r = read(s, &arp, sizeof(arp));
if (r < 0)
break;
+
+ //bb_error_msg("sHaddr %02x:%02x:%02x:%02x:%02x:%02x",
+ // arp.sHaddr[0], arp.sHaddr[1], arp.sHaddr[2],
+ // arp.sHaddr[3], arp.sHaddr[4], arp.sHaddr[5]);
+
if (r >= ARP_MSG_SIZE
&& arp.operation == htons(ARPOP_REPLY)
/* don't check it: Linux doesn't return proper tHaddr (fixed in 2.6.24?) */
/* && memcmp(arp.tHaddr, from_mac, 6) == 0 */
&& *((uint32_t *) arp.sInaddr) == test_ip
) {
- rv = 0;
+ /* if ARP source MAC matches safe_mac
+ * (which is client's MAC), then it's not a conflict
+ * (client simply already has this IP and replies to ARPs!)
+ */
+ if (!safe_mac || memcmp(safe_mac, arp.sHaddr, 6) != 0)
+ rv = 0;
+ //else bb_error_msg("sHaddr == safe_mac");
break;
}
}