]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - net/link_local.c
dm: tegra: Set up a pre-reloc malloc()
[karo-tx-uboot.git] / net / link_local.c
index 582d0115b7673d7c9fabc11dfdafa20300d80815..4152fae5bacba34c051bf2f877a11d435630325e 100644 (file)
@@ -103,7 +103,7 @@ static void configure_wait(void)
 void link_local_start(void)
 {
        ip = getenv_IPaddr("llipaddr");
-       if (ip != 0 && (ip & IN_CLASSB_NET) != LINKLOCAL_ADDR) {
+       if (ip != 0 && (ntohl(ip) & IN_CLASSB_NET) != LINKLOCAL_ADDR) {
                puts("invalid link address");
                net_set_state(NETLOOP_FAIL);
                return;
@@ -206,6 +206,7 @@ void link_local_receive_arp(struct arp_hdr *arp, int len)
 {
        int source_ip_conflict;
        int target_ip_conflict;
+       IPaddr_t null_ip = 0;
 
        if (state == DISABLED)
                return;
@@ -225,12 +226,13 @@ void link_local_receive_arp(struct arp_hdr *arp, int len)
                        timeout_ms = diff | 1; /* never 0 */
                }
        }
-/*
- * XXX Don't bother with ethernet link just yet
+#if 0
+ /* XXX Don't bother with ethernet link just yet */
        if ((fds[0].revents & POLLIN) == 0) {
                if (fds[0].revents & POLLERR) {
-                       // FIXME: links routinely go down;
-                       // this shouldn't necessarily exit.
+                       /*
+                        * FIXME: links routinely go down;
+                        */
                        bb_error_msg("iface %s is down", eth_get_name());
                        if (ready) {
                                run(argv, "deconfig", &ip);
@@ -239,7 +241,7 @@ void link_local_receive_arp(struct arp_hdr *arp, int len)
                }
                continue;
        }
-*/
+#endif
 
        debug_cond(DEBUG_INT_STATE, "%s recv arp type=%d, op=%d,\n",
                eth_get_name(), ntohs(arp->ar_pro),
@@ -266,10 +268,18 @@ void link_local_receive_arp(struct arp_hdr *arp, int len)
        ) {
                source_ip_conflict = 1;
        }
-       if (arp->ar_op == htons(ARPOP_REQUEST)
-        && memcmp(&arp->ar_tpa, &ip, ARP_PLEN) == 0
-        && memcmp(&arp->ar_tha, NetOurEther, ARP_HLEN) != 0
-       ) {
+
+       /*
+        * 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 (arp->ar_op == htons(ARPOP_REQUEST) &&
+           memcmp(&arp->ar_spa, &null_ip, ARP_PLEN) == 0 &&
+           memcmp(&arp->ar_tpa, &ip, ARP_PLEN) == 0 &&
+           memcmp(&arp->ar_sha, NetOurEther, ARP_HLEN) != 0) {
                target_ip_conflict = 1;
        }