shithub: riscv

Download patch

ref: 6041d2048c13057fcefc318345d41eef26e51149
parent: abc5a66c566e217f8683b6a105860ad05709d541
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Apr 8 19:48:09 EDT 2020

9bootpxe: simplify

--- a/sys/src/boot/efi/pxe.c
+++ b/sys/src/boot/efi/pxe.c
@@ -380,6 +380,20 @@
 	}
 
 	/* DHCPv6 */
+
+	/*
+	 * some UEFI implementations use random UUID based DUID instead of
+	 * ethernet address, but use ethernet derived link-local addresses.
+	 * so extract the MAC from our IPv6 address as a fallback.
+	 */
+	p = pxe->Mode->StationIp;
+	mymac[0] = p[8] ^ 2;
+	mymac[1] = p[9];
+	mymac[2] = p[10];
+	mymac[3] = p[13];
+	mymac[4] = p[14];
+	mymac[5] = p[15];
+
 	e = (uchar*)dhcp + sizeof(*dhcp);
 	p = (uchar*)dhcp + 4;
 	while(p+4 <= e){
@@ -410,21 +424,6 @@
 			break;
 		}
 		p += len;
-	}
-
-	/*
-	 * some UEFI implementations use random UUID based DUID instead of
-	 * ethernet address, but use ethernet derived link-local addresses.
-	 * so extract the MAC from our IPv6 address.
-	 */
-	if((mymac[0]|mymac[1]|mymac[2]|mymac[3]|mymac[4]|mymac[5]) == 0){
-		p = pxe->Mode->StationIp;
-		mymac[0] = p[8] ^ 2;
-		mymac[1] = p[9];
-		mymac[2] = p[10];
-		mymac[3] = p[13];
-		mymac[4] = p[14];
-		mymac[5] = p[15];
 	}
 }