sonic-buildimage/files/image_config/ntp
Alexander Allen da7533aad4
[ntp] Fix ntp.conf template to allow setting of source port in CONFIG_DB (#7586)
Why I did it
Currently, there is a bug in the ntp.conf jinja2 template where it will ignore the src_intf directive in CONFIG_DB if there are multiple IP addresses associated with an interface. This code change fixes that bug and allows the template to select the correct source interface for NTP.

How I did it
I did this by modifying the macro in ntp.conf.j2 which determines if there is an ip address associated with an interface to set a state variable when it detects a valid interface entry in CONFIG_DB instead of outputting "true" directly (which could result in multiple "trues" outputted for interfaces with multiple valid IP addresses).

How to verify it
Add two ipv4 addresses to an interface in SONiC

Add the following configuration to config_db.json

{
"NTP": {
    "global": {
        "src_intf": "Ethernet1"
        }
    }
}
Replace Ethernet1 with the interface name of the one you assigned the IP addresses to.

Run sudo config reload -y

Open /etc/ntp.conf and verify that the following line exists

...
interface listen Ethernet1
...
The interface specified should be the one set in the previous steps.

Description for the changelog
[ntp] Fix ntp.conf template to allow setting of source port in CONFIG_DB
2021-05-23 13:40:43 -07:00
..
ntp [ntp]: Source interface support for NTP (#6033) 2020-12-21 05:34:13 -08:00
ntp-apparmor [ntp][apparmor] Allow apparmor read permission for ntpd under rw mount path of rootfs (#6040) 2020-12-18 04:57:35 -08:00
ntp-config.service [services] introduce sonic.target (#5705) 2021-02-25 14:26:24 +02:00
ntp-config.sh [ntp]: NTP service ordering (#6115) 2020-12-04 08:49:20 -08:00
ntp-systemd-wrapper [ntp]: Source interface support for NTP (#6033) 2020-12-21 05:34:13 -08:00
ntp.conf.j2 [ntp] Fix ntp.conf template to allow setting of source port in CONFIG_DB (#7586) 2021-05-23 13:40:43 -07:00
ntp.service [services] introduce sonic.target (#5705) 2021-02-25 14:26:24 +02:00