diff options
author | 2014-11-27 23:04:12 +0000 | |
---|---|---|
committer | 2014-11-27 23:04:12 +0000 | |
commit | 54e7c2609e4c0d0eeb8a7dcffe1343dd3c01ae9f (patch) | |
tree | a279e7229e76f98277187eb51c3ec7eb00c3fd20 | |
parent | Multiple fixes with respect to .Eo: (diff) | |
download | wireguard-openbsd-54e7c2609e4c0d0eeb8a7dcffe1343dd3c01ae9f.tar.xz wireguard-openbsd-54e7c2609e4c0d0eeb8a7dcffe1343dd3c01ae9f.zip |
Use if_nametoindex() to get the interface index, and thereby check
the validity of the interface name as soon the actual name is known.
i.e. right after 'egress' is expanded. One less thing for
get_hw_address() to do.
-rw-r--r-- | sbin/dhclient/dhclient.c | 5 | ||||
-rw-r--r-- | sbin/dhclient/dispatch.c | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 73ccaad4dfc..04c5884fbf0 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.335 2014/11/25 17:03:03 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.336 2014/11/27 23:04:12 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -468,6 +468,9 @@ main(int argc, char *argv[]) if (ifi == NULL) error("ifi calloc"); get_ifname(argv[0]); + ifi->index = if_nametoindex(ifi->name); + if (ifi->index == 0) + error("'%s' is not an interface", ifi->name); tzset(); diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index 26c30c4cd4f..0f4fbfd4d25 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.97 2014/11/26 19:25:31 krw Exp $ */ +/* $OpenBSD: dispatch.c,v 1.98 2014/11/27 23:04:12 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -82,7 +82,6 @@ get_hw_address(void) sdl->sdl_alen != ETHER_ADDR_LEN) continue; - ifi->index = sdl->sdl_index; memcpy(ifi->hw_address.ether_addr_octet, LLADDR(sdl), ETHER_ADDR_LEN); } |