[ntp:questions] ntpd 4.2.6p5 will not synchronize to broadcast servers

Gary Johnson garyjohn at eskimo.com
Thu Apr 25 00:09:51 UTC 2013


We have a system that uses ntpd to synchronize the system clock.  We
allow the user to run ntpd in polling mode with a user-specified set of
servers, or in broadcast mode, accepting any broadcast NTP messages
received.

This used to work fine with ntpd 4.2.4p7.  Since upgrading to 4.2.6p5,
polling mode continues to work fine but broadcast mode does not work at
all--ntpd never sees any broadcast messages.

The reason seems to be that ntpd 4.2.6p4 tries to initialize the
broadcast interface before initializing its list of available
interfaces.  Here is a simple invocation of ntpd that exhibits the
problem.  Note the message about "no broadcast interfaces available" on
the seventh line of output below.

    $ ntpd -4 -b -D2 -c /dev/null
    ntpd 4.2.6p5 at 1.2349-o Fri Apr 19 01:23:45 UTC 2013 (1)
    24 Apr 23:58:35 ntpd[17867]: set_process_priority: Leave priority alone: priority_done is <2>
    24 Apr 23:58:35 ntpd[17867]: proto: precision = 5.380 usec
    loop_config: item 1 freq 0.000000
    event at 0 0.0.0.0 c01d 0d kern kernel time sync enabled
    proto_config: code 1 value 1 dvalue 0.000000
    24 Apr 23:58:35 ntpd[17867]: Unable to listen for broadcasts, no broadcast interfaces available
    24 Apr 23:58:35 ntpd[17867]: line 1999510120 column 0 syntax error, unexpected $end
    Finished Parsing!!
    create_sockets(123)
    24 Apr 23:58:35 ntpd[17867]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16
    24 Apr 23:58:35 ntpd[17867]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
    created interface #0: fd=16, bfd=-1, name=v4wildcard, flags=0x89, ifindex=0, sin=0.0.0.0, bcast=0.0.0.0, mask=255.255.255.255, Disabled:
    create_interface(127.0.0.1#123)
    24 Apr 23:58:35 ntpd[17867]: Listen normally on 1 lo 127.0.0.1 UDP 123
    restrict: op 1 addr 127.0.0.1 mask 255.255.255.255 mflags 00003000 flags 00000001
    created interface #1: fd=17, bfd=-1, name=lo, flags=0x5, ifindex=0, sin=127.0.0.1, mask=255.0.0.0, Enabled:
    create_interface(10.10.143.200#123)
    24 Apr 23:58:35 ntpd[17867]: Listen normally on 2 eth0 10.10.143.200 UDP 123
    restrict: op 1 addr 10.10.143.200 mask 255.255.255.255 mflags 00003000 flags 00000001
    created interface #2: fd=18, bfd=-1, name=eth0, flags=0x19, ifindex=0, sin=10.10.143.200, bcast=10.10.143.255, mask=255.255.255.0, Enabled:
    create_interface(10.27.50.174#123)
    24 Apr 23:58:35 ntpd[17867]: Listen normally on 3 remote 10.27.50.174 UDP 123
    restrict: op 1 addr 10.27.50.174 mask 255.255.255.255 mflags 00003000 flags 00000001
    created interface #3: fd=19, bfd=-1, name=remote, flags=0x19, ifindex=0, sin=10.27.50.174, bcast=10.27.50.255, mask=255.255.255.0, Enabled:
    24 Apr 23:58:35 ntpd[17867]: peers refreshed
    create_sockets: Total interfaces = 4
    24 Apr 23:58:35 ntpd[17867]: Listening on routing socket on fd #20 for interface updates
    auth_setkey: key 65535 type 4 len 4 6ee30717
    event at 0 0.0.0.0 c016 06 restart
    loop_config: item 2 freq 1000000000.000000
    event at 0 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
    local_clock: mu 0 state 1 poll 3 count 0
    event at 0 0.0.0.0 c011 01 freq_not_set
    auth_agekeys: at 1 keys 1 expired 0
    timer: interface update

After waiting long enough for a broadcast message to have been sent by
ntpd running on another host,

    $ ntpq -crv
    receive: at 96 127.0.0.1<-127.0.0.1 flags 5 restrict 000
    sendpkt(17, dst=127.0.0.1, src=127.0.0.1, ttl=-6, len=372)
    associd=0 status=c011 leap_alarm, sync_unspec, 1 event, freq_not_set,
    version="ntpd 4.2.6p5 at 1.2349-o Fri Apr 19 01:23:45 UTC 2013 (1)",
    processor="mips64", system="Linux/3.4.34", leap=11, stratum=16,
    precision=-17, rootdelay=0.000, rootdisp=1.440, refid=INIT,
    reftime=00000000.00000000  Thu, Feb  7 2036  6:28:16.000,
    clock=d522f08b.f70b1c35  Thu, Apr 25 2013  0:00:11.965, peer=0, tc=3,
    mintc=3, offset=0.000, frequency=0.000, sys_jitter=0.000,
    clk_jitter=0.008, clk_wander=0.000

I looked at the source code for both versions of ntpd and saw that in
4.2.4p7, the list of interfaces was initialized by the following cascade
of function calls,

    ntpdmain() --> init_io() --> create_sockets()

In 4.2.6p4, however, most of the contents of the function init_io() have
been stripped out, including the call to create_sockets().  In 4.2.6p4,
create_sockets() is not called until later, after the attempt to create
the broadcast interface.

Is ntpd 4.2.6p4 really broken w.r.t. receiving broadcasts, or do we have
something configured incorrectly?

Regards,
Gary



More information about the questions mailing list