Skip to content

Commit 6a9c058

Browse files
authored
Revert "Add support for generating interface configuration in /etc/network/interfaces for multiple management interfaces (#11204)" (#11241)
This reverts commit 90a849e. #### Why I did it The interfaces unit test did not cover some of the conditions in interfaces.j2 that was changed in #11204. Therefore reverting the change and add the tests before making the change to interfaces.j2. #### How I did it Git revert. #### How to verify it #### Which release branch to backport (provide reason below if selected) - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 - [ ] 202111 - [ ] 202205 #### Description for the changelog #### Link to config_db schema for YANG module changes #### A picture of a cute animal (not mandatory but encouraged)
1 parent 0c5b1b2 commit 6a9c058

File tree

6 files changed

+12
-1132
lines changed

6 files changed

+12
-1132
lines changed

files/image_config/interfaces/interfaces.j2

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,19 @@ iface lo inet loopback
3030
{% block mgmt_interface %}
3131

3232
# The management network interface
33-
{% if MGMT_INTERFACE %}
34-
{% for (name, prefix) in MGMT_INTERFACE|pfx_filter|unique(attribute=0) %}
35-
auto {{ name }}
36-
{% endfor %}
37-
{% endif %}
33+
auto eth0
3834
{% if (ZTP_DHCP_DISABLED is not defined) and (ZTP is defined) and (ZTP['mode'] is defined and ZTP['mode']['profile'] == 'active') %}
3935

4036

4137
# ZTP out-of-band interface
42-
{% if MGMT_INTERFACE %}
43-
{% for (name, prefix) in MGMT_INTERFACE|pfx_filter|unique(attribute=0) %}
44-
allow-hotplug {{ name }}
38+
allow-hotplug eth0
4539
{% if ZTP['mode']['ipv4'] == 'true' %}
46-
iface {{ name }} inet dhcp
40+
iface eth0 inet dhcp
4741
{% endif %}
4842
{% if ZTP['mode']['ipv6'] == 'true' %}
49-
iface {{ name }} inet6 dhcp
50-
up sysctl net.ipv6.conf.{{ name }}.accept_ra=1
51-
down sysctl net.ipv6.conf.{{ name }}.accept_ra=0
52-
{% endif %}
53-
{% endfor %}
43+
iface eth0 inet6 dhcp
44+
up sysctl net.ipv6.conf.eth0.accept_ra=1
45+
down sysctl net.ipv6.conf.eth0.accept_ra=0
5446
{% endif %}
5547

5648
{% if ZTP['mode']['inband'] == 'true' %}
@@ -73,7 +65,7 @@ iface {{ port }} inet6 dhcp
7365
{% else %}
7466
{% if MGMT_INTERFACE %}
7567
{% for (name, prefix) in MGMT_INTERFACE|pfx_filter %}
76-
iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
68+
iface eth0 {{ 'inet' if prefix | ipv4 else 'inet6' }} static
7769
address {{ prefix | ip }}
7870
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
7971
network {{ prefix | network }}
@@ -85,15 +77,15 @@ iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
8577
{% endif %}
8678
########## management network policy routing rules
8779
# management port up rules
88-
up ip {{ '-4' if prefix | ipv4 else '-6' }} route add default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev {{ name }} table {{ vrf_table }} metric 201
89-
up ip {{ '-4' if prefix | ipv4 else '-6' }} route add {{ prefix | network }}/{{ prefix | prefixlen }} dev {{ name }} table {{ vrf_table }}
80+
up ip {{ '-4' if prefix | ipv4 else '-6' }} route add default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev eth0 table {{ vrf_table }} metric 201
81+
up ip {{ '-4' if prefix | ipv4 else '-6' }} route add {{ prefix | network }}/{{ prefix | prefixlen }} dev eth0 table {{ vrf_table }}
9082
up ip {{ '-4' if prefix | ipv4 else '-6' }} rule add pref 32765 from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table {{ vrf_table }}
9183
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
9284
up ip rule add pref 32764 to {{ route }} table {{ vrf_table }}
9385
{% endfor %}
9486
# management port down rules
95-
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev {{ name }} table {{ vrf_table }}
96-
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete {{ prefix | network }}/{{ prefix | prefixlen }} dev {{ name }} table {{ vrf_table }}
87+
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev eth0 table {{ vrf_table }}
88+
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete {{ prefix | network }}/{{ prefix | prefixlen }} dev eth0 table {{ vrf_table }}
9789
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} rule delete pref 32765 from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table {{ vrf_table }}
9890
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
9991
pre-down ip rule delete pref 32764 to {{ route }} table {{ vrf_table }}

src/sonic-config-engine/minigraph.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from lxml import etree as ET
1111
from lxml.etree import QName
1212

13-
from natsort import natsorted
1413

1514
from portconfig import get_port_config
1615
from sonic_py_common.interface import backplane_prefix
@@ -1433,8 +1432,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
14331432
results['MGMT_INTERFACE'] = {}
14341433
mgmt_intf_count = 0
14351434
mgmt_alias_reverse_mapping = {}
1436-
sorted_keys = natsorted(mgmt_intf.keys(), key=lambda x : x[0].lower())
1437-
for key in sorted_keys:
1435+
for key in mgmt_intf:
14381436
alias = key[0]
14391437
if alias in mgmt_alias_reverse_mapping:
14401438
name = mgmt_alias_reverse_mapping[alias]

src/sonic-config-engine/tests/sample_output/py2/two_mgmt_interfaces

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/sonic-config-engine/tests/sample_output/py3/two_mgmt_interfaces

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)