Skip to content

Commit 7406d37

Browse files
jipanyanglguohan
authored andcommitted
[configdb]: Add support for vlanconfd and intfconfd (#1063)
* Add support for vlanconfd and intfconfd Signed-off-by: Jipan Yang <[email protected]> * Change name to vlanmgrd and intfmgrd Signed-off-by: Jipan Yang <[email protected]> * Add missing vlan_members for parse_dpg result Signed-off-by: Jipan Yang <[email protected]> * Remove cfgmgr debug CLI from image Signed-off-by: Jipan Yang <[email protected]> * Update swss and swss-common submodules for VLAN trunk support Signed-off-by: Jipan Yang <[email protected]>
1 parent 84cbfd5 commit 7406d37

File tree

8 files changed

+40
-189
lines changed

8 files changed

+40
-189
lines changed

dockers/docker-orchagent/start.sh

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ supervisorctl start neighsyncd
2222

2323
supervisorctl start swssconfig
2424

25+
supervisorctl start vlanmgrd
26+
27+
supervisorctl start intfmgrd
28+
2529
# Start arp_update when VLAN exists
2630
VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'`
2731
if [ "$VLAN" != "" ]; then

dockers/docker-orchagent/supervisord.conf

+16
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,19 @@ autostart=false
6767
autorestart=true
6868
stdout_logfile=syslog
6969
stderr_logfile=syslog
70+
71+
[program:vlanmgrd]
72+
command=/usr/bin/vlanmgrd
73+
priority=9
74+
autostart=false
75+
autorestart=false
76+
stdout_logfile=syslog
77+
stderr_logfile=syslog
78+
79+
[program:intfmgrd]
80+
command=/usr/bin/intfmgrd
81+
priority=10
82+
autostart=false
83+
autorestart=false
84+
stdout_logfile=syslog
85+
stderr_logfile=syslog

files/image_config/interfaces/interfaces.j2

-27
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,6 @@ iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
5555
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
5656
#
5757
{% endfor %}
58-
{% if VLAN %}
59-
# "|| true" is added to suppress the error when interface is already a member of VLAN
60-
{% for vlan in VLAN.keys()|sort %}
61-
{% for member in VLAN[vlan]['members'] %}
62-
allow-hotplug {{ member }}
63-
iface {{ member }} inet manual
64-
pre-up ifconfig {{ member }} up mtu 9100
65-
post-up brctl addif {{ vlan }} {{ member }} || true
66-
post-down ifconfig {{ member }} down
67-
#
68-
{% endfor %}
69-
{% endfor %}
70-
{% endif %}
7158
{% if PORTCHANNEL %}
7259
# "|| true" is added to suppress the error when interface is already a member of LAG
7360
# "ip link show | grep -q master" is added to ensure interface is enslaved
@@ -83,20 +70,6 @@ iface {{ member }} inet manual
8370
{% endfor %}
8471
{% endif %}
8572
{% endblock front_panel_interfaces %}
86-
{% block vlan_interfaces %}
87-
{% if VLAN_INTERFACE %}
88-
# Vlan interfaces
89-
{% for (name, prefix) in VLAN_INTERFACE.keys() | sort %}
90-
auto {{ name }}
91-
iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
92-
bridge_ports none
93-
hwaddress ether {{ hwaddr }}
94-
address {{ prefix | ip }}
95-
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
96-
{% endfor %}
97-
#
98-
{% endif %}
99-
{% endblock vlan_interfaces %}
10073
{% block pc_interfaces %}
10174
{% if PORTCHANNEL_INTERFACE %}
10275
# Portchannel interfaces

src/sonic-config-engine/minigraph.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
ns1 = "http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"
2525
ns2 = "Microsoft.Search.Autopilot.NetMux"
2626
ns3 = "http://www.w3.org/2001/XMLSchema-instance"
27-
27+
KEY_SEPARATOR = '|'
2828

2929
class minigraph_encoder(json.JSONEncoder):
3030
def default(self, obj):
@@ -86,7 +86,7 @@ def parse_png(png, hname):
8686
if child.tag == str(QName(ns, "Devices")):
8787
for device in child.findall(str(QName(ns, "Device"))):
8888
(lo_prefix, mgmt_prefix, name, hwsku, d_type) = parse_device(device)
89-
device_data = {'lo_addr': lo_prefix, 'type': d_type, 'mgmt_addr': mgmt_prefix, 'hwsku': hwsku }
89+
device_data = {'lo_addr': lo_prefix, 'type': d_type, 'mgmt_addr': mgmt_prefix, 'hwsku': hwsku }
9090
devices[name] = device_data
9191

9292
if child.tag == str(QName(ns, "DeviceInterfaceLinks")):
@@ -153,14 +153,18 @@ def parse_dpg(dpg, hname):
153153
vlanintfs = child.find(str(QName(ns, "VlanInterfaces")))
154154
vlan_intfs = []
155155
vlans = {}
156+
vlan_members = {}
156157
for vintf in vlanintfs.findall(str(QName(ns, "VlanInterface"))):
157158
vintfname = vintf.find(str(QName(ns, "Name"))).text
158159
vlanid = vintf.find(str(QName(ns, "VlanID"))).text
159160
vintfmbr = vintf.find(str(QName(ns, "AttachTo"))).text
160161
vmbr_list = vintfmbr.split(';')
161162
for i, member in enumerate(vmbr_list):
162163
vmbr_list[i] = port_alias_map.get(member, member)
163-
vlan_attributes = {'members': vmbr_list, 'vlanid': vlanid}
164+
sonic_vlan_member_name = "Vlan%s%s%s" % (vlanid, KEY_SEPARATOR, vmbr_list[i])
165+
vlan_members[sonic_vlan_member_name] = {'tagging_mode': 'untagged'}
166+
167+
vlan_attributes = {'vlanid': vlanid}
164168

165169
# If this VLAN requires a DHCP relay agent, it will contain a <DhcpRelays> element
166170
# containing a list of DHCP server IPs
@@ -194,8 +198,8 @@ def parse_dpg(dpg, hname):
194198
break;
195199
if acl_intfs:
196200
acls[aclname] = { 'policy_desc': aclname, 'ports': acl_intfs, 'type': 'MIRROR' if is_mirror else 'L3'}
197-
return intfs, lo_intfs, mgmt_intf, vlans, pcs, acls
198-
return None, None, None, None, None, None
201+
return intfs, lo_intfs, mgmt_intf, vlans, vlan_members, pcs, acls
202+
return None, None, None, None, None, None, None
199203

200204

201205
def parse_cpg(cpg, hname):
@@ -318,6 +322,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
318322
vlan_intfs = None
319323
pc_intfs = None
320324
vlans = None
325+
vlan_members = None
321326
pcs = None
322327
mgmt_intf = None
323328
lo_intf = None
@@ -345,7 +350,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
345350
port_alias_map.update(alias_map)
346351
for child in root:
347352
if child.tag == str(QName(ns, "DpgDec")):
348-
(intfs, lo_intfs, mgmt_intf, vlans, pcs, acls) = parse_dpg(child, hostname)
353+
(intfs, lo_intfs, mgmt_intf, vlans, vlan_members, pcs, acls) = parse_dpg(child, hostname)
349354
elif child.tag == str(QName(ns, "CpgDec")):
350355
(bgp_sessions, bgp_asn, bgp_peers_with_range) = parse_cpg(child, hostname)
351356
elif child.tag == str(QName(ns, "PngDec")):
@@ -393,6 +398,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
393398
results['PORT'] = ports
394399
results['PORTCHANNEL'] = pcs
395400
results['VLAN'] = vlans
401+
results['VLAN_MEMBER'] = vlan_members
396402

397403
results['DEVICE_NEIGHBOR'] = neighbors
398404
results['DEVICE_NEIGHBOR_METADATA'] = { key:devices[key] for key in devices if key != hostname }

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

-153
Original file line numberDiff line numberDiff line change
@@ -39,151 +39,6 @@ iface eth0 inet6 static
3939
down ip -6 rule delete from 2603:10e2:0:2902::8/128 table default
4040
#
4141
# The switch front panel interfaces
42-
# "|| true" is added to suppress the error when interface is already a member of VLAN
43-
allow-hotplug fortyGigE0/4
44-
iface fortyGigE0/4 inet manual
45-
pre-up ifconfig fortyGigE0/4 up mtu 9100
46-
post-up brctl addif Vlan1000 fortyGigE0/4 || true
47-
post-down ifconfig fortyGigE0/4 down
48-
#
49-
allow-hotplug fortyGigE0/8
50-
iface fortyGigE0/8 inet manual
51-
pre-up ifconfig fortyGigE0/8 up mtu 9100
52-
post-up brctl addif Vlan1000 fortyGigE0/8 || true
53-
post-down ifconfig fortyGigE0/8 down
54-
#
55-
allow-hotplug fortyGigE0/12
56-
iface fortyGigE0/12 inet manual
57-
pre-up ifconfig fortyGigE0/12 up mtu 9100
58-
post-up brctl addif Vlan1000 fortyGigE0/12 || true
59-
post-down ifconfig fortyGigE0/12 down
60-
#
61-
allow-hotplug fortyGigE0/16
62-
iface fortyGigE0/16 inet manual
63-
pre-up ifconfig fortyGigE0/16 up mtu 9100
64-
post-up brctl addif Vlan1000 fortyGigE0/16 || true
65-
post-down ifconfig fortyGigE0/16 down
66-
#
67-
allow-hotplug fortyGigE0/20
68-
iface fortyGigE0/20 inet manual
69-
pre-up ifconfig fortyGigE0/20 up mtu 9100
70-
post-up brctl addif Vlan1000 fortyGigE0/20 || true
71-
post-down ifconfig fortyGigE0/20 down
72-
#
73-
allow-hotplug fortyGigE0/24
74-
iface fortyGigE0/24 inet manual
75-
pre-up ifconfig fortyGigE0/24 up mtu 9100
76-
post-up brctl addif Vlan1000 fortyGigE0/24 || true
77-
post-down ifconfig fortyGigE0/24 down
78-
#
79-
allow-hotplug fortyGigE0/28
80-
iface fortyGigE0/28 inet manual
81-
pre-up ifconfig fortyGigE0/28 up mtu 9100
82-
post-up brctl addif Vlan1000 fortyGigE0/28 || true
83-
post-down ifconfig fortyGigE0/28 down
84-
#
85-
allow-hotplug fortyGigE0/32
86-
iface fortyGigE0/32 inet manual
87-
pre-up ifconfig fortyGigE0/32 up mtu 9100
88-
post-up brctl addif Vlan1000 fortyGigE0/32 || true
89-
post-down ifconfig fortyGigE0/32 down
90-
#
91-
allow-hotplug fortyGigE0/36
92-
iface fortyGigE0/36 inet manual
93-
pre-up ifconfig fortyGigE0/36 up mtu 9100
94-
post-up brctl addif Vlan1000 fortyGigE0/36 || true
95-
post-down ifconfig fortyGigE0/36 down
96-
#
97-
allow-hotplug fortyGigE0/40
98-
iface fortyGigE0/40 inet manual
99-
pre-up ifconfig fortyGigE0/40 up mtu 9100
100-
post-up brctl addif Vlan1000 fortyGigE0/40 || true
101-
post-down ifconfig fortyGigE0/40 down
102-
#
103-
allow-hotplug fortyGigE0/44
104-
iface fortyGigE0/44 inet manual
105-
pre-up ifconfig fortyGigE0/44 up mtu 9100
106-
post-up brctl addif Vlan1000 fortyGigE0/44 || true
107-
post-down ifconfig fortyGigE0/44 down
108-
#
109-
allow-hotplug fortyGigE0/48
110-
iface fortyGigE0/48 inet manual
111-
pre-up ifconfig fortyGigE0/48 up mtu 9100
112-
post-up brctl addif Vlan1000 fortyGigE0/48 || true
113-
post-down ifconfig fortyGigE0/48 down
114-
#
115-
allow-hotplug fortyGigE0/52
116-
iface fortyGigE0/52 inet manual
117-
pre-up ifconfig fortyGigE0/52 up mtu 9100
118-
post-up brctl addif Vlan1000 fortyGigE0/52 || true
119-
post-down ifconfig fortyGigE0/52 down
120-
#
121-
allow-hotplug fortyGigE0/56
122-
iface fortyGigE0/56 inet manual
123-
pre-up ifconfig fortyGigE0/56 up mtu 9100
124-
post-up brctl addif Vlan1000 fortyGigE0/56 || true
125-
post-down ifconfig fortyGigE0/56 down
126-
#
127-
allow-hotplug fortyGigE0/60
128-
iface fortyGigE0/60 inet manual
129-
pre-up ifconfig fortyGigE0/60 up mtu 9100
130-
post-up brctl addif Vlan1000 fortyGigE0/60 || true
131-
post-down ifconfig fortyGigE0/60 down
132-
#
133-
allow-hotplug fortyGigE0/64
134-
iface fortyGigE0/64 inet manual
135-
pre-up ifconfig fortyGigE0/64 up mtu 9100
136-
post-up brctl addif Vlan1000 fortyGigE0/64 || true
137-
post-down ifconfig fortyGigE0/64 down
138-
#
139-
allow-hotplug fortyGigE0/68
140-
iface fortyGigE0/68 inet manual
141-
pre-up ifconfig fortyGigE0/68 up mtu 9100
142-
post-up brctl addif Vlan1000 fortyGigE0/68 || true
143-
post-down ifconfig fortyGigE0/68 down
144-
#
145-
allow-hotplug fortyGigE0/72
146-
iface fortyGigE0/72 inet manual
147-
pre-up ifconfig fortyGigE0/72 up mtu 9100
148-
post-up brctl addif Vlan1000 fortyGigE0/72 || true
149-
post-down ifconfig fortyGigE0/72 down
150-
#
151-
allow-hotplug fortyGigE0/76
152-
iface fortyGigE0/76 inet manual
153-
pre-up ifconfig fortyGigE0/76 up mtu 9100
154-
post-up brctl addif Vlan1000 fortyGigE0/76 || true
155-
post-down ifconfig fortyGigE0/76 down
156-
#
157-
allow-hotplug fortyGigE0/80
158-
iface fortyGigE0/80 inet manual
159-
pre-up ifconfig fortyGigE0/80 up mtu 9100
160-
post-up brctl addif Vlan1000 fortyGigE0/80 || true
161-
post-down ifconfig fortyGigE0/80 down
162-
#
163-
allow-hotplug fortyGigE0/84
164-
iface fortyGigE0/84 inet manual
165-
pre-up ifconfig fortyGigE0/84 up mtu 9100
166-
post-up brctl addif Vlan1000 fortyGigE0/84 || true
167-
post-down ifconfig fortyGigE0/84 down
168-
#
169-
allow-hotplug fortyGigE0/88
170-
iface fortyGigE0/88 inet manual
171-
pre-up ifconfig fortyGigE0/88 up mtu 9100
172-
post-up brctl addif Vlan1000 fortyGigE0/88 || true
173-
post-down ifconfig fortyGigE0/88 down
174-
#
175-
allow-hotplug fortyGigE0/92
176-
iface fortyGigE0/92 inet manual
177-
pre-up ifconfig fortyGigE0/92 up mtu 9100
178-
post-up brctl addif Vlan1000 fortyGigE0/92 || true
179-
post-down ifconfig fortyGigE0/92 down
180-
#
181-
allow-hotplug fortyGigE0/96
182-
iface fortyGigE0/96 inet manual
183-
pre-up ifconfig fortyGigE0/96 up mtu 9100
184-
post-up brctl addif Vlan1000 fortyGigE0/96 || true
185-
post-down ifconfig fortyGigE0/96 down
186-
#
18742
# "|| true" is added to suppress the error when interface is already a member of LAG
18843
# "ip link show | grep -q master" is added to ensure interface is enslaved
18944
allow-hotplug fortyGigE0/112
@@ -210,14 +65,6 @@ iface fortyGigE0/124 inet manual
21065
post-up ip link show fortyGigE0/124 | grep -q master && ifconfig fortyGigE0/124 up
21166
post-down ifconfig fortyGigE0/124 down
21267
#
213-
# Vlan interfaces
214-
auto Vlan1000
215-
iface Vlan1000 inet static
216-
bridge_ports none
217-
hwaddress ether e4:1d:2d:a5:f3:ad
218-
address 192.168.0.1
219-
netmask 255.255.255.224
220-
#
22168
# Portchannel interfaces
22269
allow-hotplug PortChannel01
22370
iface PortChannel01 inet static

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ def test_minigraph_interfaces(self):
8888
def test_minigraph_vlans(self):
8989
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN'
9090
output = self.run_script(argument)
91-
self.assertEqual(output.strip(), "{'Vlan1000': {'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'members': ['Ethernet8'], 'vlanid': '1000'}}")
91+
self.assertEqual(output.strip(), "{'Vlan1000': {'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000'}}")
92+
93+
def test_minigraph_vlan_members(self):
94+
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN_MEMBER'
95+
output = self.run_script(argument)
96+
self.assertEqual(output.strip(), "{'Vlan1000|Ethernet8': {'tagging_mode': 'untagged'}}")
9297

9398
def test_minigraph_vlan_interfaces(self):
9499
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()"'

src/sonic-swss

src/sonic-swss-common

0 commit comments

Comments
 (0)