summaryrefslogtreecommitdiff
path: root/dev.c
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-17 22:45:53 +0200
committerDaniel Borkmann <dborkman@redhat.com>2013-06-17 22:45:53 +0200
commit9a3134494188611a2866f6e2406296d43913cd4e (patch)
tree1c29cf54136c9df1d81230307f3948ba2a17e638 /dev.c
parent1bb8cf17318a09ee55a99043703512ec37560b29 (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.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/dev.c b/dev.c
index 210487c..6488f4a 100644
--- a/dev.c
+++ b/dev.c
@@ -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;