Remove some assumptions about DHCP obtaining only a single options block.

This commit is contained in:
Michael Brown
2007-11-21 04:48:18 +00:00
parent 8d18338ae7
commit fb809da2df
4 changed files with 23 additions and 14 deletions

View File

@@ -1006,14 +1006,18 @@ int dhcp_configure_netdev ( struct net_device *netdev,
struct in_addr gateway = { INADDR_NONE };
int rc;
/* Clear any existing routing table entry */
del_ipv4_address ( netdev );
/* Retrieve IP address configuration */
find_dhcp_ipv4_option ( options, DHCP_EB_YIADDR, &address );
find_dhcp_ipv4_option ( options, DHCP_SUBNET_MASK, &netmask );
find_dhcp_ipv4_option ( options, DHCP_ROUTERS, &gateway );
/* Do nothing unless we have at least an IP address to use */
if ( ! address.s_addr )
return 0;
/* Clear any existing routing table entry */
del_ipv4_address ( netdev );
/* Set up new IP address configuration */
if ( ( rc = add_ipv4_address ( netdev, address, netmask,
gateway ) ) != 0 ) {