Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Feb 2019 09:05:28 +0200
From:      Konstantin Belousov <kib@freebsd.org>
To:        Nash Kaminski <nashkaminski@gmail.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: dhclient appears to misinterpret the exit status of dhclient-script
Message-ID:  <20190208070528.GL24863@kib.kiev.ua>
In-Reply-To: <CAEF9=Z7Rz58uyic3bBtMJgy5Zv1feFtL1BJdcu7XP_N=uVoosg@mail.gmail.com>
References:  <CAEF9=Z7Rz58uyic3bBtMJgy5Zv1feFtL1BJdcu7XP_N=uVoosg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



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