Blame SOURCES/0490-efinet-Add-DHCP-proxy-support.patch

f6e916
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f6e916
From: Ian Page Hands <iphands@gmail.com>
f6e916
Date: Tue, 8 Jun 2021 13:48:56 -0400
f6e916
Subject: [PATCH] efinet: Add DHCP proxy support
f6e916
f6e916
If a proxyDHCP configuration is used, the server name, server IP and boot
f6e916
file values should be taken from the DHCP proxy offer instead of the DHCP
f6e916
server ack packet. Currently that case is not handled, add support for it.
f6e916
f6e916
(cherry picked from commit 9cd94b23fe366b87ef25c13c95a531325af9016f)
f6e916
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
f6e916
---
f6e916
 grub-core/net/drivers/efi/efinet.c | 25 +++++++++++++++++++++++--
f6e916
 1 file changed, 23 insertions(+), 2 deletions(-)
f6e916
f6e916
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
f6e916
index df7760ad2..25809050b 100644
f6e916
--- a/grub-core/net/drivers/efi/efinet.c
f6e916
+++ b/grub-core/net/drivers/efi/efinet.c
f6e916
@@ -850,10 +850,31 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
f6e916
     else
f6e916
       {
f6e916
 	grub_dprintf ("efinet", "using ipv4 and dhcp\n");
f6e916
+
f6e916
+        struct grub_net_bootp_packet *dhcp_ack = &pxe_mode->dhcp_ack;
f6e916
+
f6e916
+        if (pxe_mode->proxy_offer_received)
f6e916
+          {
f6e916
+            grub_dprintf ("efinet", "proxy offer receive");
f6e916
+            struct grub_net_bootp_packet *proxy_offer = &pxe_mode->proxy_offer;
f6e916
+
f6e916
+            if (proxy_offer && dhcp_ack->boot_file[0] == '\0')
f6e916
+              {
f6e916
+                grub_dprintf ("efinet", "setting values from proxy offer");
f6e916
+                /* Here we got a proxy offer and the dhcp_ack has a nil boot_file
f6e916
+                 * Copy the proxy DHCP offer details into the bootp_packet we are
f6e916
+                 * sending forward as they are the deatils we need.
f6e916
+                 */
f6e916
+                *dhcp_ack->server_name = *proxy_offer->server_name;
f6e916
+                *dhcp_ack->boot_file   = *proxy_offer->boot_file;
f6e916
+                dhcp_ack->server_ip    = proxy_offer->server_ip;
f6e916
+              }
f6e916
+          }
f6e916
+
f6e916
 	grub_net_configure_by_dhcp_ack (card->name, card, 0,
f6e916
 					(struct grub_net_bootp_packet *)
f6e916
-					packet_buf,
f6e916
-					packet_bufsz,
f6e916
+					&pxe_mode->dhcp_ack,
f6e916
+					sizeof (pxe_mode->dhcp_ack),
f6e916
 					1, device, path);
f6e916
 	grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
f6e916
       }