From owner-freebsd-net@freebsd.org Fri Feb 8 07:05:41 2019 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 02A5A14D6650 for ; Fri, 8 Feb 2019 07:05:41 +0000 (UTC) (envelope-from kib@freebsd.org) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 492026CA08 for ; Fri, 8 Feb 2019 07:05:40 +0000 (UTC) (envelope-from kib@freebsd.org) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x1875TL4046028 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 8 Feb 2019 09:05:32 +0200 (EET) (envelope-from kib@freebsd.org) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x1875TL4046028 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x1875Sht046026; Fri, 8 Feb 2019 09:05:28 +0200 (EET) (envelope-from kib@freebsd.org) X-Authentication-Warning: tom.home: kostik set sender to kib@freebsd.org using -f Date: Fri, 8 Feb 2019 09:05:28 +0200 From: Konstantin Belousov To: Nash Kaminski Cc: freebsd-net@freebsd.org Subject: Re: dhclient appears to misinterpret the exit status of dhclient-script Message-ID: <20190208070528.GL24863@kib.kiev.ua> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.2 (2019-01-07) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Feb 2019 07:05:41 -0000 On Thu, Feb 07, 2019 at 08:45:32PM -0600, Nash Kaminski wrote: > Hello, > > I have been attempting to debug a peculiar issue with dhclient on a > vanilla FreeBSD 11.2 system where it appears that even if > dhclient-script returns nonzero when invoked in response to a protocol > timeout, dhclient continues as if the address was bound successfully, > as opposed to the protocol being restarted after the defined retry > interval. > > After some investigation, it appears that the root cause of this > behavior is a result of the lower byte of the exit status being > returned, instead of the upper byte containing the return code, on > line 2319 of sbin/dhclient/dhclient.c (Ref: > https://github.com/freebsd/freebsd/blob/releng/11.2/sbin/dhclient/dhclient.c#L2319). > > Making the following change makes dhclient behave as expected. Am I > missing something or is there indeed a significant bug here? > > Index: sbin/dhclient/dhclient.c > =================================================================== > --- sbin/dhclient/dhclient.c (revision 342377) > +++ sbin/dhclient/dhclient.c (working copy) > @@ -2316,7 +2316,7 @@ > if (ip) > script_flush_env(ip->client); > > - return (wstatus & 0xff); > + return WEXITSTATUS(wstatus); > > } > Your finding sounds reasonable and from my code read it is correct. But I never looked at the dhclient code, so I prefer somebody more knowledgable of it to look. If nobody takes the patch in 3-5 days, ping me and I will commit it.