]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: fix adding noselect to selection options
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 7 Aug 2023 12:52:01 +0000 (14:52 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 7 Aug 2023 12:58:48 +0000 (14:58 +0200)
If noselect is present in the configured options, don't assume it
cannot change and the effective options are equal. This fixes chronyc
selectopts +noselect command.

Fixes: 38777348143e ("sources: add function to modify selection options")
sources.c
test/simulation/110-chronyc

index 261d31d32a5c77585b9b10caf5c9751cbe3d40a1..e8e970536e53a77c16b59b2c52147106e4311a4e 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -587,18 +587,17 @@ update_sel_options(void)
   for (i = 0; i < n_sources; i++) {
     options = sources[i]->conf_sel_options;
 
-    if (options & SRC_SELECT_NOSELECT)
-      continue;
-
-    switch (sources[i]->type) {
-      case SRC_NTP:
-        options |= sources[i]->authenticated ? auth_ntp_options : unauth_ntp_options;
-        break;
-      case SRC_REFCLOCK:
-        options |= refclk_options;
-        break;
-      default:
-        assert(0);
+    if (!(options & SRC_SELECT_NOSELECT)) {
+      switch (sources[i]->type) {
+        case SRC_NTP:
+          options |= sources[i]->authenticated ? auth_ntp_options : unauth_ntp_options;
+          break;
+        case SRC_REFCLOCK:
+          options |= refclk_options;
+          break;
+        default:
+          assert(0);
+      }
     }
 
     if (sources[i]->sel_options != options) {
index 33d204bb613c03c8fe9b353cd6fc5e6d9e1d7e49..97abc217d2e5f9fe2ee35523f307a756992d1260 100755 (executable)
@@ -350,6 +350,8 @@ minstratum 192.168.123.1 1
 polltarget 192.168.123.1 10
 selectopts 192.168.123.1 +trust +prefer -require
 selectdata
+selectopts 192.168.123.1 +noselect -prefer -trust +require
+selectdata
 delete 192.168.123.1"
 
 run_test || test_fail
@@ -372,6 +374,10 @@ check_chronyc_output "^200 OK
 S Name/IP Address        Auth COpts EOpts Last Score     Interval  Leap
 =======================================================================
 M node1\.net1\.clk            N \-PT\-\- \-PT\-\-    0   1\.0    \+0ns    \+0ns  \?
+200 OK
+S Name/IP Address        Auth COpts EOpts Last Score     Interval  Leap
+=======================================================================
+M node1\.net1\.clk            N N\-\-R\- N\-\-R\-    0   1\.0    \+0ns    \+0ns  \?
 200 OK$" || test_fail
 
 chronyc_conf="