Page MenuHomeVyOS Platform

"show ntp" fails when vrf is being configured
Closed, ResolvedPublicBUG

Description

Utilizing vrf I wish to synchronize towards a ntp-server available on internet (normally one would most likely use something available on your mgmt-network instead).

By using this configuration:

ntp {
    interface eth1
    server 194.58.200.20 {
        prefer
    }
    vrf INTERNET
}

the output of "show ntp" fails with following error:

506 Cannot talk to daemon

Workaround is to switch context to vrf INTERNET and rerun the command, like so:

force vrf INTERNET
show ntp
exit

IMHO this shouldnt be needed.

"show ntp" should be able to be runned from regular vyos op-mode and if needed the output should inform which vrf the ntp service operates under.

Something like this:

vyos@vyos:~$ show ntp
                             .- Number of sample points in measurement set.
                            /    .- Number of residual runs with same sign.
                           |    /    .- Length of measurement set (time).
                           |   |    /      .- Est. clock freq error (ppm).
                           |   |   |      /           .- Est. error in freq.
                           |   |   |     |           /         .- Est. offset.
                           |   |   |     |          |          |   On the -.
                           |   |   |     |          |          |   samples. \
                           |   |   |     |          |          |             |
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
ntp.netnod.se               9   4   330     +0.002      0.441    +84ns    24us
==============================================================================
VRF: INTERNET
==============================================================================
vyos@vyos:~$

If no vrf is configured for "set service ntp" then the above output should read "VRF: Default".

Details

Difficulty level
Unknown (require assessment)
Version
VyOS 1.4-rolling-202307250317
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

Can you check changing

VRF_NAME=$(ip vrf identify )

to

VRF_NAME=$(ip vrf identify ${PID})

In file /usr/libexec/vyos/op_mode/show_ntp.sh, line 21

If possible, please check output when vrf configured in ntp, and also when not configured.

I can confirm that altering line 21 as suggested fixes this issue.

With "set service ntp vrf INTERNET" configured the output now becomes:

vyos@vyos:~$ show ntp
                             .- Number of sample points in measurement set.
                            /    .- Number of residual runs with same sign.
                           |    /    .- Length of measurement set (time).
                           |   |    /      .- Est. clock freq error (ppm).
                           |   |   |      /           .- Est. error in freq.
                           |   |   |     |           /         .- Est. offset.
                           |   |   |     |          |          |   On the -.
                           |   |   |     |          |          |   samples. \
                           |   |   |     |          |          |             |
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
ntp.netnod.se               4   3     6     +2.071    292.260    +50us    44us

The above also works if I first do "force vrf INTERNET" to change context into vrf INTERNET before running "show ntp".

And with "delete service ntp vrf" (followed by commit and save) the output becomes (since I dont have any static route configured for vrf Default and all interfaces are either part of vrf MGMT or vrf INTERNET both the dns-lookup and ntp synchronization will fail):

vyos@vyos:~$ show ntp
                             .- Number of sample points in measurement set.
                            /    .- Number of residual runs with same sign.
                           |    /    .- Length of measurement set (time).
                           |   |    /      .- Est. clock freq error (ppm).
                           |   |   |      /           .- Est. error in freq.
                           |   |   |     |           /         .- Est. offset.
                           |   |   |     |          |          |   On the -.
                           |   |   |     |          |          |   samples. \
                           |   |   |     |          |          |             |
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
194.58.200.20               0   0     0     +0.000   2000.000     +0ns  4000ms
Viacheslav changed the task status from Open to Needs testing.Jul 26 2023, 12:01 PM
Viacheslav assigned this task to Apachez.

Thanks for testing and submitting PR

Tested and verified as described in the pull request:

  1. Using VyOS 1.4-rolling-202307250317.
  1. Modifying line 21 in /usr/libexec/vyos/op_mode/show_ntp.sh.
  1. Ran "show ntp" in op-mode and got the expected result:

Before fix:

vyos@vyos:~$ show ntp
506 Cannot talk to daemon

After fix:

vyos@vyos:~$ show ntp
                             .- Number of sample points in measurement set.
                            /    .- Number of residual runs with same sign.
                           |    /    .- Length of measurement set (time).
                           |   |    /      .- Est. clock freq error (ppm).
                           |   |   |      /           .- Est. error in freq.
                           |   |   |     |           /         .- Est. offset.
                           |   |   |     |          |          |   On the -.
                           |   |   |     |          |          |   samples. \
                           |   |   |     |          |          |             |
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
ntp.netnod.se               4   3     6     +2.071    292.260    +50us    44us

Could you close the task if the issue is solved?