From owner-svn-src-all@FreeBSD.ORG Fri Aug 6 08:21:03 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6168A1065672; Fri, 6 Aug 2010 08:21:03 +0000 (UTC) (envelope-from brian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4F06D8FC20; Fri, 6 Aug 2010 08:21:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o768L3GM056788; Fri, 6 Aug 2010 08:21:03 GMT (envelope-from brian@svn.freebsd.org) Received: (from brian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o768L34T056786; Fri, 6 Aug 2010 08:21:03 GMT (envelope-from brian@svn.freebsd.org) Message-Id: <201008060821.o768L34T056786@svn.freebsd.org> From: Brian Somers Date: Fri, 6 Aug 2010 08:21:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r210916 - stable/7/sbin/dhclient X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2010 08:21:03 -0000 Author: brian Date: Fri Aug 6 08:21:03 2010 New Revision: 210916 URL: http://svn.freebsd.org/changeset/base/210916 Log: MFC r209756: Log dhclient's reason for exiting and change the 10 second ignore-routing-messages dhclient-script timeout to be effective from script completion rather than from script start time. Ignore RTM_DELADDR and RTM_NEWADDR messages when the message contains no interface address (which should not happen) rather than exiting. Modified: stable/7/sbin/dhclient/dhclient.c Directory Properties: stable/7/sbin/dhclient/ (props changed) Modified: stable/7/sbin/dhclient/dhclient.c ============================================================================== --- stable/7/sbin/dhclient/dhclient.c Fri Aug 6 08:17:44 2010 (r210915) +++ stable/7/sbin/dhclient/dhclient.c Fri Aug 6 08:21:03 2010 (r210916) @@ -126,7 +126,7 @@ int fork_privchld(int, int); ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) #define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) -time_t scripttime; +static time_t scripttime; int findproto(char *cp, int n) @@ -204,7 +204,7 @@ disassoc(void *arg) void routehandler(struct protocol *p) { - char msg[2048]; + char msg[2048], *addr; struct rt_msghdr *rtm; struct if_msghdr *ifm; struct ifa_msghdr *ifam; @@ -224,13 +224,6 @@ routehandler(struct protocol *p) switch (rtm->rtm_type) { case RTM_NEWADDR: - /* - * XXX: If someone other than us adds our address, - * we should assume they are taking over from us, - * delete the lease record, and exit without modifying - * the interface. - */ - break; case RTM_DELADDR: ifam = (struct ifa_msghdr *)rtm; @@ -243,7 +236,7 @@ routehandler(struct protocol *p) sa = get_ifa((char *)(ifam + 1), ifam->ifam_addrs); if (sa == NULL) - goto die; + break; if ((a.len = sizeof(struct in_addr)) > sizeof(a.iabuf)) error("king bula sez: len mismatch"); @@ -255,21 +248,42 @@ routehandler(struct protocol *p) if (addr_eq(a, l->address)) break; - if (l == NULL) /* deleted addr is not the one we set */ + if (l == NULL) /* added/deleted addr is not the one we set */ break; - goto die; + + addr = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr); + if (rtm->rtm_type == RTM_NEWADDR) { + /* + * XXX: If someone other than us adds our address, + * should we assume they are taking over from us, + * delete the lease record, and exit without modifying + * the interface? + */ + warning("My address (%s) was re-added", addr); + } else { + warning("My address (%s) was deleted, dhclient exiting", + addr); + goto die; + } + break; case RTM_IFINFO: ifm = (struct if_msghdr *)rtm; if (ifm->ifm_index != ifi->index) break; - if ((rtm->rtm_flags & RTF_UP) == 0) + if ((rtm->rtm_flags & RTF_UP) == 0) { + warning("Interface %s is down, dhclient exiting", + ifi->name); goto die; + } break; case RTM_IFANNOUNCE: ifan = (struct if_announcemsghdr *)rtm; if (ifan->ifan_what == IFAN_DEPARTURE && - ifan->ifan_index == ifi->index) + ifan->ifan_index == ifi->index) { + warning("Interface %s is gone, dhclient exiting", + ifi->name); goto die; + } break; case RTM_IEEE80211: ifan = (struct if_announcemsghdr *)rtm; @@ -2110,8 +2124,6 @@ script_go(void) struct buf *buf; int ret; - scripttime = time(NULL); - hdr.code = IMSG_SCRIPT_GO; hdr.len = sizeof(struct imsg_hdr); @@ -2132,6 +2144,8 @@ script_go(void) error("received corrupted message"); buf_read(privfd, &ret, sizeof(ret)); + scripttime = time(NULL); + return (ret); }