summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authorraj <raj@FreeBSD.org>2008-03-12 16:12:48 +0000
committerraj <raj@FreeBSD.org>2008-03-12 16:12:48 +0000
commit054d727b12bc095749d9c28ef9354f5aab773391 (patch)
treef94e7c15d9c77bfb1ce32ab3eafb8e6e67edb379 /sys/boot
parent7e7a99d55a83a8319b7b43dc69930dddc3698080 (diff)
downloadFreeBSD-src-054d727b12bc095749d9c28ef9354f5aab773391.zip
FreeBSD-src-054d727b12bc095749d9c28ef9354f5aab773391.tar.gz
Improve handling U-Boot's "eth%daddr" while PowerPC metadata preparation.
We're now more robust against cases of non-sorted and/or non-continuous numbering of those entries. Reviewed by: imp, marcel Approved by: cognet (mentor)
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/powerpc/uboot/metadata.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/sys/boot/powerpc/uboot/metadata.c b/sys/boot/powerpc/uboot/metadata.c
index f9d9a62..c4342ed 100644
--- a/sys/boot/powerpc/uboot/metadata.c
+++ b/sys/boot/powerpc/uboot/metadata.c
@@ -267,7 +267,7 @@ md_bootinfo(struct bootinfo **addr)
const char *env;
void *ptr;
u_int8_t tmp_addr[6];
- int i, mr_no, eth_no, size;
+ int i, n, mr_no, eth_no, size;
if ((si = ub_get_sys_info()) == NULL)
panic("can't retrieve U-Boot sysinfo");
@@ -301,15 +301,32 @@ md_bootinfo(struct bootinfo **addr)
if (strncmp(env, "eth", 3) == 0 &&
strncmp(env + (strlen(env) - 4), "addr", 4) == 0) {
+ /* Extract interface number */
+ i = strtol(env + 3, &end, 10);
+ if (end == (env + 3))
+ /* 'ethaddr' means interface 0 address */
+ n = 0;
+ else
+ n = i;
+
+ if (n >= TMP_MAX_MR) {
+ printf("Ethernet interface number too high: %d. "
+ "Skipping...\n");
+ continue;
+ }
+
str = ub_env_get(env);
for (i = 0; i < 6; i++) {
tmp_addr[i] = str ? strtol(str, &end, 16) : 0;
if (str)
str = (*end) ? end + 1 : end;
- tmp_eth[eth_no].mac_addr[i] = tmp_addr[i];
+ tmp_eth[n].mac_addr[i] = tmp_addr[i];
}
- eth_no++;
+
+ /* eth_no is 1-based number of all interfaces defined */
+ if (n + 1 > eth_no)
+ eth_no = n + 1;
}
}
OpenPOWER on IntegriCloud