diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-06-17 22:45:53 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-06-17 22:45:53 +0200 |
commit | 9a3134494188611a2866f6e2406296d43913cd4e (patch) | |
tree | 1c29cf54136c9df1d81230307f3948ba2a17e638 /dev.c | |
parent | 1bb8cf17318a09ee55a99043703512ec37560b29 (diff) |
dev: bail out if ifindex could not be retrieved
If we fail to find the ifindex of a given device, bail out.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'dev.c')
-rw-r--r-- | dev.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -9,6 +9,7 @@ #include "sock.h" #include "die.h" #include "link.h" +#include "built_in.h" int device_ifindex(const char *ifname) { @@ -24,11 +25,10 @@ int device_ifindex(const char *ifname) strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); ret = ioctl(sock, SIOCGIFINDEX, &ifr); - if (!ret) - index = ifr.ifr_ifindex; - else - index = -1; + if (unlikely(ret)) + panic("Cannot get ifindex from device!\n"); + index = ifr.ifr_ifindex; close(sock); return index; |