All of lore.kernel.org
 help / color / mirror / Atom feed
* RFC Patch [0/2] PXE Add support for proxy DHCP
@ 2014-04-19  0:26 Mroczek, Joseph T
  2014-04-20 14:05 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 6+ messages in thread
From: Mroczek, Joseph T @ 2014-04-19  0:26 UTC (permalink / raw)
  To: The development of GNU GRUB

Hello:

Currently, grub does not support getting boot server information from a proxy DHCP server. This patch set adds this support for EFI. If the approach is good, I will go back and create a i386-pc patch as well.

It works by combining the contents from the two DHCP packets into a single source. This seems simpler and cleaner than updating all the DHCP code to work with multiple packets and juggling precedence across all the options.

Any help in getting this support into grub would be greatly appreciated.

~joe




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFC Patch [0/2] PXE Add support for proxy DHCP
  2014-04-19  0:26 RFC Patch [0/2] PXE Add support for proxy DHCP Mroczek, Joseph T
@ 2014-04-20 14:05 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-04-29  0:16   ` Mroczek, Joseph T
  2014-05-02  0:11   ` Mroczek, Joseph T
  0 siblings, 2 replies; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-04-20 14:05 UTC (permalink / raw)
  To: The development of GNU GRUB


[-- Attachment #1.1: Type: text/plain, Size: 1038 bytes --]

On 19.04.2014 02:26, Mroczek, Joseph T wrote:
> Hello:
> 
> Currently, grub does not support getting boot server information from a proxy DHCP server. This patch set adds this support for EFI. If the approach is good, I will go back and create a i386-pc patch as well.
> 
> It works by combining the contents from the two DHCP packets into a single source. This seems simpler and cleaner than updating all the DHCP code to work with multiple packets and juggling precedence across all the options.
> 
> Any help in getting this support into grub would be greatly appreciated.
> 
We have patch for similar problem for i386-pc port (attached).
The main problem with it is that it wasn't tested. If you can confirm
that it works for EFI as well (after adaptations from your patch), we
could commit pxe2.diff and necessarry adaptations on top of it.
> ~joe
> 
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: pxe2.diff --]
[-- Type: text/x-diff; name="pxe2.diff", Size: 7444 bytes --]

diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
index 19dc988..a1dcde6 100644
--- a/grub-core/kern/main.c
+++ b/grub-core/kern/main.c
@@ -142,8 +142,9 @@ grub_set_prefix_and_root (void)
       if (pptr[0])
 	path = grub_strdup (pptr);
     }
-  if ((!device || device[0] == ',' || !device[0]) || !path)
-    grub_machine_get_bootlocation (&fwdevice, &fwpath);
+
+  /* Call unconditionally as it also configures the network.  */
+  grub_machine_get_bootlocation (&fwdevice, &fwpath);
 
   if (!device && fwdevice)
     device = fwdevice;
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
index ed15941..38b0836 100644
--- a/grub-core/net/bootp.c
+++ b/grub-core/net/bootp.c
@@ -161,33 +161,14 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask)
 
 #define OFFSET_OF(x, y) ((grub_size_t)((grub_uint8_t *)((y)->x) - (grub_uint8_t *)(y)))
 
