From fb809da2dfe9d715a02de7033ede46854d176c2e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 21 Nov 2007 04:48:18 +0000 Subject: Remove some assumptions about DHCP obtaining only a single options block. --- src/net/dhcpopts.c | 6 +++--- src/net/udp/dhcp.c | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/net') diff --git a/src/net/dhcpopts.c b/src/net/dhcpopts.c index c713909e0..d1837be3b 100644 --- a/src/net/dhcpopts.c +++ b/src/net/dhcpopts.c @@ -35,7 +35,7 @@ */ /** List of registered DHCP option blocks */ -static LIST_HEAD ( option_blocks ); +LIST_HEAD ( dhcp_option_blocks ); /** Registered DHCP option applicators */ static struct dhcp_option_applicator dhcp_option_applicators[0] @@ -259,7 +259,7 @@ struct dhcp_option * find_dhcp_option ( struct dhcp_option_block *options, if ( options ) { return find_dhcp_option_with_encap ( options, tag, NULL ); } else { - list_for_each_entry ( options, &option_blocks, list ) { + list_for_each_entry ( options, &dhcp_option_blocks, list ) { if ( ( option = find_dhcp_option ( options, tag ) ) ) return option; } @@ -283,7 +283,7 @@ void register_dhcp_options ( struct dhcp_option_block *options ) { options, options->priority ); /* Insert after any existing blocks which have a higher priority */ - list_for_each_entry ( existing, &option_blocks, list ) { + list_for_each_entry ( existing, &dhcp_option_blocks, list ) { if ( options->priority > existing->priority ) break; } diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c index 7de05ac1b..308044570 100644 --- a/src/net/udp/dhcp.c +++ b/src/net/udp/dhcp.c @@ -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 ) { -- cgit v1.2.3-55-g7522