Skip to content

Commit

Permalink
ipconfig: handle case of delayed DHCP server
Browse files Browse the repository at this point in the history
If a DHCP server is delayed, it's possible for the client to receive the 
DHCPOFFER after it has already sent out a new DHCPDISCOVER message from 
a second interface.  The client then sends out a DHCPREQUEST from the 
second interface, but the server doesn't recognize the device and 
rejects the request.

This patch simply tracks the current device being configured and throws 
away the OFFER if it is not intended for the current device.  A more 
sophisticated approach would be to put the OFFER information into the 
struct ic_device rather than storing it globally.

Signed-off-by: Chris Friesen <cfriesen@nortel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Chris Friesen authored and David S. Miller committed May 18, 2009
1 parent 5e39273 commit 2513dfb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions net/ipv4/ipconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ __be32 ic_servaddr = NONE; /* Boot server IP address */
__be32 root_server_addr = NONE; /* Address of NFS server */
u8 root_server_path[256] = { 0, }; /* Path to mount as root */

u32 ic_dev_xid; /* Device under configuration */

/* vendor class identifier */
static char vendor_class_identifier[253] __initdata;

Expand Down Expand Up @@ -932,6 +934,13 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
goto drop_unlock;
}

/* Is it a reply for the device we are configuring? */
if (b->xid != ic_dev_xid) {
if (net_ratelimit())
printk(KERN_ERR "DHCP/BOOTP: Ignoring delayed packet \n");
goto drop_unlock;
}

/* Parse extensions */
if (ext_len >= 4 &&
!memcmp(b->exten, ic_bootp_cookie, 4)) { /* Check magic cookie */
Expand Down Expand Up @@ -1115,6 +1124,9 @@ static int __init ic_dynamic(void)
get_random_bytes(&timeout, sizeof(timeout));
timeout = CONF_BASE_TIMEOUT + (timeout % (unsigned) CONF_TIMEOUT_RANDOM);
for (;;) {
/* Track the device we are configuring */
ic_dev_xid = d->xid;

#ifdef IPCONFIG_BOOTP
if (do_bootp && (d->able & IC_BOOTP))
ic_bootp_send_if(d, jiffies - start_jiffies);
Expand Down

0 comments on commit 2513dfb

Please sign in to comment.