diff --git a/dockers/docker-orchagent/start.sh b/dockers/docker-orchagent/start.sh index aa4e5b7dae..9f3ba3cb07 100755 --- a/dockers/docker-orchagent/start.sh +++ b/dockers/docker-orchagent/start.sh @@ -22,6 +22,10 @@ supervisorctl start neighsyncd supervisorctl start swssconfig +supervisorctl start vlanmgrd + +supervisorctl start intfmgrd + # Start arp_update when VLAN exists VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'` if [ "$VLAN" != "" ]; then diff --git a/dockers/docker-orchagent/supervisord.conf b/dockers/docker-orchagent/supervisord.conf index 09850b13d4..95e92be622 100644 --- a/dockers/docker-orchagent/supervisord.conf +++ b/dockers/docker-orchagent/supervisord.conf @@ -67,3 +67,19 @@ autostart=false autorestart=true stdout_logfile=syslog stderr_logfile=syslog + +[program:vlanmgrd] +command=/usr/bin/vlanmgrd +priority=9 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:intfmgrd] +command=/usr/bin/intfmgrd +priority=10 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog diff --git a/files/image_config/interfaces/interfaces.j2 b/files/image_config/interfaces/interfaces.j2 index 2fdd04804c..a06ff91518 100644 --- a/files/image_config/interfaces/interfaces.j2 +++ b/files/image_config/interfaces/interfaces.j2 @@ -55,19 +55,6 @@ iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }} # {% endfor %} -{% if VLAN %} -# "|| true" is added to suppress the error when interface is already a member of VLAN -{% for vlan in VLAN.keys()|sort %} -{% for member in VLAN[vlan]['members'] %} -allow-hotplug {{ member }} -iface {{ member }} inet manual - pre-up ifconfig {{ member }} up mtu 9100 - post-up brctl addif {{ vlan }} {{ member }} || true - post-down ifconfig {{ member }} down -# -{% endfor %} -{% endfor %} -{% endif %} {% if PORTCHANNEL %} # "|| true" is added to suppress the error when interface is already a member of LAG # "ip link show | grep -q master" is added to ensure interface is enslaved @@ -83,20 +70,6 @@ iface {{ member }} inet manual {% endfor %} {% endif %} {% endblock front_panel_interfaces %} -{% block vlan_interfaces %} -{% if VLAN_INTERFACE %} -# Vlan interfaces -{% for (name, prefix) in VLAN_INTERFACE.keys() | sort %} -auto {{ name }} -iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static - bridge_ports none - hwaddress ether {{ hwaddr }} - address {{ prefix | ip }} - netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }} -{% endfor %} -# -{% endif %} -{% endblock vlan_interfaces %} {% block pc_interfaces %} {% if PORTCHANNEL_INTERFACE %} # Portchannel interfaces diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index c51b24afed..8269970633 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -24,7 +24,7 @@ ns = "Microsoft.Search.Autopilot.Evolution" ns1 = "http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution" ns2 = "Microsoft.Search.Autopilot.NetMux" ns3 = "http://www.w3.org/2001/XMLSchema-instance" - +KEY_SEPARATOR = '|' class minigraph_encoder(json.JSONEncoder): def default(self, obj): @@ -86,7 +86,7 @@ def parse_png(png, hname): if child.tag == str(QName(ns, "Devices")): for device in child.findall(str(QName(ns, "Device"))): (lo_prefix, mgmt_prefix, name, hwsku, d_type) = parse_device(device) - device_data = {'lo_addr': lo_prefix, 'type': d_type, 'mgmt_addr': mgmt_prefix, 'hwsku': hwsku } + device_data = {'lo_addr': lo_prefix, 'type': d_type, 'mgmt_addr': mgmt_prefix, 'hwsku': hwsku } devices[name] = device_data if child.tag == str(QName(ns, "DeviceInterfaceLinks")): @@ -153,6 +153,7 @@ def parse_dpg(dpg, hname): vlanintfs = child.find(str(QName(ns, "VlanInterfaces"))) vlan_intfs = [] vlans = {} + vlan_members = {} for vintf in vlanintfs.findall(str(QName(ns, "VlanInterface"))): vintfname = vintf.find(str(QName(ns, "Name"))).text vlanid = vintf.find(str(QName(ns, "VlanID"))).text @@ -160,7 +161,10 @@ def parse_dpg(dpg, hname): vmbr_list = vintfmbr.split(';') for i, member in enumerate(vmbr_list): vmbr_list[i] = port_alias_map.get(member, member) - vlan_attributes = {'members': vmbr_list, 'vlanid': vlanid} + sonic_vlan_member_name = "Vlan%s%s%s" % (vlanid, KEY_SEPARATOR, vmbr_list[i]) + vlan_members[sonic_vlan_member_name] = {'tagging_mode': 'untagged'} + + vlan_attributes = {'vlanid': vlanid} # If this VLAN requires a DHCP relay agent, it will contain a element # containing a list of DHCP server IPs @@ -194,8 +198,8 @@ def parse_dpg(dpg, hname): break; if acl_intfs: acls[aclname] = { 'policy_desc': aclname, 'ports': acl_intfs, 'type': 'MIRROR' if is_mirror else 'L3'} - return intfs, lo_intfs, mgmt_intf, vlans, pcs, acls - return None, None, None, None, None, None + return intfs, lo_intfs, mgmt_intf, vlans, vlan_members, pcs, acls + return None, None, None, None, None, None, None def parse_cpg(cpg, hname): @@ -318,6 +322,7 @@ def parse_xml(filename, platform=None, port_config_file=None): vlan_intfs = None pc_intfs = None vlans = None + vlan_members = None pcs = None mgmt_intf = None lo_intf = None @@ -345,7 +350,7 @@ def parse_xml(filename, platform=None, port_config_file=None): port_alias_map.update(alias_map) for child in root: if child.tag == str(QName(ns, "DpgDec")): - (intfs, lo_intfs, mgmt_intf, vlans, pcs, acls) = parse_dpg(child, hostname) + (intfs, lo_intfs, mgmt_intf, vlans, vlan_members, pcs, acls) = parse_dpg(child, hostname) elif child.tag == str(QName(ns, "CpgDec")): (bgp_sessions, bgp_asn, bgp_peers_with_range) = parse_cpg(child, hostname) elif child.tag == str(QName(ns, "PngDec")): @@ -393,6 +398,7 @@ def parse_xml(filename, platform=None, port_config_file=None): results['PORT'] = ports results['PORTCHANNEL'] = pcs results['VLAN'] = vlans + results['VLAN_MEMBER'] = vlan_members results['DEVICE_NEIGHBOR'] = neighbors results['DEVICE_NEIGHBOR_METADATA'] = { key:devices[key] for key in devices if key != hostname } diff --git a/src/sonic-config-engine/tests/sample_output/interfaces b/src/sonic-config-engine/tests/sample_output/interfaces index 89a23471a7..2d54e6dabb 100644 --- a/src/sonic-config-engine/tests/sample_output/interfaces +++ b/src/sonic-config-engine/tests/sample_output/interfaces @@ -39,151 +39,6 @@ iface eth0 inet6 static down ip -6 rule delete from 2603:10e2:0:2902::8/128 table default # # The switch front panel interfaces -# "|| true" is added to suppress the error when interface is already a member of VLAN -allow-hotplug fortyGigE0/4 -iface fortyGigE0/4 inet manual - pre-up ifconfig fortyGigE0/4 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/4 || true - post-down ifconfig fortyGigE0/4 down -# -allow-hotplug fortyGigE0/8 -iface fortyGigE0/8 inet manual - pre-up ifconfig fortyGigE0/8 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/8 || true - post-down ifconfig fortyGigE0/8 down -# -allow-hotplug fortyGigE0/12 -iface fortyGigE0/12 inet manual - pre-up ifconfig fortyGigE0/12 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/12 || true - post-down ifconfig fortyGigE0/12 down -# -allow-hotplug fortyGigE0/16 -iface fortyGigE0/16 inet manual - pre-up ifconfig fortyGigE0/16 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/16 || true - post-down ifconfig fortyGigE0/16 down -# -allow-hotplug fortyGigE0/20 -iface fortyGigE0/20 inet manual - pre-up ifconfig fortyGigE0/20 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/20 || true - post-down ifconfig fortyGigE0/20 down -# -allow-hotplug fortyGigE0/24 -iface fortyGigE0/24 inet manual - pre-up ifconfig fortyGigE0/24 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/24 || true - post-down ifconfig fortyGigE0/24 down -# -allow-hotplug fortyGigE0/28 -iface fortyGigE0/28 inet manual - pre-up ifconfig fortyGigE0/28 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/28 || true - post-down ifconfig fortyGigE0/28 down -# -allow-hotplug fortyGigE0/32 -iface fortyGigE0/32 inet manual - pre-up ifconfig fortyGigE0/32 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/32 || true - post-down ifconfig fortyGigE0/32 down -# -allow-hotplug fortyGigE0/36 -iface fortyGigE0/36 inet manual - pre-up ifconfig fortyGigE0/36 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/36 || true - post-down ifconfig fortyGigE0/36 down -# -allow-hotplug fortyGigE0/40 -iface fortyGigE0/40 inet manual - pre-up ifconfig fortyGigE0/40 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/40 || true - post-down ifconfig fortyGigE0/40 down -# -allow-hotplug fortyGigE0/44 -iface fortyGigE0/44 inet manual - pre-up ifconfig fortyGigE0/44 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/44 || true - post-down ifconfig fortyGigE0/44 down -# -allow-hotplug fortyGigE0/48 -iface fortyGigE0/48 inet manual - pre-up ifconfig fortyGigE0/48 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/48 || true - post-down ifconfig fortyGigE0/48 down -# -allow-hotplug fortyGigE0/52 -iface fortyGigE0/52 inet manual - pre-up ifconfig fortyGigE0/52 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/52 || true - post-down ifconfig fortyGigE0/52 down -# -allow-hotplug fortyGigE0/56 -iface fortyGigE0/56 inet manual - pre-up ifconfig fortyGigE0/56 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/56 || true - post-down ifconfig fortyGigE0/56 down -# -allow-hotplug fortyGigE0/60 -iface fortyGigE0/60 inet manual - pre-up ifconfig fortyGigE0/60 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/60 || true - post-down ifconfig fortyGigE0/60 down -# -allow-hotplug fortyGigE0/64 -iface fortyGigE0/64 inet manual - pre-up ifconfig fortyGigE0/64 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/64 || true - post-down ifconfig fortyGigE0/64 down -# -allow-hotplug fortyGigE0/68 -iface fortyGigE0/68 inet manual - pre-up ifconfig fortyGigE0/68 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/68 || true - post-down ifconfig fortyGigE0/68 down -# -allow-hotplug fortyGigE0/72 -iface fortyGigE0/72 inet manual - pre-up ifconfig fortyGigE0/72 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/72 || true - post-down ifconfig fortyGigE0/72 down -# -allow-hotplug fortyGigE0/76 -iface fortyGigE0/76 inet manual - pre-up ifconfig fortyGigE0/76 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/76 || true - post-down ifconfig fortyGigE0/76 down -# -allow-hotplug fortyGigE0/80 -iface fortyGigE0/80 inet manual - pre-up ifconfig fortyGigE0/80 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/80 || true - post-down ifconfig fortyGigE0/80 down -# -allow-hotplug fortyGigE0/84 -iface fortyGigE0/84 inet manual - pre-up ifconfig fortyGigE0/84 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/84 || true - post-down ifconfig fortyGigE0/84 down -# -allow-hotplug fortyGigE0/88 -iface fortyGigE0/88 inet manual - pre-up ifconfig fortyGigE0/88 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/88 || true - post-down ifconfig fortyGigE0/88 down -# -allow-hotplug fortyGigE0/92 -iface fortyGigE0/92 inet manual - pre-up ifconfig fortyGigE0/92 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/92 || true - post-down ifconfig fortyGigE0/92 down -# -allow-hotplug fortyGigE0/96 -iface fortyGigE0/96 inet manual - pre-up ifconfig fortyGigE0/96 up mtu 9100 - post-up brctl addif Vlan1000 fortyGigE0/96 || true - post-down ifconfig fortyGigE0/96 down -# # "|| true" is added to suppress the error when interface is already a member of LAG # "ip link show | grep -q master" is added to ensure interface is enslaved allow-hotplug fortyGigE0/112 @@ -210,14 +65,6 @@ iface fortyGigE0/124 inet manual post-up ip link show fortyGigE0/124 | grep -q master && ifconfig fortyGigE0/124 up post-down ifconfig fortyGigE0/124 down # -# Vlan interfaces -auto Vlan1000 -iface Vlan1000 inet static - bridge_ports none - hwaddress ether e4:1d:2d:a5:f3:ad - address 192.168.0.1 - netmask 255.255.255.224 -# # Portchannel interfaces allow-hotplug PortChannel01 iface PortChannel01 inet static diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index 31663077c4..47cc006f46 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -88,7 +88,12 @@ class TestCfgGen(TestCase): def test_minigraph_vlans(self): argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN' output = self.run_script(argument) - self.assertEqual(output.strip(), "{'Vlan1000': {'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'members': ['Ethernet8'], 'vlanid': '1000'}}") + self.assertEqual(output.strip(), "{'Vlan1000': {'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000'}}") + + def test_minigraph_vlan_members(self): + argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN_MEMBER' + output = self.run_script(argument) + self.assertEqual(output.strip(), "{'Vlan1000|Ethernet8': {'tagging_mode': 'untagged'}}") def test_minigraph_vlan_interfaces(self): argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()"' diff --git a/src/sonic-swss b/src/sonic-swss index f90a4e1ef3..6e845042c1 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit f90a4e1ef369491b84a048cbf234f4cd3442d552 +Subproject commit 6e845042c1d9097bfe713a32dab7b414527962bf diff --git a/src/sonic-swss-common b/src/sonic-swss-common index a6f74b67a5..adf7d4cb3c 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit a6f74b67a58074439d8f3dbf84fa8ecc0a2e06a6 +Subproject commit adf7d4cb3c22061bf781ef6ce7b79964ce505730