ntp: fix adding noselect to selection options

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: 3877734814 ("sources: add function to modify selection options")
This commit is contained in:
Miroslav Lichvar 2023-08-07 14:52:01 +02:00
parent b5cf861cd7
commit 7bc7d00297
2 changed files with 17 additions and 12 deletions

View file

@ -587,9 +587,7 @@ update_sel_options(void)
for (i = 0; i < n_sources; i++) { for (i = 0; i < n_sources; i++) {
options = sources[i]->conf_sel_options; options = sources[i]->conf_sel_options;
if (options & SRC_SELECT_NOSELECT) if (!(options & SRC_SELECT_NOSELECT)) {
continue;
switch (sources[i]->type) { switch (sources[i]->type) {
case SRC_NTP: case SRC_NTP:
options |= sources[i]->authenticated ? auth_ntp_options : unauth_ntp_options; options |= sources[i]->authenticated ? auth_ntp_options : unauth_ntp_options;
@ -600,6 +598,7 @@ update_sel_options(void)
default: default:
assert(0); assert(0);
} }
}
if (sources[i]->sel_options != options) { if (sources[i]->sel_options != options) {
DEBUG_LOG("changing %s from %x to %x", source_to_string(sources[i]), DEBUG_LOG("changing %s from %x to %x", source_to_string(sources[i]),

View file

@ -350,6 +350,8 @@ minstratum 192.168.123.1 1
polltarget 192.168.123.1 10 polltarget 192.168.123.1 10
selectopts 192.168.123.1 +trust +prefer -require selectopts 192.168.123.1 +trust +prefer -require
selectdata selectdata
selectopts 192.168.123.1 +noselect -prefer -trust +require
selectdata
delete 192.168.123.1" delete 192.168.123.1"
run_test || test_fail run_test || test_fail
@ -372,6 +374,10 @@ check_chronyc_output "^200 OK
S Name/IP Address Auth COpts EOpts Last Score Interval Leap S Name/IP Address Auth COpts EOpts Last Score Interval Leap
======================================================================= =======================================================================
M node1\.net1\.clk N \-PT\-\- \-PT\-\- 0 1\.0 \+0ns \+0ns \? 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 200 OK$" || test_fail
chronyc_conf=" chronyc_conf="