Skip to content

Commit

Permalink
modified down rules to pre-down rules to ensure that default route is… (
Browse files Browse the repository at this point in the history
sonic-net#3853)

* modified down rules to pre-down rules to ensure that default route is deleted just before interface is made down
  • Loading branch information
kannankvs authored and pphuchar committed Mar 9, 2020
1 parent d4f127a commit e99086c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
24 changes: 12 additions & 12 deletions files/image_config/interfaces/interfaces.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

Expand Down Expand Up @@ -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 %}
Expand Down
12 changes: 6 additions & 6 deletions src/sonic-config-engine/tests/sample_output/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/*
#
Expand Down
22 changes: 11 additions & 11 deletions src/sonic-config-engine/tests/sample_output/mvrf_interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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/*
Expand Down

0 comments on commit e99086c

Please sign in to comment.