The officially official Devuan Forum!

You are not logged in.

#1 2018-06-04 20:08:08

msi
Member
Registered: 2017-02-04
Posts: 143  

Problems with NTP and network config after upgrade

Since I have upgraded from Jessie to ASCII, I'm getting the following warning about NTP on shutdown, which is apparently somehow connected to network device configuration:

DHCPRELEASE on wlan0 to 192.168.178.1 port 67
invoke-rc.d: -----------------------------------------------------
invoke-rc.d: WARNING: 'invoke-rc.d ntp try-restart' called
invoke-rc.d: during shutdown sequence.
invoke-rc.d: enabling safe mode: initscript policy layer disabled
invoke-rc.d: -----------------------------------------------------
done

I hadn't heard of invoke-rc.d before, so I looked it up. The manual page says it's "a generic interface to execute System V style init script /etc/init.d/name actions" and that "all access to the init scripts by Debian packages' maintainer scripts should be done through invoke-rc.d".

I had initially tried to solve the problem by editing /etc/init.d/ntp. But that doesn't seem right, so I restored the original file from backup.

How can I find out now what is calling invoke-rc.d ntp try-restart during shutdown and why?

As for this issue being connected to the network device settings, I've found the following: When I use auto wlan0 instead of allow-hotplug wlan0 in /etc/network/interfaces (where I do all my network configuration), I'll get this during boot:

DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPREQUEST of 192.168.178.21 on wlan0 to 255.255.255.255 port 67
DHCPOFFER of 192.168.178.21 from 192.168.178.1
DHCPACK of 192.168.178.21 from 192.168.178.1
invoke-rc.d: could not determine current runlevel
bound to 192.168.178.21 -- renewal in 400249 seconds.

First, these messages are not shown when using the allow-hotplug configuration. In that case, all that is shown of the network device configuration during boot is:

Configuring network interfaces...ifup: waiting for lock on /run/network/ifstate.wlan0
ifup: interface wlan0 already configured

Second, there's an error message in there. And even though I understand what it says, I have no clue what to do about that.

The warning message displayed on shutdown is the same in both cases.

Any ideas?

Last edited by msi (2018-06-12 15:56:47)

Offline

#2 2018-06-05 05:11:09

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,251  

Re: Problems with NTP and network config after upgrade

I followed Luke to the source, and saw that ntp has a script added into /etc/dhcp/dhclient-exit-hooks.d/ that apparently does some willy-nilly restart attempt upon dhcp events,

Offline

#3 2018-06-06 08:42:12

msi
Member
Registered: 2017-02-04
Posts: 143  

Re: Problems with NTP and network config after upgrade

That script seems to be there to make sure NTP is being restarted automatically when bringing up and down network interfaces that get their IP address through DHCP.

I've dug a little deeper and found that it has been part of the ntp package at least since Debian Wheezy. Also, it's identical in the Wheezy and Jessie packages, but has seen minor changes in Stretch.

These are:

1. Line 2 was changed from

NTP_DHCP_CONF=/var/lib/ntp/ntp.conf.dhcp

to

NTP_DHCP_CONF=/run/ntp.conf.dhcp

2. Line 43 was changed from

sed -r -e '/^ *(server|peer).*$/d' $NTP_CONF

to

sed '/^[[:space:]]*\(server\|peer\|pool\)[[:space:]]/d' $NTP_CON

I temporarily replaced the current verison of the file with that from Jessie to see if it would make any difference and it didn't. So, the root of the problem must be somewhere else.

Offline

#4 2018-06-12 17:39:38

msi
Member
Registered: 2017-02-04
Posts: 143  

Re: Problems with NTP and network config after upgrade

msi wrote:

I temporarily replaced the current verison of the file with that from Jessie to see if it would make any difference and it didn't. So, the root of the problem must be somewhere else.

Well, maybe not. I've found that throwing out /etc/dhcp/dhclient-exit-hooks.d/ntp will make both of the error messages mentioned above go away. So, the one on boot is obviously also triggered by it. There will, of course, be no automatic handling of ntp restarts on DHCP events if the file is missing.

I've been trying to understand what this script really does and I kind of do. But the ntp_servers_setup function is still a mystery to me. Where does it get the value for $reason? It's simply not defined within the script. And neither are $new_ntp_servers and $old_ntp_servers, which are used in the ntp_servers_setup_add function.

Here's the entire file:

NTP_CONF=/etc/ntp.conf
NTP_DHCP_CONF=/run/ntp.conf.dhcp

ntp_server_restart() {
	invoke-rc.d ntp try-restart
}

ntp_servers_setup_remove() {
	if [ ! -e $NTP_DHCP_CONF ]; then
		return
	fi
	rm -f $NTP_DHCP_CONF
	ntp_server_restart
}

ntp_servers_setup_add() {
	if [ -e $NTP_DHCP_CONF ] && [ "$new_ntp_servers" = "$old_ntp_servers" ]; then
		return
	fi

	if [ -z "$new_ntp_servers" ]; then
		ntp_servers_setup_remove
		return
	fi

	tmp=$(mktemp "$NTP_DHCP_CONF.XXXXXX") || return
	chmod --reference=$NTP_CONF $tmp
	chown --reference=$NTP_CONF $tmp

	(
	  echo "# This file was copied from $NTP_CONF with the server options changed"
	  echo "# to reflect the information sent by the DHCP server.  Any changes made"
	  echo "# here will be lost at the next DHCP event.  Edit $NTP_CONF instead."
	  echo
	  echo "# NTP server entries received from DHCP server"
	  for server in $new_ntp_servers; do
		echo "server $server iburst"
	  done
	  echo
	  sed '/^[[:space:]]*\(server\|peer\|pool\)[[:space:]]/d' $NTP_CONF
	) >>$tmp
	
	mv $tmp $NTP_DHCP_CONF

	ntp_server_restart
}

ntp_servers_setup() {
	case $reason in
		BOUND|RENEW|REBIND|REBOOT)
			ntp_servers_setup_add
			;;
		EXPIRE|FAIL|RELEASE|STOP)
			ntp_servers_setup_remove
			;;
	esac
}

ntp_servers_setup

Last edited by msi (2018-06-12 17:42:33)

Offline

#5 2018-09-03 18:05:13

xrogaan
Member
Registered: 2018-09-03
Posts: 2  

Re: Problems with NTP and network config after upgrade

The reason there is a ntp hook for dhcp is to override the system configuration with the ntp servers advertised through dhcp. You could get rid of it all by removing 'ntp-server' from the dhclient.conf request line. I haven't tested it yet though, so if I don't correct myself assume what I said to be accurate.

Offline

Board footer