[#4949] dhcpcd-new w/ mutliple cards

Document created by Aaronwu Employee on Aug 30, 2013
Version 1Show Document
  • View in full screen mode

[#4949] dhcpcd-new w/ mutliple cards

Submitted By: Jason Hennigar

Open Date

2009-03-02 19:37:35    

Priority:

Low     Assignee:

Nobody

Status:

Open     Fixed In Release:

N/A

Found In Release:

2008R1.5-RC3     Release:

2008r1.5-rc3

Category:

Networking     Board:

STAMP

Processor:

BF537     Silicon Revision:

Is this bug repeatable?:

Yes     Resolution:

N/A

Uboot version or rev.:

1.1.6     Toolchain version or rev.:

2008R1.5-rc14

App binary format:

N/A     

Summary: dhcpcd-new w/ mutliple cards

Details:

 

When multiple cards are powered up at the same instant the DHCP transaction ID used in the REQUEST message can be identical for all cards. The DHCP server broadcasts an OFFER message with a unique IP for each MAC. The dhcpcd-new client does not verify that the MAC address in the OFFER is it's MAC. The DhcpMsgRecv.chaddr should be compared to the ClientHwAddr and if they don't match then the OFFER should be ignored. Right now all the cards with the same transaction ID will send a REQUEST for the same IP. The DHCP server only ACKs one of the MAC addresses but all the cards pick up that IP address.

 

In addition it would be worth while to incorporate both the time and the MAC address when seeding the random number generator.

 

Cheers!

Jason

 

Follow-ups

 

--- Jason Hennigar                                           2009-03-03 12:33:27

The diff of the solution that I have implemented is as follows:

 

svn diff user/dhcpcd-new/client.c

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

--- client.c

+++ client.c    (working copy)

@@ -65,7 +65,7 @@

extern int             ReplResolvConf;

extern int             SetDomainName;

extern int             SetHostName;

-extern unsigned short  ip_id;

+extern unsigned int    ip_id;

extern  void           *(*currState)();

extern  time_t          TimeOut;

extern  unsigned        nleaseTime;

@@ -562,6 +562,7 @@

          DhcpMsgRecv = (dhcpMessage

*)&UdpIpMsgRecv.udpipmsg[(ipRecv_local.ip_hl<<2)+sizeof(struct

udphdr)];

          if ( DhcpMsgRecv->htype != ARPHRD_ETHER ) continue;

          if ( DhcpMsgRecv->xid != xid ) continue;

+         if ( memcmp(DhcpMsgRecv->chaddr, ClientHwAddr, ETH_ALEN) != 0)

continue;

          if ( DhcpMsgRecv->op != DHCP_BOOTREPLY ) continue;

          if ( parseDhcpMsgRecv() == msg ) return 0;

          if ( *(unsigned char *)DhcpOptions.val[dhcpMessageType] == DHCP_NAK

)

@@ -1250,7 +1251,13 @@

void *dhcpStart()

{

   openSocket();

-  ip_id=time(NULL)&0xffff;

+  /* Seed the random number generator. Shifting is used so that this code is

*

+   * portable to systems that support both 2 byte and 4 byte unsigned ints.

*/

+  ip_id = (unsigned int)(((ClientHwAddr[2] << 24) & 0xFF000000) +

+                         ((ClientHwAddr[3] << 16) & 0x00FF0000) +

+                         ((ClientHwAddr[4] << 8) & 0x0000FF00) +

+                         ((ClientHwAddr[5]) & 0x000000FF) +

+                         (time(NULL)&0xFFFFFFFF));

   srandom(ip_id);

#ifdef CONFIG_LEDMAN

   if ( ledman_led >= 0 )

 

Cheers!

Jason

 

 

 

    Files

    Changes

    Commits

    Dependencies

    Duplicates

    Associations

    Tags

 

File Name     File Type     File Size     Posted By

No Files Were Found

Attachments

    Outcomes