Skip to content

Commit 73bfd2e

Browse files
author
Dinar Valeev
committed
Handle MAC address for VETH
VETH have 8-byte MAC address. Signed-off-by: Dinar Valeev <dvaleev@suse.com>
1 parent e0a716b commit 73bfd2e

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

include/file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct path_description {
9090
char *ip_before_filename;
9191
#define path_net_after(x) (x)->u.n.ip_after_filename
9292
char *ip_after_filename;
93-
unsigned char mac[6];
93+
unsigned char mac[8];
9494
} n;
9595
struct {
9696
char *s1;

second/parse_device_path.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,11 +612,21 @@ static void parse_net_device(struct path_description *path, const char *netdev_o
612612
static void get_mac_address(struct path_description *result)
613613
{
614614
phandle dev = prom_finddevice(path_device(result));
615+
616+
int len;
617+
unsigned char* m;
618+
615619
if (dev != PROM_INVALID_HANDLE) {
616-
if (prom_getprop(dev, "mac-address", &result->u.n.mac, 6) == -1)
617-
prom_getprop(dev, "local-mac-address", &result->u.n.mac, 6);
618-
prom_printf("MAC for %s: %02x:%02x:%02x:%02x:%02x:%02x\n", path_device(result),
619-
result->u.n.mac[0], result->u.n.mac[1], result->u.n.mac[2], result->u.n.mac[3], result->u.n.mac[4], result->u.n.mac[5]);
620+
len = prom_getproplen(dev, "mac-address");
621+
if (prom_getprop(dev, "mac-address", &result->u.n.mac, len) < 0) {
622+
len = prom_getproplen(dev, "local-mac-address");
623+
prom_getprop(dev, "local-mac-address", &result->u.n.mac, len);
624+
m = result->u.n.mac;
625+
if (len == 8)
626+
m = m + 2;
627+
prom_printf("MAC for %s: %02x:%02x:%02x:%02x:%02x:%02x\n", path_device(result),
628+
m[0], m[1], m[2], m[3], m[4], m[5]);
629+
}
620630
}
621631
}
622632

second/yaboot.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,18 @@ static int find_and_load_config_file(const struct path_description *b, char *con
208208
int sz = 0, opened = 0, result;
209209
int i;
210210
struct path_description config_fspec;
211-
211+
unsigned char* m;
212212
switch (path_type(b)) {
213213
case TYPE_NET:
214214
names = config_file_names_net;
215+
m = b->u.n.mac;
216+
if ( m[7] != NULL )
217+
m = m + 2;
218+
215219
for (i = 0; i < 6; i++)
216-
if (b->u.n.mac[i]) {
220+
if (m[i]) {
217221
sprintf(config_file_name_ether_mac, config_file_name_ether_mac_template,
218-
b->u.n.mac[0], b->u.n.mac[1], b->u.n.mac[2], b->u.n.mac[3], b->u.n.mac[4], b->u.n.mac[5]);
222+
m[0], m[1], m[2], m[3], m[4], m[5]);
219223
break;
220224
}
221225
break;

0 commit comments

Comments
 (0)