From owner-svn-src-stable-8@FreeBSD.ORG Tue Feb 26 19:14:30 2013 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E21BC28B; Tue, 26 Feb 2013 19:14:30 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BC42119F0; Tue, 26 Feb 2013 19:14:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1QJEUNI029260; Tue, 26 Feb 2013 19:14:30 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1QJEUmp029257; Tue, 26 Feb 2013 19:14:30 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201302261914.r1QJEUmp029257@svn.freebsd.org> From: John Baldwin Date: Tue, 26 Feb 2013 19:14:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r247336 - stable/8/sbin/dhclient X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Feb 2013 19:14:31 -0000 Author: jhb Date: Tue Feb 26 19:14:29 2013 New Revision: 247336 URL: http://svnweb.freebsd.org/changeset/base/247336 Log: MFC 239356,239564: Teach dhclient to track changes in link state and to enter the reboot state when the link on an interface goes up causing dhclient to attempt to renew its existing lease. PR: bin/166656 Modified: stable/8/sbin/dhclient/dhclient.c stable/8/sbin/dhclient/dhcpd.h Directory Properties: stable/8/sbin/dhclient/ (props changed) Modified: stable/8/sbin/dhclient/dhclient.c ============================================================================== --- stable/8/sbin/dhclient/dhclient.c Tue Feb 26 19:14:05 2013 (r247335) +++ stable/8/sbin/dhclient/dhclient.c Tue Feb 26 19:14:29 2013 (r247336) @@ -218,6 +218,7 @@ routehandler(struct protocol *p) 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 @@ routehandler(struct protocol *p) 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 @@ main(int argc, char *argv[]) } 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: stable/8/sbin/dhclient/dhcpd.h ============================================================================== --- stable/8/sbin/dhclient/dhcpd.h Tue Feb 26 19:14:05 2013 (r247335) +++ stable/8/sbin/dhclient/dhcpd.h Tue Feb 26 19:14:29 2013 (r247336) @@ -208,6 +208,7 @@ struct interface_info { int errors; int dead; u_int16_t index; + int linkstat; }; struct timeout {