summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/include/ipxe/ip.h2
-rw-r--r--src/net/ipv4.c2
-rw-r--r--src/net/udp/dhcp.c7
3 files changed, 10 insertions, 1 deletions
diff --git a/src/include/ipxe/ip.h b/src/include/ipxe/ip.h
index 4366d9ab..ca508e27 100644
--- a/src/include/ipxe/ip.h
+++ b/src/include/ipxe/ip.h
@@ -86,4 +86,6 @@ extern struct list_head ipv4_miniroutes;
extern struct net_protocol ipv4_protocol __net_protocol;
+extern int ipv4_has_any_addr ( struct net_device *netdev );
+
#endif /* _IPXE_IP_H */
diff --git a/src/net/ipv4.c b/src/net/ipv4.c
index 08249d41..791d4195 100644
--- a/src/net/ipv4.c
+++ b/src/net/ipv4.c
@@ -408,7 +408,7 @@ static int ipv4_tx ( struct io_buffer *iobuf,
* @v netdev Network device
* @ret has_any_addr Network device has any IPv4 address
*/
-static int ipv4_has_any_addr ( struct net_device *netdev ) {
+int ipv4_has_any_addr ( struct net_device *netdev ) {
struct ipv4_miniroute *miniroute;
list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c
index 10482e94..9a231840 100644
--- a/src/net/udp/dhcp.c
+++ b/src/net/udp/dhcp.c
@@ -941,6 +941,13 @@ int dhcp_create_packet ( struct dhcp_packet *dhcppkt,
&dhcphdr->flags );
memcpy ( dhcphdr->options, options, options_len );
+ /* If the network device already has an IPv4 address then
+ * unicast responses from the DHCP server may be rejected, so
+ * request broadcast responses.
+ */
+ if ( ipv4_has_any_addr ( netdev ) )
+ dhcphdr->flags |= htons ( BOOTP_FL_BROADCAST );
+
/* Initialise DHCP packet structure */
memset ( dhcppkt, 0, sizeof ( *dhcppkt ) );
dhcppkt_init ( dhcppkt, data, max_len );