summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-02-28 00:54:19 +0100
committerFelix Fietkau <nbd@openwrt.org>2012-02-28 00:54:19 +0100
commit7622440f6ddb0facdaca208186f72b345a6f7c3d (patch)
treec92019db6d9302d26e9475f16703d512caa52be6
parent0a1b9d266280ceba2492db6287330f771eab9de6 (diff)
fix mac address handling
-rw-r--r--system-linux.c7
1 files changed, 5 insertions, 2 deletions
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 <linux/if_vlan.h>
#include <linux/if_bridge.h>
#include <linux/ethtool.h>
+#include <net/if_arp.h>
#include <unistd.h>
#include <string.h>
@@ -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;
}