X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=net%2Fbootp.c;h=de3dab4114d92b25bd0a58f2ea422add414fe9b9;hb=2fa581ba910368d0f7f995fb906d6c5e4218b594;hp=579515687b7567e0e2069ff316ac60129f0da846;hpb=382bee57f19b4454e2015bc19a010bc2d0ab9337;p=oweals%2Fu-boot.git diff --git a/net/bootp.c b/net/bootp.c index 579515687b..de3dab4114 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -9,12 +9,17 @@ */ #include +#include #include +#include #include +#include #include +#include +#include +#include #include #include "bootp.h" -#include "nfs.h" #ifdef CONFIG_LED_STATUS #include #endif @@ -148,9 +153,14 @@ static void store_net_params(struct bootp_hdr *bp) { #if !defined(CONFIG_BOOTP_SERVERIP) struct in_addr tmp_ip; + bool overwrite_serverip = true; + +#if defined(CONFIG_BOOTP_PREFER_SERVERIP) + overwrite_serverip = false; +#endif net_copy_ip(&tmp_ip, &bp->bp_siaddr); - if (tmp_ip.s_addr != 0) + if (tmp_ip.s_addr != 0 && (overwrite_serverip || !net_server_ip.s_addr)) net_copy_ip(&net_server_ip, &bp->bp_siaddr); memcpy(net_server_ethaddr, ((struct ethernet_hdr *)net_rx_packet)->et_src, 6); @@ -158,7 +168,8 @@ static void store_net_params(struct bootp_hdr *bp) #if defined(CONFIG_CMD_DHCP) !(dhcp_option_overload & OVERLOAD_FILE) && #endif - (strlen(bp->bp_file) > 0)) { + (strlen(bp->bp_file) > 0) && + !net_boot_file_name_explicit) { copy_filename(net_boot_file_name, bp->bp_file, sizeof(net_boot_file_name)); } @@ -334,7 +345,7 @@ static void bootp_process_vendor(u8 *ext, int size) debug("net_nis_domain : %s\n", net_nis_domain); #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER) - if (net_ntp_server) + if (net_ntp_server.s_addr) debug("net_ntp_server : %pI4\n", &net_ntp_server); #endif } @@ -387,12 +398,19 @@ static void bootp_timeout_handler(void) if (time_taken >= time_taken_max) { #ifdef CONFIG_BOOTP_MAY_FAIL - puts("\nRetry time exceeded\n"); - net_set_state(NETLOOP_FAIL); -#else - puts("\nRetry time exceeded; starting again\n"); - net_start_again(); + char *ethrotate; + + ethrotate = env_get("ethrotate"); + if ((ethrotate && strcmp(ethrotate, "no") == 0) || + net_restart_wrap) { + puts("\nRetry time exceeded\n"); + net_set_state(NETLOOP_FAIL); + } else #endif + { + puts("\nRetry time exceeded; starting again\n"); + net_start_again(); + } } else { bootp_timeout *= 2; if (bootp_timeout > 2000) @@ -414,7 +432,7 @@ static void bootp_timeout_handler(void) static u8 *add_vci(u8 *e) { char *vci = NULL; - char *env_vci = getenv("bootp_vci"); + char *env_vci = env_get("bootp_vci"); #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_NET_VCI_STRING) vci = CONFIG_SPL_NET_VCI_STRING; @@ -488,7 +506,7 @@ static int dhcp_extended(u8 *e, int message_type, struct in_addr server_ip, *e++ = tmp & 0xff; } #if defined(CONFIG_BOOTP_SEND_HOSTNAME) - hostname = getenv("hostname"); + hostname = env_get("hostname"); if (hostname) { int hostnamelen = strlen(hostname); @@ -503,8 +521,8 @@ static int dhcp_extended(u8 *e, int message_type, struct in_addr server_ip, clientarch = CONFIG_BOOTP_PXE_CLIENTARCH; #endif - if (getenv("bootp_arch")) - clientarch = getenv_ulong("bootp_arch", 16, clientarch); + if (env_get("bootp_arch")) + clientarch = env_get_ulong("bootp_arch", 16, clientarch); if (clientarch > 0) { *e++ = 93; /* Client System Architecture */ @@ -520,7 +538,7 @@ static int dhcp_extended(u8 *e, int message_type, struct in_addr server_ip, *e++ = 0; /* minor revision */ #ifdef CONFIG_LIB_UUID - uuid = getenv("pxeuuid"); + uuid = env_get("pxeuuid"); if (uuid) { if (uuid_str_valid(uuid)) { @@ -713,7 +731,7 @@ void bootp_request(void) dhcp_state = INIT; #endif - ep = getenv("bootpretryperiod"); + ep = env_get("bootpretryperiod"); if (ep != NULL) time_taken_max = simple_strtoul(ep, NULL, 10); else @@ -883,10 +901,13 @@ static void dhcp_process_options(uchar *popt, uchar *end) case 66: /* Ignore TFTP server name */ break; case 67: /* Bootfile option */ - size = truncate_sz("Bootfile", - sizeof(net_boot_file_name), oplen); - memcpy(&net_boot_file_name, popt + 2, size); - net_boot_file_name[size] = 0; + if (!net_boot_file_name_explicit) { + size = truncate_sz("Bootfile", + sizeof(net_boot_file_name), + oplen); + memcpy(&net_boot_file_name, popt + 2, size); + net_boot_file_name[size] = 0; + } break; default: #if defined(CONFIG_BOOTP_VENDOREX)