Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NTP support for management VRF #3400

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ sudo cp files/dhcp/graphserviceurl $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks
sudo cp files/dhcp/snmpcommunity $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks.d/
sudo cp files/dhcp/vrf $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks.d/
sudo cp files/dhcp/dhclient.conf $FILESYSTEM_ROOT/etc/dhcp/
if [ -f files/image_config/ntp/mgmtvrf_add_cgexec_to_ntp.sh ]; then
./files/image_config/ntp/mgmtvrf_add_cgexec_to_ntp.sh $FILESYSTEM_ROOT/etc/init.d/ntp
fi

## Version file
sudo mkdir -p $FILESYSTEM_ROOT/etc/sonic
Expand Down
8 changes: 8 additions & 0 deletions files/image_config/interfaces/interfaces.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ iface lo {{ 'inet' if prefix | ipv4 else 'inet6' }} static
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
#
{% endfor %}
# The loopback network interface for mgmt VRF that is required for applications like NTP
{% if (MGMT_VRF_CONFIG) and (MGMT_VRF_CONFIG['vrf_global']['mgmtVrfEnabled'] == "true") %}
up ip link add lo-m type dummy
up ip addr add 127.0.0.1/8 dev lo-m
up ip link set lo-m up
up ip link set dev lo-m master mgmt
down ip link delete dev lo-m
{% endif %}
{% endblock loopback %}
{% block mgmt_interface %}

Expand Down
3 changes: 3 additions & 0 deletions files/image_config/ntp/mgmtvrf_add_cgexec_to_ntp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
sudo sed -i '/start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -p $PIDFILE $NTPD_OPTS/d' $1
sudo sed -i '/flock -w 180 9/a \\t\t\tvrfEnabled=$(/usr/local/bin/sonic-cfggen -d -v '"'MGMT_VRF_CONFIG[\"vrf_global\"][\"mgmtVrfEnabled\"]'"')\n\t\t\tif [ "$vrfEnabled" = "true" ]\n\t\t\tthen\n\t\t\t\tlog_daemon_msg "Starting NTP server in mgmt-vrf" "ntpd"\n\t\t\t\tcgexec -g l3mdev:mgmt start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -p $PIDFILE $NTPD_OPTS\n\t\t\telse\n\t\t\t\tlog_daemon_msg "Starting NTP server in default-vrf" "ntpd"\n\t\t\t\tstart-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -p $PIDFILE $NTPD_OPTS\n\t\t\tfi' $1