-struct grub_net_network_level_interface *
-grub_net_configure_by_dhcp_ack (const char *name,
-				struct grub_net_card *card,
-				grub_net_interface_flags_t flags,
-				const struct grub_net_bootp_packet *bp,
-				grub_size_t size,
-				int is_def, char **device, char **path)
+void
+grub_net_process_dhcp_ack (struct grub_net_network_level_interface *inter,
+			   const struct grub_net_bootp_packet *bp,
+			   grub_size_t size,
+			   int is_def, char **device, char **path)
 {
-  grub_net_network_level_address_t addr;
-  grub_net_link_level_address_t hwaddr;
-  struct grub_net_network_level_interface *inter;
   int mask = -1;
 
-  addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
-  addr.ipv4 = bp->your_ip;
-
-  if (device)
-    *device = 0;
-  if (path)
-    *path = 0;
-
-  grub_memcpy (hwaddr.mac, bp->mac_addr,
-	       bp->hw_len < sizeof (hwaddr.mac) ? bp->hw_len
-	       : sizeof (hwaddr.mac));
-  hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
-
-  inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags);
   if (bp->gateway_ip)
     {
       grub_net_network_level_netaddress_t target;
@@ -199,7 +180,7 @@ grub_net_configure_by_dhcp_ack (const char *name,
       target.ipv4.masksize = 32;
       gw.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
       gw.ipv4 = bp->gateway_ip;
-      rname = grub_xasprintf ("%s:gw", name);
+      rname = grub_xasprintf ("%s:gw", inter->name);
       if (rname)
 	grub_net_add_route_gw (rname, target, gw);
       grub_free (rname);
@@ -207,14 +188,12 @@ grub_net_configure_by_dhcp_ack (const char *name,
       target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
       target.ipv4.base = bp->gateway_ip;
       target.ipv4.masksize = 32;
-      grub_net_add_route (name, target, inter);
+      grub_net_add_route (inter->name, target, inter);
     }
 
   if (size > OFFSET_OF (boot_file, bp))
-    set_env_limn_ro (name, "boot_file", (char *) bp->boot_file,
+    set_env_limn_ro (inter->name, "boot_file", (char *) bp->boot_file,
 		     sizeof (bp->boot_file));
-  if (is_def)
-    grub_net_default_server = 0;
   if (is_def && !grub_net_default_server && bp->server_ip)
     {
       grub_net_default_server = grub_xasprintf ("%d.%d.%d.%d",
@@ -225,12 +204,6 @@ grub_net_configure_by_dhcp_ack (const char *name,
       grub_print_error ();
     }
 
-  if (is_def)
-    {
-      grub_env_set ("net_default_interface", name);
-      grub_env_export ("net_default_interface");
-    }
-
   if (device && !*device && bp->server_ip)
     {
       *device = grub_xasprintf ("tftp,%d.%d.%d.%d",
@@ -243,7 +216,7 @@ grub_net_configure_by_dhcp_ack (const char *name,
   if (size > OFFSET_OF (server_name, bp)
       && bp->server_name[0])
     {
-      set_env_limn_ro (name, "dhcp_server_name", (char *) bp->server_name,
+      set_env_limn_ro (inter->name, "dhcp_server_name", (char *) bp->server_name,
 		       sizeof (bp->server_name));
       if (is_def && !grub_net_default_server)
 	{
@@ -257,7 +230,8 @@ grub_net_configure_by_dhcp_ack (const char *name,
 	}
     }
 
-  if (size > OFFSET_OF (boot_file, bp) && path)
+  if (size > OFFSET_OF (boot_file, bp) && path && !*path
+      && bp->boot_file[0])
     {
       *path = grub_strndup (bp->boot_file, sizeof (bp->boot_file));
       grub_print_error ();
@@ -272,9 +246,47 @@ grub_net_configure_by_dhcp_ack (const char *name,
 	}
     }
   if (size > OFFSET_OF (vendor, bp))
-    parse_dhcp_vendor (name, &bp->vendor, size - OFFSET_OF (vendor, bp), &mask);
+    parse_dhcp_vendor (inter->name, &bp->vendor, size - OFFSET_OF (vendor, bp), &mask);
   grub_net_add_ipv4_local (inter, mask);
-  
+}
+
+
+struct grub_net_network_level_interface *
+grub_net_configure_by_dhcp_ack (const char *name,
+				struct grub_net_card *card,
+				grub_net_interface_flags_t flags,
+				const struct grub_net_bootp_packet *bp,
+				grub_size_t size,
+				int is_def, char **device, char **path)
+{
+  grub_net_network_level_address_t addr;
+  grub_net_link_level_address_t hwaddr;
+  struct grub_net_network_level_interface *inter;
+
+  addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+  addr.ipv4 = bp->your_ip;
+
+  if (device)
+    *device = 0;
+  if (path)
+    *path = 0;
+
+  grub_memcpy (hwaddr.mac, bp->mac_addr,
+	       bp->hw_len < sizeof (hwaddr.mac) ? bp->hw_len
+	       : sizeof (hwaddr.mac));
+  hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+
+  inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags);
+
+  if (is_def)
+    {
+      grub_env_set ("net_default_interface", name);
+      grub_env_export ("net_default_interface");
+      grub_net_default_server = 0;
+    }
+
+  grub_net_process_dhcp_ack (inter, bp, size, is_def, device, path);
+
   inter->dhcp_ack = grub_malloc (size);
   if (inter->dhcp_ack)
     {
diff --git a/grub-core/net/drivers/i386/pc/pxe.c b/grub-core/net/drivers/i386/pc/pxe.c
index 3e75b2e..0a2ed82 100644
--- a/grub-core/net/drivers/i386/pc/pxe.c
+++ b/grub-core/net/drivers/i386/pc/pxe.c
@@ -360,15 +360,24 @@ static void
 grub_pc_net_config_real (char **device, char **path)
 {
   struct grub_net_bootp_packet *bp;
+  struct grub_net_network_level_interface *inter;
 
   bp = grub_pxe_get_cached (GRUB_PXENV_PACKET_TYPE_DHCP_ACK);
 
   if (!bp)
     return;
-  grub_net_configure_by_dhcp_ack ("pxe", &grub_pxe_card, 0,
-				  bp, GRUB_PXE_BOOTP_SIZE,
-				  1, device, path);
+  inter = grub_net_configure_by_dhcp_ack ("pxe", &grub_pxe_card, 0,
+					  bp, GRUB_PXE_BOOTP_SIZE,
+					  1, device, path);
 
+
+  /* Boot server PXE options add and override boot file/server */
+  bp = grub_pxe_get_cached (GRUB_PXENV_PACKET_TYPE_CACHED_REPLY);
+
+
+  if (bp)
+    grub_net_process_dhcp_ack (inter, bp, GRUB_PXE_BOOTP_SIZE,
+			       1, device, path);
 }
 
 static struct grub_preboot *fini_hnd;
diff --git a/include/grub/net.h b/include/grub/net.h
index 788516a..507f985 100644
--- a/include/grub/net.h
+++ b/include/grub/net.h
@@ -444,6 +444,12 @@ grub_net_configure_by_dhcp_ack (const char *name,
 				grub_size_t size,
 				int is_def, char **device, char **path);
 
+void
+grub_net_process_dhcp_ack (struct grub_net_network_level_interface *inter,
+			   const struct grub_net_bootp_packet *bp,
+			   grub_size_t size,
+			   int is_def, char **device, char **path);
+
 grub_err_t
 grub_net_add_ipv4_local (struct grub_net_network_level_interface *inf,
 			 int mask);

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 274 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: RFC Patch [0/2] PXE Add support for proxy DHCP
  2014-04-20 14:05 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-04-29  0:16   ` Mroczek, Joseph T
  2014-05-02  0:11   ` Mroczek, Joseph T
  1 sibling, 0 replies; 6+ messages in thread
From: Mroczek, Joseph T @ 2014-04-29  0:16 UTC (permalink / raw)
  To: The development of GNU GRUB

> From: Vladimir 'f-coder/phcoder' Serbinenko
> Sent: Sunday, April 20, 2014 7:06 AM
> 
> On 19.04.2014 02:26, Mroczek, Joseph T wrote:
> > Hello:
> >
> > Currently, grub does not support getting boot server information from a
> proxy DHCP server. This patch set adds this support for EFI. If the approach is
> good, I will go back and create a i386-pc patch as well.
> >
> > It works by combining the contents from the two DHCP packets into a
> single source. This seems simpler and cleaner than updating all the DHCP
> code to work with multiple packets and juggling precedence across all the
> options.
> >
> > Any help in getting this support into grub would be greatly appreciated.
> >
> We have patch for similar problem for i386-pc port (attached).
> The main problem with it is that it wasn't tested. If you can confirm that it
> works for EFI as well (after adaptations from your patch), we could commit
> pxe2.diff and necessarry adaptations on top of it.

Sorry for the delay in getting back to you on this. I got pulled into a high priority issue. This patch looks more complex but safer than what I proposed. I patched against grub2.02~beta2. Hunk #1 appears obsolete. The rest applied cleanly, but the network came up completely unconfigured. (net_default_ip=(null) net_default_mac=(null) net_default_server= ) I will poke at the changes and see if I can figure out where it went sideways.

~joe

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: RFC Patch [0/2] PXE Add support for proxy DHCP
  2014-04-20 14:05 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-04-29  0:16   ` Mroczek, Joseph T
@ 2014-05-02  0:11   ` Mroczek, Joseph T
  2014-05-22 16:53     ` Mroczek, Joseph T
  1 sibling, 1 reply; 6+ messages in thread
From: Mroczek, Joseph T @ 2014-05-02  0:11 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]

> From: Vladimir 'f-coder/phcoder' Serbinenko
> Sent: Sunday, April 20, 2014 7:06 AM
> 
> On 19.04.2014 02:26, Mroczek, Joseph T wrote:
> > Hello:
> >
> > Currently, grub does not support getting boot server information from a
> proxy DHCP server. This patch set adds this support for EFI. If the approach is
> good, I will go back and create a i386-pc patch as well.
> >
> > It works by combining the contents from the two DHCP packets into a
> single source. This seems simpler and cleaner than updating all the DHCP
> code to work with multiple packets and juggling precedence across all the
> options.
> >
> > Any help in getting this support into grub would be greatly appreciated.
> >
> We have patch for similar problem for i386-pc port (attached).
> The main problem with it is that it wasn't tested. If you can confirm that it
> works for EFI as well (after adaptations from your patch), we could commit
> pxe2.diff and necessarry adaptations on top of it.
> > ~joe

Attached is an updated version of the patch. It is against grub-2.02~beta2. I have tested the following environments: i386-pc-pxe, i386-efi, and x86_64-efi. All network variables except boot filename were set properly (expected), and I was able to continue boot normally. There is one caveat, I had to add the patch to correct routing behavior for the boot server that I previously proposed. I don’t feel that is relevant to the validity of this patch. 

Please let me know if there is anything I can do to assist with integration of this support.

~joe



[-- Attachment #2: pxe2.2.diff --]
[-- Type: application/octet-stream, Size: 9305 bytes --]

diff -Naurb grub-2.02~beta2/grub-core/net/bootp.c grub-2.02~beta2-pxe2-jtm/grub-core/net/bootp.c
--- grub-2.02~beta2/grub-core/net/bootp.c	2013-12-24 11:40:31.000000000 -0500
+++ grub-2.02~beta2-pxe2-jtm/grub-core/net/bootp.c	2014-05-01 20:13:26.398208600 -0400
@@ -161,33 +161,14 @@
 
 #define OFFSET_OF(x, y) ((grub_size_t)((grub_uint8_t *)((y)->x) - (grub_uint8_t *)(y)))
 
-struct grub_net_network_level_interface *
-grub_net_configure_by_dhcp_ack (const char *name,
-				struct grub_net_card *card,
-				grub_net_interface_flags_t flags,
+void
+grub_net_process_dhcp_ack (struct grub_net_network_level_interface *inter,
 				const struct grub_net_bootp_packet *bp,
 				grub_size_t size,
 				int is_def, char **device, char **path)
 {
-  grub_net_network_level_address_t addr;
-  grub_net_link_level_address_t hwaddr;
-  struct grub_net_network_level_interface *inter;
   int mask = -1;
 
-  addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
-  addr.ipv4 = bp->your_ip;
-
-  if (device)
-    *device = 0;
-  if (path)
-    *path = 0;
-
-  grub_memcpy (hwaddr.mac, bp->mac_addr,
-	       bp->hw_len < sizeof (hwaddr.mac) ? bp->hw_len
-	       : sizeof (hwaddr.mac));
-  hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
-
-  inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags);
   if (bp->gateway_ip)
     {
       grub_net_network_level_netaddress_t target;
@@ -199,7 +180,7 @@
       target.ipv4.masksize = 32;
       gw.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
       gw.ipv4 = bp->gateway_ip;
-      rname = grub_xasprintf ("%s:gw", name);
+      rname = grub_xasprintf ("%s:gw", inter->name);
       if (rname)
 	grub_net_add_route_gw (rname, target, gw);
       grub_free (rname);
@@ -207,14 +188,12 @@
       target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
       target.ipv4.base = bp->gateway_ip;
       target.ipv4.masksize = 32;
-      grub_net_add_route (name, target, inter);
+      grub_net_add_route (inter->name, target, inter);
     }
 
   if (size > OFFSET_OF (boot_file, bp))
-    set_env_limn_ro (name, "boot_file", (char *) bp->boot_file,
+    set_env_limn_ro (inter->name, "boot_file", (char *) bp->boot_file,
 		     sizeof (bp->boot_file));
-  if (is_def)
-    grub_net_default_server = 0;
   if (is_def && !grub_net_default_server && bp->server_ip)
     {
       grub_net_default_server = grub_xasprintf ("%d.%d.%d.%d",
@@ -225,12 +204,6 @@
       grub_print_error ();
     }
 
-  if (is_def)
-    {
-      grub_env_set ("net_default_interface", name);
-      grub_env_export ("net_default_interface");
-    }
-
   if (device && !*device && bp->server_ip)
     {
       *device = grub_xasprintf ("tftp,%d.%d.%d.%d",
@@ -243,7 +216,7 @@
   if (size > OFFSET_OF (server_name, bp)
       && bp->server_name[0])
     {
-      set_env_limn_ro (name, "dhcp_server_name", (char *) bp->server_name,
+      set_env_limn_ro (inter->name, "dhcp_server_name", (char *) bp->server_name,
 		       sizeof (bp->server_name));
       if (is_def && !grub_net_default_server)
 	{
@@ -257,7 +230,8 @@
 	}
     }
 
-  if (size > OFFSET_OF (boot_file, bp) && path)
+  if (size > OFFSET_OF (boot_file, bp) && path && !*path
+      && bp->boot_file[0])
     {
       *path = grub_strndup (bp->boot_file, sizeof (bp->boot_file));
       grub_print_error ();
@@ -272,8 +246,46 @@
 	}
     }
   if (size > OFFSET_OF (vendor, bp))
-    parse_dhcp_vendor (name, &bp->vendor, size - OFFSET_OF (vendor, bp), &mask);
+    parse_dhcp_vendor (inter->name, &bp->vendor, size - OFFSET_OF (vendor, bp), &mask);
   grub_net_add_ipv4_local (inter, mask);
+}
+
+
+struct grub_net_network_level_interface *
+grub_net_configure_by_dhcp_ack (const char *name,
+				struct grub_net_card *card,
+				grub_net_interface_flags_t flags,
+				const struct grub_net_bootp_packet *bp,
+				grub_size_t size,
+				int is_def, char **device, char **path)
+{
+  grub_net_network_level_address_t addr;
+  grub_net_link_level_address_t hwaddr;
+  struct grub_net_network_level_interface *inter;
+
+  addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+  addr.ipv4 = bp->your_ip;
+
+  if (device)
+    *device = 0;
+  if (path)
+    *path = 0;
+
+  grub_memcpy (hwaddr.mac, bp->mac_addr,
+	       bp->hw_len < sizeof (hwaddr.mac) ? bp->hw_len
+	       : sizeof (hwaddr.mac));
+  hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+
+  inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags);
+
+  if (is_def)
+    {
+      grub_env_set ("net_default_interface", name);
+      grub_env_export ("net_default_interface");
+      grub_net_default_server = 0;
+    }
+
+  grub_net_process_dhcp_ack (inter, bp, size, is_def, device, path);
   
   inter->dhcp_ack = grub_malloc (size);
   if (inter->dhcp_ack)
diff -Naurb grub-2.02~beta2/grub-core/net/drivers/efi/efinet.c grub-2.02~beta2-pxe2-jtm/grub-core/net/drivers/efi/efinet.c
--- grub-2.02~beta2/grub-core/net/drivers/efi/efinet.c	2013-12-24 11:29:27.000000000 -0500
+++ grub-2.02~beta2-pxe2-jtm/grub-core/net/drivers/efi/efinet.c	2014-05-01 19:50:06.730208600 -0400
@@ -223,6 +223,7 @@
 {
   struct grub_net_card *card;
   grub_efi_device_path_t *dp;
+  struct grub_net_network_level_interface *inter;
 
   dp = grub_efi_get_device_path (hnd);
   if (! dp)
@@ -245,11 +246,19 @@
     if (! pxe)
       continue;
     pxe_mode = pxe->mode;
-    grub_net_configure_by_dhcp_ack (card->name, card, 0,
+    inter = grub_net_configure_by_dhcp_ack (card->name, card, 0,
 				    (struct grub_net_bootp_packet *)
 				    &pxe_mode->dhcp_ack,
 				    sizeof (pxe_mode->dhcp_ack),
 				    1, device, path);
+
+  /* Boot server PXE options add and override boot file/server */
+   if (pxe_mode->proxy_offer_received)
+     grub_net_process_dhcp_ack (inter,
+				(struct grub_net_bootp_packet *)
+				&pxe_mode->proxy_offer,
+				sizeof (pxe_mode->proxy_offer),
+				1, device, path);
     return;
   }
 }
diff -Naurb grub-2.02~beta2/grub-core/net/drivers/i386/pc/pxe.c grub-2.02~beta2-pxe2-jtm/grub-core/net/drivers/i386/pc/pxe.c
--- grub-2.02~beta2/grub-core/net/drivers/i386/pc/pxe.c	2013-12-24 11:29:27.000000000 -0500
+++ grub-2.02~beta2-pxe2-jtm/grub-core/net/drivers/i386/pc/pxe.c	2014-05-01 19:50:06.726208600 -0400
@@ -360,15 +360,24 @@
 grub_pc_net_config_real (char **device, char **path)
 {
   struct grub_net_bootp_packet *bp;
+  struct grub_net_network_level_interface *inter;
 
   bp = grub_pxe_get_cached (GRUB_PXENV_PACKET_TYPE_DHCP_ACK);
 
   if (!bp)
     return;
-  grub_net_configure_by_dhcp_ack ("pxe", &grub_pxe_card, 0,
+  inter = grub_net_configure_by_dhcp_ack ("pxe", &grub_pxe_card, 0,
 				  bp, GRUB_PXE_BOOTP_SIZE,
 				  1, device, path);
 
+
+  /* Boot server PXE options add and override boot file/server */
+  bp = grub_pxe_get_cached (GRUB_PXENV_PACKET_TYPE_CACHED_REPLY);
+
+
+  if (bp)
+    grub_net_process_dhcp_ack (inter, bp, GRUB_PXE_BOOTP_SIZE,
+			       1, device, path);
 }
 
 static struct grub_preboot *fini_hnd;
diff -Naurb grub-2.02~beta2/include/grub/efi/api.h grub-2.02~beta2-pxe2-jtm/include/grub/efi/api.h
--- grub-2.02~beta2/include/grub/efi/api.h	2013-12-24 12:04:54.000000000 -0500
+++ grub-2.02~beta2-pxe2-jtm/include/grub/efi/api.h	2014-05-01 19:50:06.730208600 -0400
@@ -526,7 +526,7 @@
 typedef grub_uint8_t grub_efi_mac_address_t[32];
 typedef grub_uint8_t grub_efi_ipv4_address_t[4];
 typedef grub_uint16_t grub_efi_ipv6_address_t[8];
-typedef grub_uint8_t grub_efi_ip_address_t[8] __attribute__ ((aligned(4)));
+typedef grub_uint8_t grub_efi_ip_address_t[16] __attribute__ ((aligned(4)));
 typedef grub_efi_uint64_t grub_efi_physical_address_t;
 typedef grub_efi_uint64_t grub_efi_virtual_address_t;
 
@@ -1342,12 +1342,33 @@
 
 typedef struct grub_efi_pxe_mode
 {
-  grub_uint8_t unused[52];
+  grub_uint8_t started;
+  grub_uint8_t ipv6_available;
+  grub_uint8_t ipv6_supported;
+  grub_uint8_t using_ipv6;
+  grub_uint8_t bis_supported;
+  grub_uint8_t bis_detected;
+  grub_uint8_t auto_arp;
+  grub_uint8_t send_guid;
+  grub_uint8_t dhcp_discover_valid;
+  grub_uint8_t dhcp_ack_received;
+  grub_uint8_t proxy_offer_received;
+  grub_uint8_t pxe_discover_valid;
+  grub_uint8_t pxe_reply_received;
+  grub_uint8_t pxe_bis_reply_received;
+  grub_uint8_t icmp_error_received;
+  grub_uint8_t tftp_error_received;
+  grub_uint8_t make_callbacks;
+  grub_uint8_t ttl;
+  grub_uint8_t tos;
+  grub_efi_ip_address_t station_ip;
+  grub_efi_ip_address_t subnet_mask;
   grub_efi_pxe_packet_t dhcp_discover;
   grub_efi_pxe_packet_t dhcp_ack;
   grub_efi_pxe_packet_t proxy_offer;
   grub_efi_pxe_packet_t pxe_discover;
   grub_efi_pxe_packet_t pxe_reply;
+  grub_efi_pxe_packet_t pxe_bis_reply;
 } grub_efi_pxe_mode_t;
 
 typedef struct grub_efi_pxe
diff -Naurb grub-2.02~beta2/include/grub/net.h grub-2.02~beta2-pxe2-jtm/include/grub/net.h
--- grub-2.02~beta2/include/grub/net.h	2013-12-24 11:40:31.000000000 -0500
+++ grub-2.02~beta2-pxe2-jtm/include/grub/net.h	2014-05-01 19:50:06.726208600 -0400
@@ -444,6 +444,12 @@
 				grub_size_t size,
 				int is_def, char **device, char **path);
 
+void
+grub_net_process_dhcp_ack (struct grub_net_network_level_interface *inter,
+			   const struct grub_net_bootp_packet *bp,
+			   grub_size_t size,
+			   int is_def, char **device, char **path);
+
 grub_err_t
 grub_net_add_ipv4_local (struct grub_net_network_level_interface *inf,
 			 int mask);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: RFC Patch [0/2] PXE Add support for proxy DHCP
  2014-05-02  0:11   ` Mroczek, Joseph T
@ 2014-05-22 16:53     ` Mroczek, Joseph T
  0 siblings, 0 replies; 6+ messages in thread
From: Mroczek, Joseph T @ 2014-05-22 16:53 UTC (permalink / raw)
  To: The development of GNU GRUB

> From Mroczek, Joseph T
> Sent: Thursday, May 01, 2014 5:11 PM
> > From: Vladimir 'f-coder/phcoder' Serbinenko
> > Sent: Sunday, April 20, 2014 7:06 AM
> >
> > On 19.04.2014 02:26, Mroczek, Joseph T wrote:
> > > Hello:
> > >
> > > Currently, grub does not support getting boot server information
> > > from a
> > proxy DHCP server. This patch set adds this support for EFI. If the
> > approach is good, I will go back and create a i386-pc patch as well.
> > >
> > > It works by combining the contents from the two DHCP packets into a
> > single source. This seems simpler and cleaner than updating all the
> > DHCP code to work with multiple packets and juggling precedence across
> > all the options.
> > >
> > > Any help in getting this support into grub would be greatly appreciated.
> > >
> > We have patch for similar problem for i386-pc port (attached).
> > The main problem with it is that it wasn't tested. If you can confirm
> > that it works for EFI as well (after adaptations from your patch), we
> > could commit pxe2.diff and necessarry adaptations on top of it.
> > > ~joe
> 
> Attached is an updated version of the patch. It is against grub-2.02~beta2. I
> have tested the following environments: i386-pc-pxe, i386-efi, and x86_64-
> efi. All network variables except boot filename were set properly
> (expected), and I was able to continue boot normally. There is one caveat, I
> had to add the patch to correct routing behavior for the boot server that I
> previously proposed. I don’t feel that is relevant to the validity of this patch.
> 
> Please let me know if there is anything I can do to assist with integration of
> this support.
>

I don’t see this in the list of commits. Is there anything I can do to help this patch along?

~joe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFC Patch [0/2] PXE Add support for proxy DHCP
@ 2019-02-03 15:04 Alkis Georgopoulos
  0 siblings, 0 replies; 6+ messages in thread
From: Alkis Georgopoulos @ 2019-02-03 15:04 UTC (permalink / raw)
  To: grub-devel

Sorry I just joined the list, the original thread that I reply to is:
https://lists.gnu.org/archive/html/grub-devel/2014-04/msg00091.html

Thousands of LTSP installations use proxy DHCP to netboot clients.
Unfortunately grub has a bug and tries to use the real DHCP as the TFTP 
server, instead of the proxy DHCP, and fails to fetch grub.cfg.

The proposed patch by Mroczek, Joseph T addressed this issue,
and Vladimir 'φ-coder/phcoder' Serbinenko replied that he even had a 
better one.
Why weren't they merged? Could I help with testing or something?

It'll be extremely valuable now with UEFI, and especially with secure 
boot, since shimx64.efi > grubnetx64.efi is essentially the only option 
there.

The respective commit in shim was:
https://github.com/rhboot/shim/commit/5f4fd5364109c80934b7837255ddde61f572fd69

Thanks,
Alkis Georgopoulos
LTSP developer

--
Replying to this message:

Re: RFC Patch [0/2] PXE Add support for proxy DHCP
From: 	Vladimir 'φ-coder/phcoder' Serbinenko
Subject: 	Re: RFC Patch [0/2] PXE Add support for proxy DHCP
Date: 	Sun, 20 Apr 2014 16:05:42 +0200
User-agent: 	Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 
Icedove/24.4.0

On 19.04.2014 02:26, Mroczek, Joseph T wrote:
 > Hello:
 >
 > Currently, grub does not support getting boot server information from 
a proxy
 > DHCP server. This patch set adds this support for EFI. If the 
approach is
 > good, I will go back and create a i386-pc patch as well.
 >
 > It works by combining the contents from the two DHCP packets into a 
single
 > source. This seems simpler and cleaner than updating all the DHCP 
code to
 > work with multiple packets and juggling precedence across all the 
options.
 >
 > Any help in getting this support into grub would be greatly appreciated.
 >
We have patch for similar problem for i386-pc port (attached).
The main problem with it is that it wasn't tested. If you can confirm
that it works for EFI as well (after adaptations from your patch), we
could commit pxe2.diff and necessarry adaptations on top of it.
 > ~joe


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-02-03 15:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-19  0:26 RFC Patch [0/2] PXE Add support for proxy DHCP Mroczek, Joseph T
2014-04-20 14:05 ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-04-29  0:16   ` Mroczek, Joseph T
2014-05-02  0:11   ` Mroczek, Joseph T
2014-05-22 16:53     ` Mroczek, Joseph T
2019-02-03 15:04 Alkis Georgopoulos

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.