From: Felix Fietkau Date: Mon, 27 Feb 2012 23:54:19 +0000 (+0100) Subject: fix mac address handling X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7622440f6ddb0facdaca208186f72b345a6f7c3d;p=oweals%2Fnetifd.git fix mac address handling --- diff --git a/system-linux.c b/system-linux.c index 28029c1..aa1bd54 100644 --- a/system-linux.c +++ b/system-linux.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -588,7 +589,7 @@ system_if_get_settings(struct device *dev, struct device_settings *s) } if (ioctl(sock_ioctl, SIOCGIFHWADDR, &ifr) == 0) { - memcpy(s->macaddr, &ifr.ifr_hwaddr, sizeof(s->macaddr)); + memcpy(s->macaddr, &ifr.ifr_hwaddr.sa_data, sizeof(s->macaddr)); s->flags |= DEV_OPT_MACADDR; } } @@ -611,7 +612,8 @@ system_if_apply_settings(struct device *dev, struct device_settings *s) s->flags &= ~DEV_OPT_TXQUEUELEN; } if (s->flags & DEV_OPT_MACADDR) { - memcpy(&ifr.ifr_hwaddr, s->macaddr, sizeof(s->macaddr)); + ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; + memcpy(&ifr.ifr_hwaddr.sa_data, s->macaddr, sizeof(s->macaddr)); if (ioctl(sock_ioctl, SIOCSIFHWADDR, &ifr) < 0) s->flags &= ~DEV_OPT_MACADDR; } @@ -628,6 +630,7 @@ int system_if_up(struct device *dev) int system_if_down(struct device *dev) { int ret = system_if_flags(dev->ifname, 0, IFF_UP); + dev->orig_settings.flags &= dev->settings.flags; system_if_apply_settings(dev, &dev->orig_settings); return ret; }