Adds basic support for ProxyDHCP
PATCH 1/1 Adds basic support for ProxyDHCP
From: Lyle Franklin <[email protected]>
- ProxyDHCP allows a second DHCP server to exist alongside your main DHCP server and supply additional BOOTP related options
- When u-boot sends out a DHCP request, the real DHCP server will respond with a normal response containing the new client IP address while simultaneously the ProxyDHCP server will respond with a blank client IP address and a bootfile option
- This patch adds CONFIG_SERVERIP_FROM_PROXYDHCP (default false) to enable this behavior and CONFIG_SERVERIP_FROM_PROXYDHCP_DELAY_MS (default 100) which tells u-boot to wait additional time after receiving the main DHCP response to give the ProxyDHCP response time to arrive
- The PXE spec for ProxyDHCP is more complicated than the solution added here as diagramed on page 16:
http://www.pix.net/software/pxeboot/archive/pxespec.pdf:
``` DHCP Discover will be retried four times. The four timeouts are 4, 8, 16 and 32 seconds respectively. If a DHCPOFFER is received without an Option timeouts in an attempt to receive a PXE response. ```
- Adding a simple delay worked for my purposes but let me know if a more robust solution is required
---
net/Kconfig | 14 ++++++++++++++ net/bootp.c | 27 ++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-)
net/Kconfig +14 -0
@@ -35,4 +35,18 @@ config TFTP_BLOCKSIZE help Default TFTP block size. +config SERVERIP_FROM_PROXYDHCP + bool "Get serverip value from Proxy DHCP response" + help + Allows bootfile config to be fetched from Proxy DHCP server + while IP is obtained from main DHCP server. + +config SERVERIP_FROM_PROXYDHCP_DELAY_MS + int "# of additional milliseconds to wait for ProxyDHCP response" + default 100 + help + Amount of additional time to wait for ProxyDHCP response after + receiving response from main DHCP server. Has no effect if + SERVERIP_FROM_PROXYDHCP is false. + endif # if NET
net/bootp.c +22 -5
@@ -140,10 +140,7 @@ static int check_reply_packet(uchar *pkt, unsigned dest, unsigned src,return retval; } -/* -* Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet -*/ -static void store_net_params (struct bootp_hdr *bp) +static void store_bootp_params (struct bootp_hdr *bp) {#if !defined(CONFIG_BOOTP_SERVERIP )struct in_addr tmp_ip;
@@ -176,6 +173,16 @@ static void store_net_params(struct bootp_hdr *bp)*/ if (*net_boot_file_name)env_set ("bootfile" , net_boot_file_name); +#endif +} + +/* +* Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet +*/ +static void store_net_params (struct bootp_hdr *bp) +{ +#if !defined(CONFIG_SERVERIP_FROM_PROXYDHCP ) +store_bootp_params (bp);#endif net_copy_ip (&net_ip, &bp->bp_yiaddr); }
@@ -1049,8 +1056,12 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,debug ("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: " "%d\n" , src, dest, len, dhcp_state); -if (net_read_ip (&bp->bp_yiaddr).s_addr ==0 ) +if (net_read_ip (&bp->bp_yiaddr).s_addr ==0 ) { +#if defined(CONFIG_SERVERIP_FROM_PROXYDHCP ) +store_bootp_params (bp); +#endif return ; + }switch (dhcp_state) {case SELECTING :
@@ -1069,6 +1080,12 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,dhcp_packet_process_options (bp);efi_net_set_dhcp_ack (pkt, len); +#if defined(CONFIG_SERVERIP_FROM_PROXYDHCP ) +if (!net_server_ip.s_addr) +udelay (CONFIG_SERVERIP_FROM_PROXYDHCP_DELAY_MS * +1000 ); +#endif /* CONFIG_SERVERIP_FROM_PROXYDHCP */ +debug ("TRANSITIONING TO REQUESTING STATE\n" ); dhcp_state =REQUESTING ;
Signature · 1 line
2.22.0
PATCH 1/1 Adds basic support for ProxyDHCP
Quoted 23 lines · lylejfranklin at gmail.com
From: Lyle Franklin <[email protected]>
- ProxyDHCP allows a second DHCP server to exist alongside your main DHCP server and supply additional BOOTP related options
- When u-boot sends out a DHCP request, the real DHCP server will respond with a normal response containing the new client IP address while simultaneously the ProxyDHCP server will respond with a blank client IP address and abootfileoption
- This patch addsCONFIG_SERVERIP_FROM_PROXYDHCP(default false) to enable this behavior andCONFIG_SERVERIP_FROM_PROXYDHCP_DELAY_MS(default 100) which tells u-boot to wait additional time after receiving the main DHCP response to give the ProxyDHCP response time to arrive
- The PXE spec for ProxyDHCP is more complicated than the solution added here as diagramed on page 16:
http://www.pix.net/software/pxeboot/archive/pxespec.pdf:``` DHCP Discover will be retried four times. The four timeouts are 4, 8, 16 and 32 seconds respectively. If a DHCPOFFER is received without an Option timeouts in an attempt to receive a PXE response. ```
Quoted 4 lines
- Adding a simple delay worked for my purposes but let me know if a more robust solution is required
Signed-off-by Lyle Franklin <[email protected]>
Sorry for the delay, applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201202/101783a9/attachment.sig>