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

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

Merged
merged 6 commits into from
Jan 17, 2020
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 %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated condition here if, should remove one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tylerlinp : Which is duplicated condition? We modified only the order.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition from line 8 to 20, so line 12 and 19 is duplicated. And it is better to add a block mgmt.

{% 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