summaryrefslogtreecommitdiff
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2012-06-24 16:01:19 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2012-06-24 16:01:19 +0000
commit03c9f4e68367b75f6c3a2dc21ff459c891eb7ebe (patch)
tree8444999bfe7b0e115b41c4ffde41853ee6d06a86 /sbin/dhclient
parentc090cde0fbe9c5a32b2a7cbb2472ec07ffcfa58c (diff)
Nuke interface_link_status() (check media status only) and use
interface_status() (check IFF_UP|IFF_RUNNING and media status). The interface is forced up when dhclient starts so the flags should be correct. Thanks to guenther@ for pointing out the original raison d'etre of the difference between the two.
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/dhclient.c6
-rw-r--r--sbin/dhclient/dhcpd.h3
-rw-r--r--sbin/dhclient/dispatch.c33
3 files changed, 5 insertions, 37 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 3a1c03ecaea..3c667bc9315 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.144 2012/06/22 00:08:43 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.145 2012/06/24 16:01:18 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -242,7 +242,7 @@ routehandler(void)
ifi->linkstat ? "up" : "down",
linkstat ? "up" : "down");
#endif
- ifi->linkstat = interface_link_status(ifi->name);
+ ifi->linkstat = interface_status(ifi->name);
if (ifi->linkstat) {
client->state = S_REBOOTING;
state_reboot();
@@ -347,7 +347,7 @@ main(int argc, char *argv[])
} else
i = 0;
- while (!(ifi->linkstat = interface_link_status(ifi->name))) {
+ while (!(ifi->linkstat = interface_status(ifi->name))) {
if (i == 0)
fprintf(stderr, "%s: no link ...", ifi->name);
else if (i > 0)
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index a8ebc6e8b76..f2cc00b27d7 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.74 2011/12/10 15:55:43 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.75 2012/06/24 16:01:18 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -253,7 +253,6 @@ void dispatch(void);
void got_one(void);
void add_timeout(time_t, void (*)(void));
void cancel_timeout(void (*)(void));
-int interface_link_status(char *);
int interface_status(char *);
int interface_link_forceup(char *);
int get_rdomain(char *);
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 206cef12f36..6bc23353711 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.50 2012/06/22 01:01:59 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.51 2012/06/24 16:01:18 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -400,37 +400,6 @@ cancel_timeout(void (*where)(void))
}
int
-interface_link_status(char *ifname)
-{
- struct ifmediareq ifmr;
- int sock;
-
- if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- error("Can't create socket");
-
- memset(&ifmr, 0, sizeof(ifmr));
- strlcpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name));
- if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) {
- /* EINVAL/ENOTTY -> link state unknown. treat as active */
-#ifdef DEBUG
- if (errno != EINVAL && errno != ENOTTY)
- debug("ioctl(SIOCGIFMEDIA) on %s: %m", ifname);
-#endif
- close(sock);
- return (1);
- }
- close(sock);
-
- if (ifmr.ifm_status & IFM_AVALID) {
- if (ifmr.ifm_status & IFM_ACTIVE)
- return (1);
- else
- return (0);
- }
- return (1);
-}
-
-int
get_rdomain(char *name)
{
int rv = 0, s;