From 412ce9165c5b7e9ea830d840a2831c13f8f05396 Mon Sep 17 00:00:00 2001 From: Avik Sil Date: Wed, 14 Aug 2013 18:03:01 -0300 Subject: [PATCH] * grub-core/net/drivers/ieee1275/ofnet.c: Get proper mac address when using qemu. --- ChangeLog | 5 +++++ grub-core/net/drivers/ieee1275/ofnet.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 751f7108d..295b2adcd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-08-14 Avik Sil + + * grub-core/net/drivers/ieee1275/ofnet.c: Get proper mac address when + using qemu. + 2013-08-14 Paulo Flabiano Smorigo * .bzrignore: Add bootinfo.txt, grub.chrp, gnulib/float.h, and diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index 21b62141a..7ecc05571 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -202,6 +202,9 @@ search_net_devices (struct grub_ieee1275_devalias *alias) struct grub_net_card *card; grub_ieee1275_phandle_t devhandle; grub_net_link_level_address_t lla; + grub_ssize_t prop_size; + grub_uint64_t prop; + grub_uint8_t *pprop; char *shortname; if (grub_strcmp (alias->type, "network") != 0) @@ -235,16 +238,22 @@ search_net_devices (struct grub_ieee1275_devalias *alias) card->mtu = t; } + pprop = (grub_uint8_t *) ∝ if (grub_ieee1275_get_property (devhandle, "mac-address", - &(lla.mac), 6, 0) + pprop, sizeof(prop), &prop_size) && grub_ieee1275_get_property (devhandle, "local-mac-address", - &(lla.mac), 6, 0)) + pprop, sizeof(prop), &prop_size)) { grub_error (GRUB_ERR_IO, "Couldn't retrieve mac address."); grub_print_error (); return 0; } + if (prop_size == 8) + grub_memcpy (&lla.mac, pprop+2, 6); + else + grub_memcpy (&lla.mac, pprop, 6); + lla.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; card->default_address = lla;