summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorRon Yorston2015-10-21 16:57:25 +0100
committerDenys Vlasenko2015-10-24 22:04:36 +0200
commit8814431aca695a43b2e164a6620ea0a3274ce678 (patch)
treeae0b3f470b296ceea659d490d90ff77d50145306 /networking
parent6d777b75ed322ea5ef0d1674ddfee1b5713cb04f (diff)
downloadbusybox-8814431aca695a43b2e164a6620ea0a3274ce678.zip
busybox-8814431aca695a43b2e164a6620ea0a3274ce678.tar.gz
libiproute: use if_nametoindex
Saves 87 bytes. Assuming, of course, all platforms have it. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/libiproute/ll_map.c25
1 files changed, 1 insertions, 24 deletions
diff --git a/networking/libiproute/ll_map.c b/networking/libiproute/ll_map.c
index e2b85fc..af9eb46 100644
--- a/networking/libiproute/ll_map.c
+++ b/networking/libiproute/ll_map.c
@@ -136,7 +136,6 @@ unsigned FAST_FUNC ll_index_to_flags(int idx)
int FAST_FUNC xll_name_to_index(const char *name)
{
int ret = 0;
- int sock_fd;
/* caching is not warranted - no users which repeatedly call it */
#ifdef UNUSED
@@ -164,30 +163,8 @@ int FAST_FUNC xll_name_to_index(const char *name)
}
}
}
- /* We have not found the interface in our cache, but the kernel
- * may still know about it. One reason is that we may be using
- * module on-demand loading, which means that the kernel will
- * load the module and make the interface exist only when
- * we explicitely request it (check for dev_load() in net/core/dev.c).
- * I can think of other similar scenario, but they are less common...
- * Jean II */
#endif
-
- sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
- if (sock_fd >= 0) {
- struct ifreq ifr;
- int tmp;
-
- strncpy_IFNAMSIZ(ifr.ifr_name, name);
- ifr.ifr_ifindex = -1;
- tmp = ioctl(sock_fd, SIOCGIFINDEX, &ifr);
- close(sock_fd);
- if (tmp >= 0)
- /* In theory, we should redump the interface list
- * to update our cache, this is left as an exercise
- * to the reader... Jean II */
- ret = ifr.ifr_ifindex;
- }
+ ret = if_nametoindex(name);
/* out:*/
if (ret <= 0)
bb_error_msg_and_die("can't find device '%s'", name);