Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Support for NTP to run in management VRF is added.
As part of l3mdev based management VRF implementation, in order to execute the NTP daemon in the context of management vrf using cgexec, the NTP script /etc/init.d/ntp is updated to check for mvrf enabled status and call "start-stop-daemon" using cgexec. Since this /etc/init.d/ntp script is installed as part of NTP application (apt-get), a new script is used to update the installed /etc/init.d/ntp.
In addition, the linux NTP commands (programs) like “ntpq” and “ntpstat” require a loopback interface to connect to the ntpd and hence a dummy loopback interface lo-m is created in interfaces.j2 as part of management vrf.
TESTING:
Verified NTP using “ntpq -p” and “ntpstat” before enabling management VRF.
Enabled management vrf using “config vrf add mgmt” command that is explained in PR sonic-net/sonic-utilities#463
Verified NTP in management VRF using “cgexec” as follows.
root@sonic:/home/admin# date
Fri Aug 30 15:31:53 UTC 2019
root@sonic:/home/admin# cgexec -g l3mdev:mgmt ntpq -p
remote refid st t when poll reach delay offset jitter
23.92.29.245 .STEP. 16 u - 64 0 0.000 0.000 0.000
*204.2.134.164 44.24.199.34 3 u 9 64 1 200.601 -0.199 2.589
root@sonic:/home/admin# cgexec -g l3mdev:mgmt ntpstat
synchronised to NTP server (204.2.134.164) at stratum 4
time correct to within 1085 ms
polling server every 64 s
root@sonic:/home/admin# ps -ax | grep ntp
9761 ? Ssl 0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 106:110
9799 ttyS1 S+ 0:00 grep ntp
root@sonic:/home/admin#