[U-Boot-Users] question about net/net.c

Robin Getz rgetz at blackfin.uclinux.org
Thu Oct 21 18:43:56 CEST 2004


I had a question about the latest version of net/net.c

scenario is as follows.

1. u-boot initiates a tftp transfer
2. u-boot sets a flag "NetArpWaitPacketMAC = 1"
3. u-boot sends ARP Request on network to find the MAC address of tftp server
4. server is a little slow, and u-boot has not yet received the ARP so,
    u-boot sends ARP Request on network to find the MAC address of tftp server
5. tftp server responds back to first request with it's MAC address, and
    u-boot sees this, and accepts it.
6. u-boot sets the flag "NetArpWaitPacketMAC = 0" as it got the ARP reply
7. tftp server responds back to second request with it's MAC address, and
    u-boot sees this, and accepts it.

At this point as u-boot is not waiting (NetArpWaitPacketMAC is 0)
for ARP reply breaks out of the switch that handles ARP reply. But this
break is not to return from the complete handler and thus falls into
RARP handler code.

8. u-boot prints out "invalid RARP header".

This can be observed in net\net.c "NetReceive" function.

===============================================

void
NetReceive(volatile uchar * inpkt, int len)
{

[snip/snip]

         switch (x) {

         case PROT_ARP:
                 switch (ntohs(arp->ar_op)) {
                 case ARPOP_REQUEST:             /* reply with our IP 
address    */
                         return;

                 case ARPOP_REPLY:               /* arp reply */
                         /* are we waiting for a reply */
                         if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC)
                                 break;
                         return;
                 default:
                         return;
                 }

         case PROT_RARP:
                 break;


==================================================
am I missing something or shouldn't there be a break; above the 'case 
PROT_RARP:' to handle this?

Thanks
-Robin






More information about the U-Boot mailing list