aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/tools
diff options
context:
space:
mode:
authorGravatar Dave MacLachlan <dmaclach@google.com>2015-10-16 18:43:43 +0000
committerGravatar Lukacs Berki <lberki@google.com>2015-10-19 08:18:50 +0000
commit553499a9837cabe764f68e88faa8ee44200d1b04 (patch)
treec8eb560e1ecc42d8c3d9e1b96b6d1cb3f0c7c52a /src/main/tools
parentac9cf072b34c4d1761ef2bb433dd8e57ca6317a3 (diff)
Fix for SIOCGIFINDEX undefined on Mac (https://github.com/bazelbuild/bazel/issues/510)
This compiles with the assumption that all we were using SIOCGIFINDEX for was to verify that the name was valid. I think the code as written before was actually wrong as the index value, and the flags value for a ifreq structure actually shared memory, so we were potentially setting flags that we didn't want to set based on the actual index returned. -- MOS_MIGRATED_REVID=105619856
Diffstat (limited to 'src/main/tools')
-rw-r--r--src/main/tools/network-tools.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main/tools/network-tools.c b/src/main/tools/network-tools.c
index 6e088d4cea..16241cd64c 100644
--- a/src/main/tools/network-tools.c
+++ b/src/main/tools/network-tools.c
@@ -36,7 +36,8 @@ void BringupInterface(const char *name) {
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name, IF_NAMESIZE);
- CHECK_CALL(ioctl(fd, SIOCGIFINDEX, &ifr));
+ // Verify that name is valid.
+ CHECK_CALL(if_nametoindex(ifr.ifr_name));
// Enable the interface
ifr.ifr_flags |= IFF_UP;