modified down rules to pre-down rules to ensure that default route is… (#3853)

* modified down rules to pre-down rules to ensure that default route is deleted just before interface is made down
This commit is contained in:
kannankvs 2020-01-17 09:06:49 +05:30 committed by Abhishek
parent 8305e84140
commit 74ac9b02dc
3 changed files with 30 additions and 30 deletions

View File

@ -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
# 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
down ip link delete dev lo-m
{% endif %}
{% endblock mgmt_vrf %}
{% 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 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 %}
@ -50,14 +50,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 %}

View File

@ -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/*
#

View File

@ -6,15 +6,15 @@
auto mgmt
iface mgmt
vrf-table 5000
# 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
down ip link delete dev lo-m
# 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 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
# 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/*