Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Aug 2012 13:53:37 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r239564 - head/sbin/dhclient
Message-ID:  <201208221353.q7MDrbYB039551@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Aug 22 13:53:37 2012
New Revision: 239564
URL: http://svn.freebsd.org/changeset/base/239564

Log:
  Revert r239356 and use an alternate algorithm.
  
  First, don't exit when the link goes down on an interface.  Instead,
  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.
  
  Second, remove the change I added to clear the old lease when dhclient
  exits due to an error (such as ifconfig down).  If an interface is
  using autoconfiguration it should keep its autoconfiguration as much as
  possible.  If the next time it needs a configuration it is able to reuse
  the previous autoconfiguration, then leaving the settings intact allows
  existing connections to survive temporary outages, etc.
  
  PR:		bin/166656
  MFC after:	1 month

Modified:
  head/sbin/dhclient/dhclient.c
  head/sbin/dhclient/dhcpd.h

Modified: head/sbin/dhclient/dhclient.c
==============================================================================
--- head/sbin/dhclient/dhclient.c	Wed Aug 22 08:27:37 2012	(r239563)
+++ head/sbin/dhclient/dhclient.c	Wed Aug 22 13:53:37 2012	(r239564)
@@ -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,10 +279,14 @@ routehandler(struct protocol *p)
 			    ifi->name);
 			goto die;
 		}
-		if (!interface_link_status(ifi->name)) {
-			warning("Interface %s is down, dhclient exiting",
-			    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:
@@ -321,8 +326,6 @@ routehandler(struct protocol *p)
 
 die:
 	script_init("FAIL", NULL);
-	if (ifi->client->active)
-		script_write_params("old_", ifi->client->active);
 	if (ifi->client->alias)
 		script_write_params("alias_", ifi->client->alias);
 	script_go();
@@ -437,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: head/sbin/dhclient/dhcpd.h
==============================================================================
--- head/sbin/dhclient/dhcpd.h	Wed Aug 22 08:27:37 2012	(r239563)
+++ head/sbin/dhclient/dhcpd.h	Wed Aug 22 13:53:37 2012	(r239564)
@@ -208,6 +208,7 @@ struct interface_info {
 	int			 errors;
 	int			 dead;
 	u_int16_t		 index;
+	int			 linkstat;
 };
 
 struct timeout {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208221353.q7MDrbYB039551>