Skip to content

Commit 9413fa9

Browse files
author
Shuotian Cheng
authored
[interfaces]: Move IP/MTU information from interfaces file into database (#1908)
- Move front panel ports and port channels MTU and IP configurations out of the current /etc/network/interfaces file and store them in the configuration database. - The default MTU value for both front panel ports and the port channels is 9100. They are set via the minigraph or 9100 by default. - Introduce portmgrd which will pick up the MTU configurations from the configuration database. - The updated intfmgrd will pick up IP address changes from the configuration database. - Update sonic-swss submodule Signed-off-by: Shu0T1an ChenG <[email protected]>
1 parent e7ef637 commit 9413fa9

File tree

10 files changed

+80
-118
lines changed

10 files changed

+80
-118
lines changed

dockers/docker-orchagent/start.sh

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ supervisorctl start vlanmgrd
2626

2727
supervisorctl start intfmgrd
2828

29+
supervisorctl start portmgrd
30+
2931
supervisorctl start buffermgrd
3032

3133
supervisorctl start enable_counters

dockers/docker-orchagent/supervisord.conf

+10-2
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,25 @@ autorestart=false
8484
stdout_logfile=syslog
8585
stderr_logfile=syslog
8686

87+
[program:portmgrd]
88+
command=/usr/bin/portmgrd
89+
priority=11
90+
autostart=false
91+
autorestart=false
92+
stdout_logfile=syslog
93+
stderr_logfile=syslog
94+
8795
[program:buffermgrd]
8896
command=/usr/bin/buffermgrd -l /usr/share/sonic/hwsku/pg_profile_lookup.ini
89-
priority=10
97+
priority=12
9098
autostart=false
9199
autorestart=false
92100
stdout_logfile=syslog
93101
stderr_logfile=syslog
94102

95103
[program:enable_counters]
96104
command=/usr/bin/enable_counters.py
97-
priority=11
105+
priority=13
98106
autostart=false
99107
autorestart=false
100108
stdout_logfile=syslog

files/image_config/interfaces/interfaces.j2

-22
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@ iface eth0 inet dhcp
4949
#
5050
{% endblock mgmt_interface %}
5151
{% block front_panel_interfaces %}
52-
# The switch front panel interfaces
53-
{% for (name, prefix) in INTERFACE %}
54-
allow-hotplug {{ name }}
55-
iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
56-
mtu {{ PORT[name]['mtu'] if PORT[name]['mtu'] else 9100 }}
57-
address {{ prefix | ip }}
58-
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
59-
#
60-
{% endfor %}
6152
{% if PORTCHANNEL %}
6253
# "|| true" is added to suppress the error when interface is already a member of LAG
6354
# "ip link show | grep -q master" is added to ensure interface is enslaved
@@ -73,16 +64,3 @@ iface {{ member }} inet manual
7364
{% endfor %}
7465
{% endif %}
7566
{% endblock front_panel_interfaces %}
76-
{% block pc_interfaces %}
77-
{% if PORTCHANNEL_INTERFACE %}
78-
# Portchannel interfaces
79-
{% for (name, prefix) in PORTCHANNEL_INTERFACE.keys() | sort %}
80-
allow-hotplug {{ name }}
81-
iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
82-
mtu {{ PORTCHANNEL[name]['mtu'] if PORTCHANNEL[name]['mtu'] else 9100 }}
83-
address {{ prefix | ip }}
84-
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
85-
#
86-
{% endfor %}
87-
{% endif %}
88-
{% endblock pc_interfaces %}

platform/vs/docker-sonic-vs/start.sh

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ supervisorctl start teamsyncd
4242

4343
supervisorctl start fpmsyncd
4444

45+
supervisorctl start portmgrd
46+
4547
supervisorctl start intfmgrd
4648

4749
supervisorctl start vlanmgrd

platform/vs/docker-sonic-vs/supervisord.conf

+13-5
Original file line numberDiff line numberDiff line change
@@ -91,41 +91,49 @@ autorestart=false
9191
stdout_logfile=syslog
9292
stderr_logfile=syslog
9393

94+
[program:portmgrd]
95+
command=/usr/bin/portmgrd
96+
priority=12
97+
autostart=false
98+
autorestart=false
99+
stdout_logfile=syslog
100+
stderr_logfile=syslog
101+
94102
[program:zebra]
95103
command=/usr/lib/quagga/zebra -A 127.0.0.1
96-
priority=12
104+
priority=13
97105
autostart=false
98106
autorestart=false
99107
stdout_logfile=syslog
100108
stderr_logfile=syslog
101109

102110
[program:bgpd]
103111
command=/usr/lib/quagga/bgpd -A 127.0.0.1 -F
104-
priority=13
112+
priority=14
105113
autostart=false
106114
autorestart=false
107115
stdout_logfile=syslog
108116
stderr_logfile=syslog
109117

110118
[program:fpmsyncd]
111119
command=/usr/bin/fpmsyncd
112-
priority=14
120+
priority=15
113121
autostart=false
114122
autorestart=false
115123
stdout_logfile=syslog
116124
stderr_logfile=syslog
117125

118126
[program:arp_update]
119127
command=/usr/bin/arp_update
120-
priority=15
128+
priority=16
121129
autostart=false
122130
autorestart=unexpected
123131
stdout_logfile=syslog
124132
stderr_logfile=syslog
125133

126134
[program:buffermgrd]
127135
command=/usr/bin/buffermgrd -l /usr/share/sonic/device/vswitch/pg_profile_lookup.ini
128-
priority=10
136+
priority=17
129137
autostart=false
130138
autorestart=false
131139
stdout_logfile=syslog

src/sonic-config-engine/minigraph.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def parse_png(png, hname):
9191
'flow_control': flowcontrol
9292
}
9393
continue
94-
94+
9595
if linktype != "DeviceInterfaceLink" and linktype != "UnderlayInterfaceLink":
9696
continue
9797

