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