efinet: Add DHCP proxy support
authorIan Page Hands <iphands@gmail.com>
Mon, 9 Jan 2023 23:30:45 +0000 (18:30 -0500)
committerFelix Zielcke <fzielcke@z-51.de>
Wed, 11 Jun 2025 15:42:34 +0000 (17:42 +0200)
If a proxyDHCP configuration is used, the server name, server IP and
boot file values should be taken from the DHCP proxy offer instead of
the DHCP server ack packet.

Signed-off-by: Ian Page Hands <iphands@gmail.com>
Co-authored-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Gbp-Pq: Topic network
Gbp-Pq: Name efinet-add-dhcp-proxy-support.patch

grub-core/net/drivers/efi/efinet.c

index 69004d5fe2add21c8b43dcc403d563300182b9ca..4a8c38c3d650b696f5494a0584f9b5f6e7488ccc 100644 (file)
@@ -863,10 +863,33 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
     else
       {
        grub_dprintf ("efinet", "using ipv4 and dhcp\n");
+
+        struct grub_net_bootp_packet *dhcp_ack = (void *) &pxe_mode->dhcp_ack;
+
+        if (pxe_mode->proxy_offer_received)
+          {
+            grub_dprintf ("efinet", "proxy offer receive");
+            struct grub_net_bootp_packet *proxy_offer = (void *) &pxe_mode->proxy_offer;
+
+            if (proxy_offer && dhcp_ack->boot_file[0] == '\0')
+              {
+                grub_dprintf ("efinet", "setting values from proxy offer");
+                /*
+                 * Here we got a proxy offer and the dhcp_ack has a nil
+                 * boot_file Copy the proxy DHCP offer details into the
+                 * bootp_packet we are sending forward as they are the deatils
+                 * we need.
+                 */
+                *dhcp_ack->server_name = *proxy_offer->server_name;
+                *dhcp_ack->boot_file = *proxy_offer->boot_file;
+                dhcp_ack->server_ip = proxy_offer->server_ip;
+              }
+          }
+
        inter = grub_net_configure_by_dhcp_ack (card->name, card, 0,
                                                 (struct grub_net_bootp_packet *)
-                                                packet_buf,
-                                                packet_bufsz,
+                                                &pxe_mode->dhcp_ack,
+                                                sizeof (pxe_mode->dhcp_ack),
                                                 1, device, path);
        grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
       }