summaryrefslogtreecommitdiff
path: root/lib/socket
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2016-01-25 12:23:40 +0100
committerMichael Adam <obnox@samba.org>2016-01-26 07:33:16 +0100
commit235f37baa7df03ef44f71aea50d72603297a611d (patch)
tree6b6847b653abc72643d3be4caf5f19544a2390ea /lib/socket
parentd392e0a66d941eb66c1973cfa3e54653f5e7d240 (diff)
downloadsamba-235f37baa7df03ef44f71aea50d72603297a611d.tar.gz
lib:socket: get interface index from kernel
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib/socket')
-rw-r--r--lib/socket/interfaces.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/socket/interfaces.c b/lib/socket/interfaces.c
index e62da3c3a1f..3b15615b8d1 100644
--- a/lib/socket/interfaces.c
+++ b/lib/socket/interfaces.c
@@ -214,6 +214,12 @@ static int _get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
continue;
}
+ ifaces[total].if_index = if_nametoindex(ifptr->ifa_name);
+ if (ifaces[total].if_index == 0) {
+ DBG_ERR("Failed to retrieve interface index for '%s': "
+ "%s\n", ifptr->ifa_name, strerror(errno));
+ }
+
if (strlcpy(ifaces[total].name, ifptr->ifa_name,
sizeof(ifaces[total].name)) >=
sizeof(ifaces[total].name)) {