From d150721fa1b2f5c68fc7ec7978a4ba42b9a4c08c Mon Sep 17 00:00:00 2001 From: kannankvs Date: Fri, 17 Jan 2020 09:06:49 +0530 Subject: [PATCH] =?UTF-8?q?modified=20down=20rules=20to=20pre-down=20rules?= =?UTF-8?q?=20to=20ensure=20that=20default=20route=20is=E2=80=A6=20(#3853)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * modified down rules to pre-down rules to ensure that default route is deleted just before interface is made down --- files/image_config/interfaces/interfaces.j2 | 24 +++++++++---------- .../tests/sample_output/interfaces | 12 +++++----- .../tests/sample_output/mvrf_interfaces | 22 ++++++++--------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/files/image_config/interfaces/interfaces.j2 b/files/image_config/interfaces/interfaces.j2 index 8b8ea0b52bc8..dbb2b1f3418a 100644 --- a/files/image_config/interfaces/interfaces.j2 +++ b/files/image_config/interfaces/interfaces.j2 @@ -5,23 +5,23 @@ # file: /etc/network/interfaces # {% endblock banner %} +{% block mgmt_vrf %} {% if (MGMT_VRF_CONFIG) and (MGMT_VRF_CONFIG['vrf_global']['mgmtVrfEnabled'] == "true") %} auto mgmt iface mgmt vrf-table 5000 -{% endif %} -{% block loopback %} -# The loopback network interface -auto lo -iface lo inet loopback -{% if (MGMT_VRF_CONFIG) and (MGMT_VRF_CONFIG['vrf_global']['mgmtVrfEnabled'] == "true") %} # The loopback network interface for mgmt VRF that is required for applications like NTP up ip link add lo-m type dummy + up ip link set dev lo-m master mgmt 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 + down ip link delete dev lo-m {% endif %} +{% endblock mgmt_vrf %} +{% block loopback %} +# The loopback network interface +auto lo +iface lo inet loopback {% endblock loopback %} {% block mgmt_interface %} @@ -82,14 +82,14 @@ iface eth0 {{ 'inet' if prefix | ipv4 else 'inet6' }} static up ip rule add to {{ route }} table {{ vrf_table }} {% endfor %} # management port down rules - down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev eth0 table {{ vrf_table }} - down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete {{ prefix | network }}/{{ prefix | prefixlen }} dev eth0 table {{ vrf_table }} - down ip {{ '-4' if prefix | ipv4 else '-6' }} rule delete from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table {{ vrf_table }} + pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev eth0 table {{ vrf_table }} + pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete {{ prefix | network }}/{{ prefix | prefixlen }} dev eth0 table {{ vrf_table }} + pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} rule delete from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table {{ vrf_table }} {% if (MGMT_VRF_CONFIG) and (MGMT_VRF_CONFIG['vrf_global']['mgmtVrfEnabled'] == "true") %} down cgdelete -g l3mdev:mgmt {% endif %} {% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %} - down ip rule delete to {{ route }} table {{ vrf_table }} + pre-down ip rule delete to {{ route }} table {{ vrf_table }} {% endfor %} {# TODO: COPP policy type rules #} {% endfor %} diff --git a/src/sonic-config-engine/tests/sample_output/interfaces b/src/sonic-config-engine/tests/sample_output/interfaces index d3921bcbab4d..913fc8531443 100644 --- a/src/sonic-config-engine/tests/sample_output/interfaces +++ b/src/sonic-config-engine/tests/sample_output/interfaces @@ -18,9 +18,9 @@ iface eth0 inet static up ip -4 route add 10.0.0.0/24 dev eth0 table default up ip -4 rule add from 10.0.0.100/32 table default # management port down rules - down ip -4 route delete default via 10.0.0.1 dev eth0 table default - down ip -4 route delete 10.0.0.0/24 dev eth0 table default - down ip -4 rule delete from 10.0.0.100/32 table default + pre-down ip -4 route delete default via 10.0.0.1 dev eth0 table default + pre-down ip -4 route delete 10.0.0.0/24 dev eth0 table default + pre-down ip -4 rule delete from 10.0.0.100/32 table default iface eth0 inet6 static address 2603:10e2:0:2902::8 netmask 64 @@ -30,9 +30,9 @@ iface eth0 inet6 static up ip -6 route add 2603:10e2:0:2902::/64 dev eth0 table default up ip -6 rule add from 2603:10e2:0:2902::8/128 table default # management port down rules - down ip -6 route delete default via 2603:10e2:0:2902::1 dev eth0 table default - down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default - down ip -6 rule delete from 2603:10e2:0:2902::8/128 table default + pre-down ip -6 route delete default via 2603:10e2:0:2902::1 dev eth0 table default + pre-down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default + pre-down ip -6 rule delete from 2603:10e2:0:2902::8/128 table default # source /etc/network/interfaces.d/* # diff --git a/src/sonic-config-engine/tests/sample_output/mvrf_interfaces b/src/sonic-config-engine/tests/sample_output/mvrf_interfaces index afd0615b81e9..7bd664d4a9db 100644 --- a/src/sonic-config-engine/tests/sample_output/mvrf_interfaces +++ b/src/sonic-config-engine/tests/sample_output/mvrf_interfaces @@ -6,15 +6,15 @@ auto mgmt iface mgmt vrf-table 5000 -# The loopback network interface -auto lo -iface lo inet loopback # The loopback network interface for mgmt VRF that is required for applications like NTP up ip link add lo-m type dummy + up ip link set dev lo-m master mgmt 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 + down ip link delete dev lo-m +# The loopback network interface +auto lo +iface lo inet loopback # The management network interface auto eth0 @@ -30,9 +30,9 @@ iface eth0 inet static up cgcreate -g l3mdev:mgmt up cgset -r l3mdev.master-device=mgmt mgmt # management port down rules - down ip -4 route delete default via 10.0.0.1 dev eth0 table 5000 - down ip -4 route delete 10.0.0.0/24 dev eth0 table 5000 - down ip -4 rule delete from 10.0.0.100/32 table 5000 + pre-down ip -4 route delete default via 10.0.0.1 dev eth0 table 5000 + pre-down ip -4 route delete 10.0.0.0/24 dev eth0 table 5000 + pre-down ip -4 rule delete from 10.0.0.100/32 table 5000 down cgdelete -g l3mdev:mgmt iface eth0 inet6 static address 2603:10e2:0:2902::8 @@ -46,9 +46,9 @@ iface eth0 inet6 static up cgcreate -g l3mdev:mgmt up cgset -r l3mdev.master-device=mgmt mgmt # management port down rules - down ip -6 route delete default via 2603:10e2:0:2902::1 dev eth0 table 5000 - down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table 5000 - down ip -6 rule delete from 2603:10e2:0:2902::8/128 table 5000 + pre-down ip -6 route delete default via 2603:10e2:0:2902::1 dev eth0 table 5000 + pre-down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table 5000 + pre-down ip -6 rule delete from 2603:10e2:0:2902::8/128 table 5000 down cgdelete -g l3mdev:mgmt # source /etc/network/interfaces.d/*