@@ -516,6 +516,15 @@ def parse_xml(filename, platform=None, port_config_file=None):
516516

517517
ports.setdefault(port_name, {})['description'] = port_descriptions[port_name]
518518

519+
# set default port MTU as 9100
520+
for port in ports.itervalues():
521+
port['mtu'] = '9100'
522+
523+
# set physical port default admin status up
524+
for port in phyport_intfs:
525+
if port[0] in ports:
526+
ports.get(port[0])['admin_status'] = 'up'
527+
519528
results['PORT'] = ports
520529
results['CONSOLE_PORT'] = console_ports
521530

@@ -528,6 +537,11 @@ def parse_xml(filename, platform=None, port_config_file=None):
528537
print >> sys.stderr, "Warning: ignore '%s' as part of its member interfaces is not in the port_config.ini" % pc_name
529538
del pcs[pc_name]
530539

540+
# set default port channel MTU as 9100 and admin status up
541+
for pc in pcs.itervalues():
542+
pc['mtu'] = '9100'
543+
pc['admin_status'] = 'up'
544+
531545
results['PORTCHANNEL'] = pcs
532546

533547

src/sonic-config-engine/tests/sample_output/interfaces

-50
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ iface eth0 inet6 static
4747
down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default
4848
down ip -6 rule delete from 2603:10e2:0:2902::8/128 table default
4949
#
50-
# The switch front panel interfaces
5150
# "|| true" is added to suppress the error when interface is already a member of LAG
5251
# "ip link show | grep -q master" is added to ensure interface is enslaved
5352
allow-hotplug fortyGigE0/112
@@ -74,53 +73,4 @@ iface fortyGigE0/124 inet manual
7473
post-up ip link show fortyGigE0/124 | grep -q master && ifconfig fortyGigE0/124 up
7574
post-down ifconfig fortyGigE0/124 down
7675
#
77-
# Portchannel interfaces
78-
allow-hotplug PortChannel01
79-
iface PortChannel01 inet static
80-
mtu 9100
81-
address 10.0.0.56
82-
netmask 255.255.255.254
83-
#
84-
allow-hotplug PortChannel01
85-
iface PortChannel01 inet6 static
86-
mtu 9100
87-
address fc00::71
88-
netmask 126
89-
#
90-
allow-hotplug PortChannel02
91-
iface PortChannel02 inet static
92-
mtu 9100
93-
address 10.0.0.58
94-
netmask 255.255.255.254
95-
#
96-
allow-hotplug PortChannel02
97-
iface PortChannel02 inet6 static
98-
mtu 9100
99-
address fc00::75
100-
netmask 126
101-
#
102-
allow-hotplug PortChannel03
103-
iface PortChannel03 inet static
104-
mtu 9100
105-
address 10.0.0.60
106-
netmask 255.255.255.254
107-
#
108-
allow-hotplug PortChannel03
109-
iface PortChannel03 inet6 static
110-
mtu 9100
111-
address fc00::79
112-
netmask 126
113-
#
114-
allow-hotplug PortChannel04
115-
iface PortChannel04 inet static
116-
mtu 9100
117-
address 10.0.0.62
118-
netmask 255.255.255.254
119-
#
120-
allow-hotplug PortChannel04
121-
iface PortChannel04 inet6 static
122-
mtu 9100
123-
address fc00::7d
124-
netmask 126
125-
#
12676

