diff mbox

[U-Boot,v4,6/7] net: Optionally use pxe client arch from variable

Message ID 1463061105-230381-1-git-send-email-agraf@suse.de
State Accepted
Commit bc6fc28b8604eddb527217b450d86d368cc25d13
Delegated to: Tom Rini
Headers show

Commit Message

Alexander Graf May 12, 2016, 1:51 p.m. UTC
The client architecture that we pass to a dhcp server depends on the target
payload that we want to execute. An EFI binary has a different client arch
than a legacy binary or a u-boot binary.

So let's parameterize the pxe client arch field to allow an override via
the distro script, so that our efi boot path can tell the dhcp server that
it's actually an efi firmware.

Signed-off-by: Alexander Graf <agraf@suse.de>

---

v3 -> v4:

  - Fix compile build for !CONFIG_LIB_UUID
---
 net/bootp.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

Comments

Tom Rini May 30, 2016, 5:57 p.m. UTC | #1
On Thu, May 12, 2016 at 03:51:45PM +0200, Alexander Graf wrote:

> The client architecture that we pass to a dhcp server depends on the target
> payload that we want to execute. An EFI binary has a different client arch
> than a legacy binary or a u-boot binary.
> 
> So let's parameterize the pxe client arch field to allow an override via
> the distro script, so that our efi boot path can tell the dhcp server that
> it's actually an efi firmware.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/net/bootp.c b/net/bootp.c
index d718e35..c1c32a1 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -431,10 +431,10 @@  static int dhcp_extended(u8 *e, int message_type, struct in_addr server_ip,
 {
 	u8 *start = e;
 	u8 *cnt;
-#if defined(CONFIG_BOOTP_PXE)
+#ifdef CONFIG_LIB_UUID
 	char *uuid;
-	u16 clientarch;
 #endif
+	int clientarch = -1;
 
 #if defined(CONFIG_BOOTP_VENDOREX)
 	u8 *x;
@@ -490,12 +490,19 @@  static int dhcp_extended(u8 *e, int message_type, struct in_addr server_ip,
 	}
 #endif
 
-#if defined(CONFIG_BOOTP_PXE)
+#ifdef CONFIG_BOOTP_PXE_CLIENTARCH
 	clientarch = CONFIG_BOOTP_PXE_CLIENTARCH;
-	*e++ = 93;	/* Client System Architecture */
-	*e++ = 2;
-	*e++ = (clientarch >> 8) & 0xff;
-	*e++ = clientarch & 0xff;
+#endif
+
+	if (getenv("bootp_arch"))
+		clientarch = getenv_ulong("bootp_arch", 16, clientarch);
+
+	if (clientarch > 0) {
+		*e++ = 93;	/* Client System Architecture */
+		*e++ = 2;
+		*e++ = (clientarch >> 8) & 0xff;
+		*e++ = clientarch & 0xff;
+	}
 
 	*e++ = 94;	/* Client Network Interface Identifier */
 	*e++ = 3;
@@ -503,6 +510,7 @@  static int dhcp_extended(u8 *e, int message_type, struct in_addr server_ip,
 	*e++ = 0;	/* major revision */
 	*e++ = 0;	/* minor revision */
 
+#ifdef CONFIG_LIB_UUID
 	uuid = getenv("pxeuuid");
 
 	if (uuid) {