Page MenuHomeFreeBSD

D29788.diff
No OneTemporary

D29788.diff

diff --git a/share/man/man9/ether_gen_addr.9 b/share/man/man9/ether_gen_addr.9
--- a/share/man/man9/ether_gen_addr.9
+++ b/share/man/man9/ether_gen_addr.9
@@ -61,8 +61,9 @@
.Xr loader 8 .
.Pp
.Nm
-can fail to derive a MAC address due to memory allocation failure.
-In this case, a locally-administered unicast MAC address will be randomly
+can fail to derive a MAC address due to memory allocation failure, or because
+the hostid has not been populated.
+In these cases, a locally-administered unicast MAC address will be randomly
generated and returned via the
.Ar hwaddr
parameter.
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -76,7 +76,6 @@
#include <security/mac/mac_framework.h>
-#define DEFAULT_HOSTUUID "00000000-0000-0000-0000-000000000000"
#define PRISON0_HOSTUUID_MODULE "hostuuid"
MALLOC_DEFINE(M_PRISON, "prison", "Prison structures");
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1443,6 +1443,11 @@
char jailname[MAXHOSTNAMELEN];
getcredhostuuid(curthread->td_ucred, uuid, sizeof(uuid));
+ if (strncmp(uuid, DEFAULT_HOSTUUID, sizeof(uuid)) == 0) {
+ /* Fall back to a random mac address. */
+ goto rando;
+ }
+
/* If each (vnet) jail would also have a unique hostuuid this would not
* be necessary. */
getjailname(curthread->td_ucred, jailname, sizeof(jailname));
@@ -1450,9 +1455,7 @@
jailname);
if (sz < 0) {
/* Fall back to a random mac address. */
- arc4rand(hwaddr, sizeof(*hwaddr), 0);
- hwaddr->octet[0] = 0x02;
- return;
+ goto rando;
}
SHA1Init(&ctx);
@@ -1467,6 +1470,14 @@
hwaddr->octet[i] = addr >> ((ETHER_ADDR_LEN - i - 1) * 8) &
0xFF;
}
+
+ return;
+rando:
+ arc4rand(hwaddr, sizeof(*hwaddr), 0);
+ /* Unicast */
+ hwaddr->octet[0] &= 0xFE;
+ /* Locally administered. */
+ hwaddr->octet[0] |= 0x02;
}
DECLARE_MODULE(ether, ether_mod, SI_SUB_INIT_IF, SI_ORDER_ANY);
diff --git a/sys/sys/jail.h b/sys/sys/jail.h
--- a/sys/sys/jail.h
+++ b/sys/sys/jail.h
@@ -140,6 +140,7 @@
#include <sys/osd.h>
#define HOSTUUIDLEN 64
+#define DEFAULT_HOSTUUID "00000000-0000-0000-0000-000000000000"
#define OSRELEASELEN 32
struct racct;

File Metadata

Mime Type
text/plain
Expires
Sun, Jan 12, 11:15 PM (21 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15773675
Default Alt Text
D29788.diff (2 KB)

Event Timeline