aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Anderson <seanga2@gmail.com>2023-10-14 16:47:53 -0400
committerTom Rini <trini@konsulko.com>2023-10-17 20:50:52 -0400
commitacb96c170d7c9f9aed1755efe56387127a7dff0b (patch)
treea57e7e21af287fa87145d0424e96e3f23b1b7549
parent7ccc6044e964829459fa089da01b742a442df65e (diff)
downloadu-boot-acb96c170d7c9f9aed1755efe56387127a7dff0b.zip
u-boot-acb96c170d7c9f9aed1755efe56387127a7dff0b.tar.gz
u-boot-acb96c170d7c9f9aed1755efe56387127a7dff0b.tar.bz2
net: bootp: Fall back to BOOTP from DHCP when unit testing
If we sent a DHCP packet and get a BOOTP response from the server, we shouldn't try to send a DHCPREQUEST packet, since it won't be DHCPACKed. Transition straight to BIND. This is only enabled for UNIT_TEST to avoid bloat, since I suspect the number of BOOTP servers in the wild is vanishingly small. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--net/bootp.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/bootp.c b/net/bootp.c
index 2053cce..7b0f45e 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -1073,6 +1073,11 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
CONFIG_SYS_BOOTFILE_PREFIX,
strlen(CONFIG_SYS_BOOTFILE_PREFIX)) == 0) {
#endif /* CONFIG_SYS_BOOTFILE_PREFIX */
+ if (CONFIG_IS_ENABLED(UNIT_TEST) &&
+ dhcp_message_type((u8 *)bp->bp_vend) == -1) {
+ debug("got BOOTP response; transitioning to BOUND\n");
+ goto dhcp_got_bootp;
+ }
dhcp_packet_process_options(bp);
if (CONFIG_IS_ENABLED(EFI_LOADER) &&
IS_ENABLED(CONFIG_NETDEVICES))
@@ -1099,6 +1104,7 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
debug("DHCP State: REQUESTING\n");
if (dhcp_message_type((u8 *)bp->bp_vend) == DHCP_ACK) {
+dhcp_got_bootp:
dhcp_packet_process_options(bp);
/* Store net params from reply */
store_net_params(bp);