[chrony-dev] [RFC PATCH 0/9] Allow sources with same IP address and different port

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


With the ptpport directive, a chronyd server answers on both the NTP
port and the PTP port (RFC 10030). A client can't use both, though,
because chronyd identifies an NTP source by its IP address. A server
can only be specified with one of the ports, and a second source with
the same address is rejected as already in use, or stays unresolved if
it's specified by name.

That makes NTP over PTP harder to roll out in an existing network.
Enabling it incrementally next to NTP, with NTP still available as a
fallback, typically means giving every server a second IP address.

This series makes the address and port together identify an NTP
source. A server specified twice, once with the PTP port and once
without the port option, gives two independent sources. Each has its
own state, statistics, and dump file, and source selection treats them
like any other two sources. For example:

  ptpport 319
  server ntp1.example.net xleave port 319 extfield 10A
  server ntp1.example.net xleave

Logs, dump file names, and chronyc output include the port when it
isn't the NTP port, e.g. 192.0.2.1:319 or [2001:db8::1]:319, and
chronyc accepts the same forms, plus name:port, in commands that take
a source. Without a port, a command picks the source on the NTP port
if there is one, so existing usage keeps working. The command protocol
carries the port in the padding field of IPAddr, which older clients
leave zero and ignore in reports.

There's one problem I haven't solved yet. Older daemons ignore the
padding field in requests too, and pick the source by address only. So
with a new chronyc and an older chronyd, "delete 192.0.2.1:319" can end
up deleting 192.0.2.1:123 instead. I can see three ways to fix it:

  - chronyc first checks with an ntpdata request that the daemon has a
    source with that address and port. That needs no protocol change,
    and commands still work with an older daemon whose source happens
    to use the specified port, but every command with a port costs an
    extra request.
  - Requests with a port get new command codes, which older daemons
    reject with 502 Invalid command. There's no extra request, but
    every command that names a source needs a new code.
  - Requests with a port use a new protocol version, which older
    daemons reject with 517 Protocol version mismatch. That's a smaller
    change, but requests with a port must no longer fall back to the
    older protocol version.

I'm sending this as an RFC because I'd like to hear what you think of
the approach before going further. The patches are working, so they
can serve as a proof of concept if you want to try it out, and I'm
happy to rework them in whatever direction you think is best.

Wojtek Wasko (9):
  util: add functions for addresses of NTP sources with port
  util: include port in hash of addresses
  sources: save port of NTP sources
  ntp: allow sources with same address and different port
  ntp: print port of NTP sources in logs and dump file names
  cmdmon: add port to addresses of NTP sources
  client: allow specifying and printing ports of NTP sources
  test: add 153-dualtransport test
  doc: describe using NTP and NTP over PTP with same server

 candm.h                           |   6 +
 client.c                          | 190 ++++++++++++---------
 clientlog.c                       |   7 +-
 cmdmon.c                          |  87 ++++++----
 doc/chrony.conf.adoc              |  20 ++-
 doc/chronyc.adoc                  |   5 +
 ntp_core.c                        |  33 ++--
 ntp_sources.c                     | 161 +++++++++---------
 ntp_sources.h                     |  32 ++--
 reference.c                       |  27 +--
 reference.h                       |   5 +-
 reports.h                         |   4 +
 sources.c                         |  82 +++++----
 sources.h                         |  13 +-
 sourcestats.c                     |  16 +-
 sourcestats.h                     |   6 +-
 test/simulation/153-dualtransport | 265 ++++++++++++++++++++++++++++++
 test/unit/ntp_sources.c           | 134 ++++++++++++---
 test/unit/sources.c               |  46 +++++-
 test/unit/util.c                  |  98 ++++++++++-
 util.c                            |  91 +++++++++-
 util.h                            |  21 ++-
 22 files changed, 1027 insertions(+), 322 deletions(-)
 create mode 100755 test/simulation/153-dualtransport


base-commit: c97d8083cf9a9edc64d53236565916d326d8a109
-- 
2.43.0


-- 
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/