[Midnightbsd-cvs] src [8834] trunk/sbin/dhclient: teach dhclient to track changes in link state
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Sep 25 23:59:24 EDT 2016
Revision: 8834
http://svnweb.midnightbsd.org/src/?rev=8834
Author: laffer1
Date: 2016-09-25 23:59:24 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
teach dhclient to track changes in link state
Modified Paths:
--------------
trunk/sbin/dhclient/dhclient.c
trunk/sbin/dhclient/dhcpd.h
Modified: trunk/sbin/dhclient/dhclient.c
===================================================================
--- trunk/sbin/dhclient/dhclient.c 2016-09-26 03:58:46 UTC (rev 8833)
+++ trunk/sbin/dhclient/dhclient.c 2016-09-26 03:59:24 UTC (rev 8834)
@@ -218,6 +218,7 @@
struct sockaddr *sa;
struct iaddr a;
ssize_t n;
+ int linkstat;
n = read(routefd, &msg, sizeof(msg));
rtm = (struct rt_msghdr *)msg;
@@ -278,6 +279,15 @@
ifi->name);
goto die;
}
+ linkstat = interface_link_status(ifi->name);
+ if (linkstat != ifi->linkstat) {
+ debug("%s link state %s -> %s", ifi->name,
+ ifi->linkstat ? "up" : "down",
+ linkstat ? "up" : "down");
+ ifi->linkstat = linkstat;
+ if (linkstat)
+ state_reboot(ifi);
+ }
break;
case RTM_IFANNOUNCE:
ifan = (struct if_announcemsghdr *)rtm;
@@ -430,6 +440,7 @@
}
fprintf(stderr, " got link\n");
}
+ ifi->linkstat = 1;
if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1)
error("cannot open %s: %m", _PATH_DEVNULL);
Modified: trunk/sbin/dhclient/dhcpd.h
===================================================================
--- trunk/sbin/dhclient/dhcpd.h 2016-09-26 03:58:46 UTC (rev 8833)
+++ trunk/sbin/dhclient/dhcpd.h 2016-09-26 03:59:24 UTC (rev 8834)
@@ -208,6 +208,7 @@
int errors;
int dead;
u_int16_t index;
+ int linkstat;
};
struct timeout {
More information about the Midnightbsd-cvs
mailing list