projects
/
project
/
netifd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2152229
)
system-linux: resolve interface index at device_up
author
Steven Barth
<steven@midlink.org>
Fri, 7 Oct 2011 18:01:11 +0000
(20:01 +0200)
committer
Steven Barth
<steven@midlink.org>
Fri, 7 Oct 2011 18:01:11 +0000
(20:01 +0200)
system-linux.c
patch
|
blob
|
history
diff --git
a/system-linux.c
b/system-linux.c
index
f6e1058
..
f1acc19
100644
(file)
--- a/
system-linux.c
+++ b/
system-linux.c
@@
-165,8
+165,19
@@
static int system_if_flags(struct device *dev, unsigned add, unsigned rem)
return ioctl(sock_ioctl, SIOCSIFFLAGS, &ifr);
}
return ioctl(sock_ioctl, SIOCSIFFLAGS, &ifr);
}
+static int system_if_resolve(struct device *dev)
+{
+ struct ifreq ifr;
+ strncpy(ifr.ifr_name, dev->ifname, sizeof(ifr.ifr_name));
+ if (!ioctl(sock_ioctl, SIOCGIFINDEX, &ifr))
+ return ifr.ifr_ifindex;
+ else
+ return 0;
+}
+
int system_if_up(struct device *dev)
{
int system_if_up(struct device *dev)
{
+ dev->ifindex = system_if_resolve(dev);
return system_if_flags(dev, IFF_UP, 0);
}
return system_if_flags(dev, IFF_UP, 0);
}
@@
-177,16
+188,7
@@
int system_if_down(struct device *dev)
int system_if_check(struct device *dev)
{
int system_if_check(struct device *dev)
{
- struct ifreq ifr;
- strncpy(ifr.ifr_name, dev->ifname, sizeof(ifr.ifr_name));
- if (ioctl(sock_ioctl, SIOCGIFINDEX, &ifr))
- return -1;
-
- dev->ifindex = ifr.ifr_ifindex;
-
- /* if (!strcmp(dev->ifname, "eth0"))
- device_set_present(dev, true); */
- return 0;
+ return -!(system_if_resolve(dev));
}
static int system_addr(struct device *dev, struct device_addr *addr, int cmd)
}
static int system_addr(struct device *dev, struct device_addr *addr, int cmd)