dhcpcd-discuss

Re: [BUG] dhcpcd 9.0.1: dhcpcd refused to start if ipv6 is not available

Juergen Daubert

Thu Apr 16 17:13:48 2020

On Thu, Apr 16, 2020 at 03:37:47PM +0100, Roy Marples wrote:
> Hi Juergen
> 
> On 16/04/2020 13:15, Juergen Daubert wrote:
> > Hallo,
> > 
> > this is on a Linux system without ipv6:
> > 
> > # dhcpcd -d
> > dhcpcd-9.0.1 starting
> > executing `/lib/dhcpcd/dhcpcd-run-hooks' CHROOT
> > spawned privileged actioneer on PID 1362
> > spawned network proxy on PID 1363
> > udev: starting
> > dev: loaded udev
> > chrooting to `/var/lib/dhcpcd'
> > ps_inet_startcb: ipv6nd_open: Address family not supported by protocol
> > ps_start: Address family not supported by protocol
> > enp8s0: if_disable_autolinklocal: Address family not supported by
> > protocol
> > enp8s0: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT
> > enp8s0: executing `/lib/dhcpcd/dhcpcd-run-hooks' CARRIER
> > DUID 00:01:00:01:26:26:fe:b6:2c:fd:a1:5a:a7:99
> > enp8s0: IAID a1:5a:a7:99
> > enp8s0: adding address fe80::bd1b:1c16:d5d4:cd7e
> > enp8s0: pltime infinity, vltime infinity
> > ipv6_addaddr1: Operation not supported
> > enp8s0: delaying IPv6 router solicitation for 0.6 seconds
> > enp8s0: delaying IPv4 for 1.3 seconds
> > ps_dostop: Connection refused
> > dev: unloaded udev
> > dhcpcd exited
> > 
> > Notes:
> > - works if dhcpcd is started with --ipv4only
> > - works with dhcpcd 8.1.8
> 
> Does the attached patch help at all?

Yep, that works.

many thanks
Juergen


> 
> Roy

> diff --git a/src/privsep-inet.c b/src/privsep-inet.c
> index 0cf50b42..9f1eeab7 100644
> --- a/src/privsep-inet.c
> +++ b/src/privsep-inet.c
> @@ -99,37 +99,37 @@ ps_inet_startcb(void *arg)
>  	close(ctx->ps_data_fd);
>  	ctx->ps_data_fd = -1;
>  
> +	errno = 0;
> +
>  #ifdef INET
>  	if ((ctx->options & (DHCPCD_IPV4 | DHCPCD_MASTER)) ==
>  	    (DHCPCD_IPV4 | DHCPCD_MASTER))
>  	{
>  		ctx->udp_fd = dhcp_openudp(NULL);
> -		if (ctx->udp_fd == -1) {
> +		if (ctx->udp_fd == -1)
>  			logerr("%s: dhcp_open", __func__);
> -			return -1;
> -		}
> -		if (eloop_event_add(ctx->eloop, ctx->udp_fd,
> +		else if (eloop_event_add(ctx->eloop, ctx->udp_fd,
>  		    ps_inet_recvbootp, ctx) == -1)
>  		{
>  			logerr("%s: eloop_event_add DHCP", __func__);
> -			return -1;
> -		}
> -		ret++;
> +			close(ctx->udp_fd);
> +			ctx->udp_fd = -1;
> +		} else
> +			ret++;
>  	}
>  #endif
>  #if defined(INET6) && !defined(__sun)
>  	if (ctx->options & DHCPCD_IPV6) {
> -		if (ipv6nd_open(ctx) == -1) {
> +		if (ipv6nd_open(ctx) == -1)
>  			logerr("%s: ipv6nd_open", __func__);
> -			return -1;
> -		}
> -		if (eloop_event_add(ctx->eloop, ctx->nd_fd,
> +		else if (eloop_event_add(ctx->eloop, ctx->nd_fd,
>  		    ps_inet_recvra, ctx) == -1)
>  		{
>  			logerr("%s: eloop_event_add RA", __func__);
> -			return -1;
> -		}
> -		ret++;
> +			close(ctx->nd_fd);
> +			ctx->nd_fd = -1;
> +		} else
> +			ret++;
>  	}
>  #endif
>  #ifdef DHCP6
> @@ -137,21 +137,20 @@ ps_inet_startcb(void *arg)
>  	    (DHCPCD_DHCP6 | DHCPCD_MASTER))
>  	{
>  		ctx->dhcp6_fd = dhcp6_openudp(0, NULL);
> -		if (ctx->dhcp6_fd == -1) {
> +		if (ctx->dhcp6_fd == -1)
>  			logerr("%s: dhcp6_open", __func__);
> -			return -1;
> -		}
> -		if (eloop_event_add(ctx->eloop, ctx->dhcp6_fd,
> +		else if (eloop_event_add(ctx->eloop, ctx->dhcp6_fd,
>  		    ps_inet_recvdhcp6, ctx) == -1)
>  		{
>  			logerr("%s: eloop_event_add DHCP6", __func__);
> -			return -1;
> -		}
> -		ret++;
> +			close(ctx->dhcp6_fd);
> +			ctx->dhcp6_fd = -1;
> +		} else
> +			ret++;
>  	}
>  #endif
>  
> -	if (ret == 0) {
> +	if (ret == 0 && errno == 0) {
>  		errno = ENXIO;
>  		return -1;
>  	}


References:
[BUG] dhcpcd 9.0.1: dhcpcd refused to start if ipv6 is not availableJuergen Daubert
Re: [BUG] dhcpcd 9.0.1: dhcpcd refused to start if ipv6 is not availableRoy Marples
Archive administrator: postmaster@marples.name