Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 49799 - ntpd must be restarted when network connection reset; isn't
Summary: ntpd must be restarted when network connection reset; isn't
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: SpanKY
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-02 21:39 UTC by Craig Lawson
Modified: 2004-06-23 17:54 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Lawson 2004-05-02 21:39:38 UTC
ntpd (package: ntp 4.2.0-r2) is currently started after the network. This is fine for permanent network connections, but is incorrect for part-time connections such as PPPoE.

Once was a time when ntpd would restore connections to its time servers if the network connection was dropped and restored. However, it would only do so if it was was started *before* the connection to the Internet was established.

Version 4.2.0 appears to no longer support this undocumented feature. With 4.2.0, if network connectivity is lost, ntpd's "when" counters continue to count past their poll time and keep going ... to infinity and beyond. ntpd does not recover when the network connection is restored.

Gentoo's current configuration insures that ntpd will lose sync forever if the network connection is brought down.

Reproducible: Always
Steps to Reproduce:
1. Insure that network is down and ntpd is not running.
2. adsl-start
3. /etc/init.d/ntpd start
4. Wait for ntpd to sync. Check with "ntpq -p".
5. adsl-stop
6. Wait for ntpd's "when" counters to exceed the poll interval ("ntpq -p" again). (Actually, I'm not sure about this -- you may not have to wait at all.)
7. adsl-start
8. See how ntpd is doing ("ntpq -p" again).
Actual Results:  
ntpd fails to sync with any of its time servers. "When" counters just keep on
counting.

Expected Results:  
Should sync.

For this scenario, /etc/init.d/ntp-client is similarly ineffectual.

My solution was to append the following to "/etc/ppp/if-up.local":

  [ "$1" == "ppp0" ] && [ -x /etc/init.d/ntpd ] && /etc/init.d/ntpd start

and this to "/etc/ppp/ip-down.local":

  [ "$1" == "ppp0" ] && [ -x /etc/init.d/ntpd ] && /etc/init.d/ntpd stop


These modifications are rather specific to my installation (e.g. "ppp0" as
Internet connection) and also assumes that if the ntpd package is installed,
then ntpd should be started. Also required is that ntpd not be started with the
rc-update mechanism.

I don't know how well these suggestions fit into Gentoo's package architecture,
but this is what currently works for me.
Comment 1 Craig Lawson 2004-05-02 22:16:39 UTC
Found this:  http://bugzilla.ntp.org/show_bug.cgi?id=51

Confirms my situation, and recommends against the "trick" of starting ntpd before the network. Their script is more sophisticated than my solution, though the issue of invoking the script at the right time remains.
Comment 2 SpanKY gentoo-dev 2004-05-15 22:48:31 UTC
although we could try to implement those scripts partially in our network init.d scripts, that would 'work' only for the people who use those methods of connecting to the net ...

there are many more ways, and not everyone uses them ... so really the only 'proper' fix is for ntpd guys to find something :/