src/sonic-config-engine/tests/test_cfggen.py

+36-36
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ def test_minigraph_vlan_interfaces(self):
115115
def test_minigraph_portchannels(self):
116116
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v PORTCHANNEL'
117117
output = self.run_script(argument)
118-
self.assertEqual(output.strip(), "{'PortChannel01': {'members': ['Ethernet4']}}")
118+
self.assertEqual(output.strip(), "{'PortChannel01': {'admin_status': 'up', 'members': ['Ethernet4'], 'mtu': '9100'}}")
119119

120120
def test_minigraph_portchannels_more_member(self):
121121
argument = '-m "' + self.sample_graph_pc_test + '" -p "' + self.port_config + '" -v PORTCHANNEL'
122122
output = self.run_script(argument)
123-
self.assertEqual(output.strip(), "{'PortChannel01': {'members': ['Ethernet112', 'Ethernet116', 'Ethernet120', 'Ethernet124']}}")
123+
self.assertEqual(output.strip(), "{'PortChannel01': {'admin_status': 'up', 'members': ['Ethernet112', 'Ethernet116', 'Ethernet120', 'Ethernet124'], 'mtu': '9100'}}")
124124

125125
def test_minigraph_portchannel_interfaces(self):
126126
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORTCHANNEL_INTERFACE.keys()"'
@@ -159,47 +159,47 @@ def test_minigraph_deployment_id(self):
159159
def test_minigraph_ethernet_interfaces(self):
160160
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORT[\'Ethernet8\']"'
161161
output = self.run_script(argument)
162-
self.assertEqual(output.strip(), "{'alias': 'fortyGigE0/8', 'lanes': '37,38,39,40', 'description': 'Interface description', 'speed': '1000'}")
162+
self.assertEqual(output.strip(), "{'alias': 'fortyGigE0/8', 'lanes': '37,38,39,40', 'description': 'Interface description', 'speed': '1000', 'mtu': '9100'}")
163163
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORT[\'Ethernet12\']"'
164164
output = self.run_script(argument)
165-
self.assertEqual(output.strip(), "{'alias': 'fortyGigE0/12', 'lanes': '33,34,35,36', 'fec': 'rs', 'speed': '100000', 'description': 'Interface description'}")
165+
self.assertEqual(output.strip(), "{'lanes': '33,34,35,36', 'description': 'Interface description', 'mtu': '9100', 'alias': 'fortyGigE0/12', 'speed': '100000', 'fec': 'rs'}")
166166

167167
def test_minigraph_extra_ethernet_interfaces(self):
168168
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORT"'
169169
output = self.run_script(argument)
170170
self.assertEqual(output.strip(), \
171-
"{'Ethernet8': {'alias': 'fortyGigE0/8', 'lanes': '37,38,39,40', 'description': 'Interface description', 'speed': '1000'}, "
172-
"'Ethernet0': {'alias': 'fortyGigE0/0', 'lanes': '29,30,31,32', 'speed': '10000'}, "
173-
"'Ethernet4': {'alias': 'fortyGigE0/4', 'lanes': '25,26,27,28', 'speed': '25000'}, "
174-
"'Ethernet108': {'alias': 'fortyGigE0/108', 'lanes': '81,82,83,84'}, "
175-
"'Ethernet100': {'alias': 'fortyGigE0/100', 'lanes': '125,126,127,128'}, "
176-
"'Ethernet104': {'alias': 'fortyGigE0/104', 'lanes': '85,86,87,88'}, "
177-
"'Ethernet68': {'alias': 'fortyGigE0/68', 'lanes': '69,70,71,72'}, "
178-
"'Ethernet96': {'alias': 'fortyGigE0/96', 'lanes': '121,122,123,124'}, "
179-
"'Ethernet124': {'alias': 'fortyGigE0/124', 'lanes': '101,102,103,104'}, "
180-
"'Ethernet92': {'alias': 'fortyGigE0/92', 'lanes': '113,114,115,116'}, "
181-
"'Ethernet120': {'alias': 'fortyGigE0/120', 'lanes': '97,98,99,100'}, "
182-
"'Ethernet52': {'alias': 'fortyGigE0/52', 'lanes': '53,54,55,56'}, "
183-
"'Ethernet56': {'alias': 'fortyGigE0/56', 'lanes': '61,62,63,64'}, "
184-
"'Ethernet76': {'alias': 'fortyGigE0/76', 'lanes': '73,74,75,76'}, "
185-
"'Ethernet72': {'alias': 'fortyGigE0/72', 'lanes': '77,78,79,80'}, "
186-
"'Ethernet64': {'alias': 'fortyGigE0/64', 'lanes': '65,66,67,68'}, "
187-
"'Ethernet32': {'alias': 'fortyGigE0/32', 'lanes': '9,10,11,12'}, "
188-
"'Ethernet16': {'alias': 'fortyGigE0/16', 'lanes': '41,42,43,44'}, "
189-
"'Ethernet36': {'alias': 'fortyGigE0/36', 'lanes': '13,14,15,16'}, "
190-
"'Ethernet12': {'alias': 'fortyGigE0/12', 'lanes': '33,34,35,36', 'fec': 'rs', 'speed': '100000', 'description': 'Interface description'}, "
191-
"'Ethernet88': {'alias': 'fortyGigE0/88', 'lanes': '117,118,119,120'}, "
192-
"'Ethernet116': {'alias': 'fortyGigE0/116', 'lanes': '93,94,95,96'}, "
193-
"'Ethernet80': {'alias': 'fortyGigE0/80', 'lanes': '105,106,107,108'}, "
194-
"'Ethernet112': {'alias': 'fortyGigE0/112', 'lanes': '89,90,91,92'}, "
195-
"'Ethernet84': {'alias': 'fortyGigE0/84', 'lanes': '109,110,111,112'}, "
196-
"'Ethernet48': {'alias': 'fortyGigE0/48', 'lanes': '49,50,51,52'}, "
197-
"'Ethernet44': {'alias': 'fortyGigE0/44', 'lanes': '17,18,19,20'}, "
198-
"'Ethernet40': {'alias': 'fortyGigE0/40', 'lanes': '21,22,23,24'}, "
199-
"'Ethernet28': {'alias': 'fortyGigE0/28', 'lanes': '1,2,3,4'}, "
200-
"'Ethernet60': {'alias': 'fortyGigE0/60', 'lanes': '57,58,59,60'}, "
201-
"'Ethernet20': {'alias': 'fortyGigE0/20', 'lanes': '45,46,47,48'}, "
202-
"'Ethernet24': {'alias': 'fortyGigE0/24', 'lanes': '5,6,7,8'}}")
171+
"{'Ethernet8': {'alias': 'fortyGigE0/8', 'lanes': '37,38,39,40', 'description': 'Interface description', 'speed': '1000', 'mtu': '9100'}, "
172+
"'Ethernet0': {'alias': 'fortyGigE0/0', 'admin_status': 'up', 'lanes': '29,30,31,32', 'speed': '10000', 'mtu': '9100'}, "
173+
"'Ethernet4': {'alias': 'fortyGigE0/4', 'lanes': '25,26,27,28', 'speed': '25000', 'mtu': '9100'}, "
174+
"'Ethernet108': {'alias': 'fortyGigE0/108', 'lanes': '81,82,83,84', 'mtu': '9100'}, "
175+
"'Ethernet100': {'alias': 'fortyGigE0/100', 'lanes': '125,126,127,128', 'mtu': '9100'}, "
176+
"'Ethernet104': {'alias': 'fortyGigE0/104', 'lanes': '85,86,87,88', 'mtu': '9100'}, "
177+
"'Ethernet68': {'alias': 'fortyGigE0/68', 'lanes': '69,70,71,72', 'mtu': '9100'}, "
178+
"'Ethernet96': {'alias': 'fortyGigE0/96', 'lanes': '121,122,123,124', 'mtu': '9100'}, "
179+
"'Ethernet124': {'alias': 'fortyGigE0/124', 'lanes': '101,102,103,104', 'mtu': '9100'}, "
180+
"'Ethernet92': {'alias': 'fortyGigE0/92', 'lanes': '113,114,115,116', 'mtu': '9100'}, "
181+
"'Ethernet120': {'alias': 'fortyGigE0/120', 'lanes': '97,98,99,100', 'mtu': '9100'}, "
182+
"'Ethernet52': {'alias': 'fortyGigE0/52', 'lanes': '53,54,55,56', 'mtu': '9100'}, "
183+
"'Ethernet56': {'alias': 'fortyGigE0/56', 'lanes': '61,62,63,64', 'mtu': '9100'}, "
184+
"'Ethernet76': {'alias': 'fortyGigE0/76', 'lanes': '73,74,75,76', 'mtu': '9100'}, "
185+
"'Ethernet72': {'alias': 'fortyGigE0/72', 'lanes': '77,78,79,80', 'mtu': '9100'}, "
186+
"'Ethernet64': {'alias': 'fortyGigE0/64', 'lanes': '65,66,67,68', 'mtu': '9100'}, "
187+
"'Ethernet32': {'alias': 'fortyGigE0/32', 'lanes': '9,10,11,12', 'mtu': '9100'}, "
188+
"'Ethernet16': {'alias': 'fortyGigE0/16', 'lanes': '41,42,43,44', 'mtu': '9100'}, "
189+
"'Ethernet36': {'alias': 'fortyGigE0/36', 'lanes': '13,14,15,16', 'mtu': '9100'}, "
190+
"'Ethernet12': {'lanes': '33,34,35,36', 'description': 'Interface description', 'mtu': '9100', 'alias': 'fortyGigE0/12', 'speed': '100000', 'fec': 'rs'}, "
191+
"'Ethernet88': {'alias': 'fortyGigE0/88', 'lanes': '117,118,119,120', 'mtu': '9100'}, "
192+
"'Ethernet116': {'alias': 'fortyGigE0/116', 'lanes': '93,94,95,96', 'mtu': '9100'}, "
193+
"'Ethernet80': {'alias': 'fortyGigE0/80', 'lanes': '105,106,107,108', 'mtu': '9100'}, "
194+
"'Ethernet112': {'alias': 'fortyGigE0/112', 'lanes': '89,90,91,92', 'mtu': '9100'}, "
195+
"'Ethernet84': {'alias': 'fortyGigE0/84', 'lanes': '109,110,111,112', 'mtu': '9100'}, "
196+
"'Ethernet48': {'alias': 'fortyGigE0/48', 'lanes': '49,50,51,52', 'mtu': '9100'}, "
197+
"'Ethernet44': {'alias': 'fortyGigE0/44', 'lanes': '17,18,19,20', 'mtu': '9100'}, "
198+
"'Ethernet40': {'alias': 'fortyGigE0/40', 'lanes': '21,22,23,24', 'mtu': '9100'}, "
199+
"'Ethernet28': {'alias': 'fortyGigE0/28', 'lanes': '1,2,3,4', 'mtu': '9100'}, "
200+
"'Ethernet60': {'alias': 'fortyGigE0/60', 'lanes': '57,58,59,60', 'mtu': '9100'}, "
201+
"'Ethernet20': {'alias': 'fortyGigE0/20', 'lanes': '45,46,47,48', 'mtu': '9100'}, "
202+
"'Ethernet24': {'alias': 'fortyGigE0/24', 'lanes': '5,6,7,8', 'mtu': '9100'}}")
203203

204204
def test_metadata_everflow(self):
205205
argument = '-m "' + self.sample_graph_metadata + '" -p "' + self.port_config + '" -v "MIRROR_SESSION"'

src/sonic-config-engine/tests/test_minigraph_case.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_minigraph_vlan_interfaces(self):
8787
def test_minigraph_portchannels(self):
8888
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v PORTCHANNEL'
8989
output = self.run_script(argument)
90-
self.assertEqual(output.strip(), "{'PortChannel01': {'members': ['Ethernet4']}}")
90+
self.assertEqual(output.strip(), "{'PortChannel01': {'admin_status': 'up', 'members': ['Ethernet4'], 'mtu': '9100'}}")
9191

9292
def test_minigraph_console_port(self):
9393
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v CONSOLE_PORT'

src/sonic-swss

0 commit comments

Comments
 (0)