]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: Enhancements for dhcp option 209
authorSean Edmond <seanedmond@microsoft.com>
Thu, 9 May 2024 02:39:01 +0000 (19:39 -0700)
committerTom Rini <trini@konsulko.com>
Fri, 23 May 2025 17:28:51 +0000 (11:28 -0600)
- Enable option 209 by default
- Set pxelinux_configfile to NULL to avoid potential double free
- change hardcoded 209 to a define

Signed-off-by: Sean Edmond <seanedmond@microsoft.com>
cmd/Kconfig
cmd/pxe.c
net/bootp.c
net/bootp.h

index c182d73ddbd7dc779b1d687d6bfc5a04b49318eb..54c4ab8570c4530a44fad1345b86a87016f78981 100644 (file)
@@ -1898,6 +1898,7 @@ config BOOTP_PXE_CLIENTARCH
 
 config BOOTP_PXE_DHCP_OPTION
        bool "Request & store 'pxe_configfile' from BOOTP/DHCP server"
+       default y
        depends on BOOTP_PXE
 
 config BOOTP_VCI_STRING
index 21134eb7a304646ad305eaac48bd289b8be5a8d8..9404f4451870ec5fcf0faecd92ec4f1e5e8c9b37 100644 (file)
--- a/cmd/pxe.c
+++ b/cmd/pxe.c
@@ -65,6 +65,8 @@ static int pxe_dhcp_option_path(struct pxe_context *ctx, unsigned long pxefile_a
        int ret = get_pxe_file(ctx, pxelinux_configfile, pxefile_addr_r);
 
        free(pxelinux_configfile);
+       /* set to NULL to avoid double-free if DHCP is tried again */
+       pxelinux_configfile = NULL;
 
        return ret;
 }
index c15472f5d37f33d5506086dfda0f3c8d94ee6fdd..b9e3cccb4f95429d6384ff2080e9317cb06f747c 100644 (file)
@@ -603,7 +603,7 @@ static int dhcp_extended(u8 *e, int message_type, struct in_addr server_ip,
        *cnt += 1;
 #endif
        if (IS_ENABLED(CONFIG_BOOTP_PXE_DHCP_OPTION)) {
-               *e++ = 209;     /* PXELINUX Config File */
+               *e++ = DHCP_OPTION_PXE_CONFIG_FILE;     /* PXELINUX Config File */
                *cnt += 1;
        }
        /* no options, so back up to avoid sending an empty request list */
@@ -922,7 +922,7 @@ static void dhcp_process_options(uchar *popt, uchar *end)
                                net_boot_file_name[size] = 0;
                        }
                        break;
-               case 209:       /* PXELINUX Config File */
+               case DHCP_OPTION_PXE_CONFIG_FILE:       /* PXELINUX Config File */
                        if (IS_ENABLED(CONFIG_BOOTP_PXE_DHCP_OPTION)) {
                                /* In case it has already been allocated when get DHCP Offer packet,
                                 * free first to avoid memory leak.
index 4e32b19d424bee075d95614c1fd4ffb85350ee67..24b32c73f625b9bb1e21b426a42112c825bb9fe4 100644 (file)
@@ -91,6 +91,8 @@ typedef enum { INIT,
 #define DHCP_NAK      6
 #define DHCP_RELEASE  7
 
+#define DHCP_OPTION_PXE_CONFIG_FILE    209     /* "ConfigFile" option according to rfc5071 */
+
 /**********************************************************************/
 
 #endif /* __BOOTP_H__ */