From 132759b81d3beff2f686364f4dcebabfa542ce64 Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Fri, 14 Apr 2017 21:17:03 +0300 Subject: [PATCH 1/7] [swss]: Generate config files for Everflow and IPinIP from minigraph - Add Everflow DST IP to minigraph file - Extend minigraph.py to support Everflow - Add templates file for Everflow and IPinIP configuration - Add config.sh for swss docker to generate config files --- .../x86_64-accton_as7512_32x-r0/minigraph.xml | 5 +++++ .../x86_64-arista_7050_qx32/minigraph.xml | 5 +++++ .../x86_64-arista_7060_cx32s/minigraph.xml | 5 +++++ .../x86_64-dell_s6000_s1220-r0/minigraph.xml | 5 +++++ .../x86_64-dell_s6100_c2538-r0/minigraph.xml | 5 +++++ .../x86_64-dell_z9100_c2538-r0/minigraph.xml | 5 +++++ .../x86_64-ingrasys_s9100-r0/minigraph.xml | 5 +++++ .../x86_64-mlnx_msn2410-r0/minigraph.xml | 5 +++++ .../x86_64-mlnx_msn2700-r0/minigraph.xml | 5 +++++ dockers/docker-orchagent/Dockerfile.j2 | 7 +++++-- dockers/docker-orchagent/config.sh | 6 ++++++ dockers/docker-orchagent/ipinip.json.j2 | 18 ++++++++++++++++++ dockers/docker-orchagent/mirror.json.j2 | 18 ++++++++++++++++++ dockers/docker-orchagent/start.sh | 2 +- src/sonic-config-engine/minigraph.py | 9 +++++++-- 15 files changed, 100 insertions(+), 5 deletions(-) create mode 100755 dockers/docker-orchagent/config.sh create mode 100644 dockers/docker-orchagent/ipinip.json.j2 create mode 100644 dockers/docker-orchagent/mirror.json.j2 diff --git a/device/accton/x86_64-accton_as7512_32x-r0/minigraph.xml b/device/accton/x86_64-accton_as7512_32x-r0/minigraph.xml index f2326c44aae3..758aca3551d6 100644 --- a/device/accton/x86_64-accton_as7512_32x-r0/minigraph.xml +++ b/device/accton/x86_64-accton_as7512_32x-r0/minigraph.xml @@ -1064,6 +1064,11 @@ + + ErspanDestinationIpv4 + + 2.2.2.2 + diff --git a/device/arista/x86_64-arista_7050_qx32/minigraph.xml b/device/arista/x86_64-arista_7050_qx32/minigraph.xml index f2ef7b0b8bc2..bbf2508ce4cc 100644 --- a/device/arista/x86_64-arista_7050_qx32/minigraph.xml +++ b/device/arista/x86_64-arista_7050_qx32/minigraph.xml @@ -1064,6 +1064,11 @@ + + ErspanDestinationIpv4 + + 2.2.2.2 + diff --git a/device/arista/x86_64-arista_7060_cx32s/minigraph.xml b/device/arista/x86_64-arista_7060_cx32s/minigraph.xml index 5d7dcea980ff..513a60254818 100644 --- a/device/arista/x86_64-arista_7060_cx32s/minigraph.xml +++ b/device/arista/x86_64-arista_7060_cx32s/minigraph.xml @@ -1064,6 +1064,11 @@ + + ErspanDestinationIpv4 + + 2.2.2.2 + diff --git a/device/dell/x86_64-dell_s6000_s1220-r0/minigraph.xml b/device/dell/x86_64-dell_s6000_s1220-r0/minigraph.xml index 0fd1f49ab868..871a91c7fd02 100644 --- a/device/dell/x86_64-dell_s6000_s1220-r0/minigraph.xml +++ b/device/dell/x86_64-dell_s6000_s1220-r0/minigraph.xml @@ -1064,6 +1064,11 @@ + + ErspanDestinationIpv4 + + 2.2.2.2 + diff --git a/device/dell/x86_64-dell_s6100_c2538-r0/minigraph.xml b/device/dell/x86_64-dell_s6100_c2538-r0/minigraph.xml index 3ae8e77f8024..37fba6c291b1 100644 --- a/device/dell/x86_64-dell_s6100_c2538-r0/minigraph.xml +++ b/device/dell/x86_64-dell_s6100_c2538-r0/minigraph.xml @@ -759,6 +759,11 @@ + + ErspanDestinationIpv4 + + 2.2.2.2 + diff --git a/device/dell/x86_64-dell_z9100_c2538-r0/minigraph.xml b/device/dell/x86_64-dell_z9100_c2538-r0/minigraph.xml index ab1ce20a69a8..b45892801ed3 100644 --- a/device/dell/x86_64-dell_z9100_c2538-r0/minigraph.xml +++ b/device/dell/x86_64-dell_z9100_c2538-r0/minigraph.xml @@ -1064,6 +1064,11 @@ + + ErspanDestinationIpv4 + + 2.2.2.2 + diff --git a/device/ingrasys/x86_64-ingrasys_s9100-r0/minigraph.xml b/device/ingrasys/x86_64-ingrasys_s9100-r0/minigraph.xml index d56428187aa8..0c4dec50942a 100644 --- a/device/ingrasys/x86_64-ingrasys_s9100-r0/minigraph.xml +++ b/device/ingrasys/x86_64-ingrasys_s9100-r0/minigraph.xml @@ -136,6 +136,11 @@ + + ErspanDestinationIpv4 + + 2.2.2.2 + diff --git a/device/mellanox/x86_64-mlnx_msn2410-r0/minigraph.xml b/device/mellanox/x86_64-mlnx_msn2410-r0/minigraph.xml index 01cfdd03c635..ed21b8d6eeb9 100644 --- a/device/mellanox/x86_64-mlnx_msn2410-r0/minigraph.xml +++ b/device/mellanox/x86_64-mlnx_msn2410-r0/minigraph.xml @@ -510,6 +510,11 @@ + + ErspanDestinationIpv4 + + 2.2.2.2 + diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/minigraph.xml b/device/mellanox/x86_64-mlnx_msn2700-r0/minigraph.xml index 4942e64be5e9..ecbabba18da2 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/minigraph.xml +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/minigraph.xml @@ -1064,6 +1064,11 @@ + + ErspanDestinationIpv4 + + 2.2.2.2 + diff --git a/dockers/docker-orchagent/Dockerfile.j2 b/dockers/docker-orchagent/Dockerfile.j2 index 507b0bf03355..6383a893f962 100755 --- a/dockers/docker-orchagent/Dockerfile.j2 +++ b/dockers/docker-orchagent/Dockerfile.j2 @@ -23,10 +23,13 @@ debs/{{ deb }}{{' '}} {%- endfor %} COPY start.sh /usr/bin/start.sh +COPY config.sh /usr/bin/config.sh +COPY ipinip.json.j2 /usr/share/sonic/templates/ipinip.json.j2 +COPY mirror.json.j2 /usr/share/sonic/templates/mirror.json.j2 ## Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/start.sh"] +ENTRYPOINT ["/bin/bash", "-c"] +CMD ["/usr/bin/config.sh && /usr/bin/start.sh"] diff --git a/dockers/docker-orchagent/config.sh b/dockers/docker-orchagent/config.sh new file mode 100755 index 000000000000..813dad9533c5 --- /dev/null +++ b/dockers/docker-orchagent/config.sh @@ -0,0 +1,6 @@ +#!/bin/bash -e + +mkdir -p /etc/swss/config.d/ + +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/ipinip.json.j2 > /etc/swss/config.d/ipinip.json +sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/mirror.json.j2 > /etc/swss/config.d/mirror.json diff --git a/dockers/docker-orchagent/ipinip.json.j2 b/dockers/docker-orchagent/ipinip.json.j2 new file mode 100644 index 000000000000..a6a0738f854d --- /dev/null +++ b/dockers/docker-orchagent/ipinip.json.j2 @@ -0,0 +1,18 @@ +[ + { + "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { + "tunnel_type":"IPINIP", + "src_ip":"{{ minigraph_lo_interfaces[0]['addr'] }}", + "dst_ip":"{{ minigraph_lo_interfaces[0]['addr'] }}", + "dscp_mode":"uniform", +{% if minigraph_hwsku in [ 'ACS-MSN2700', 'ACS-MSN2410', 'ACS-MSN2100' ] %} + "ecn_mode":"standard", +{% else %} + "ecn_mode":"copy_from_outer", +{% endif %} + "ttl_mode":"pipe" + }, + "OP": "SET" + } +] + diff --git a/dockers/docker-orchagent/mirror.json.j2 b/dockers/docker-orchagent/mirror.json.j2 new file mode 100644 index 000000000000..926b36717ebd --- /dev/null +++ b/dockers/docker-orchagent/mirror.json.j2 @@ -0,0 +1,18 @@ +[ + { + "MIRROR_SESSION_TABLE:everflow": { + "src_ip": "{{ minigraph_lo_interfaces[0]['addr'] }}", + "dst_ip": "{{ erspan_dst[0] }}", +{% if minigraph_hwsku in [ 'ACS-MSN2700', 'ACS-MSN2410', 'ACS-MSN2100' ] %} + "gre_type": "0x6558", +{% else %} + "gre_type": "0x88be", +{% endif %} + "dscp": "8", + "ttl": "255", + "queue": "1" + }, + "OP": "SET" + } +] + diff --git a/dockers/docker-orchagent/start.sh b/dockers/docker-orchagent/start.sh index 088d0fe1bcf0..720d9fdbfa4a 100755 --- a/dockers/docker-orchagent/start.sh +++ b/dockers/docker-orchagent/start.sh @@ -43,7 +43,7 @@ ORCHAGENT_ARGS="" PORTSYNCD_ARGS="-p /usr/share/sonic/hwsku/port_config.ini" -SWSSCONFIG_ARGS="00-copp.config.json " +SWSSCONFIG_ARGS="00-copp.config.json ipinip.json mirror.json " if [ "$HWSKU" == "Force10-S6000" ]; then ORCHAGENT_ARGS+="-m $MAC_ADDRESS" diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 42086625bb90..49e8b104a46e 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -282,6 +282,7 @@ def parse_meta(meta, hname): dhcp_servers = [] ntp_servers = [] mgmt_routes = [] + erspan_dst = [] device_metas = meta.find(str(QName(ns, "Devices"))) for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))): if device.find(str(QName(ns1, "Name"))).text == hname: @@ -298,7 +299,9 @@ def parse_meta(meta, hname): syslog_servers = value_group elif name == "ForcedMgmtRoutes": mgmt_routes = value_group - return syslog_servers, dhcp_servers, ntp_servers, mgmt_routes + elif name == "ErspanDestinationIpv4": + erspan_dst = value_group + return syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst def get_console_info(devices, dev, port): @@ -391,6 +394,7 @@ def parse_xml(filename, platform=None, port_config_file=None): dhcp_servers = [] ntp_servers = [] mgmt_routes = [] + erspan_dst = [] hwsku_qn = QName(ns, "HwSku") hostname_qn = QName(ns, "Hostname") @@ -412,7 +416,7 @@ def parse_xml(filename, platform=None, port_config_file=None): elif child.tag == str(QName(ns, "UngDec")): (u_neighbors, u_devices, _, _, _, _) = parse_png(child, hostname) elif child.tag == str(QName(ns, "MetadataDeclaration")): - (syslog_servers, dhcp_servers, ntp_servers, mgmt_routes) = parse_meta(child, hostname) + (syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst) = parse_meta(child, hostname) Tree = lambda: defaultdict(Tree) @@ -460,6 +464,7 @@ def parse_xml(filename, platform=None, port_config_file=None): results['dhcp_servers'] = dhcp_servers results['ntp_servers'] = ntp_servers results['forced_mgmt_routes'] = mgmt_routes + results['erspan_dst'] = erspan_dst return results From 608094def3e74327645124c2f0589a9330cfdcea Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Tue, 18 Apr 2017 11:42:43 +0300 Subject: [PATCH 2/7] [sonic-config-engine]: Add tests for IPinIP and Everflow templates. --- .../tests/sample_output/ipinip.json | 14 ++++++++++++++ .../tests/sample_output/mirror.json | 14 ++++++++++++++ .../tests/t0-sample-graph.xml | 15 +++++++++++++++ src/sonic-config-engine/tests/test_j2files.py | 19 +++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 src/sonic-config-engine/tests/sample_output/ipinip.json create mode 100644 src/sonic-config-engine/tests/sample_output/mirror.json diff --git a/src/sonic-config-engine/tests/sample_output/ipinip.json b/src/sonic-config-engine/tests/sample_output/ipinip.json new file mode 100644 index 000000000000..04d613a5ad61 --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/ipinip.json @@ -0,0 +1,14 @@ +[ + { + "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { + "tunnel_type":"IPINIP", + "src_ip":"10.1.0.32", + "dst_ip":"10.1.0.32", + "dscp_mode":"uniform", + "ecn_mode":"copy_from_outer", + "ttl_mode":"pipe" + }, + "OP": "SET" + } +] + diff --git a/src/sonic-config-engine/tests/sample_output/mirror.json b/src/sonic-config-engine/tests/sample_output/mirror.json new file mode 100644 index 000000000000..06afbf7935cd --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/mirror.json @@ -0,0 +1,14 @@ +[ + { + "MIRROR_SESSION_TABLE:everflow": { + "src_ip": "10.1.0.32", + "dst_ip": "2.2.2.2", + "gre_type": "0x88be", + "dscp": "8", + "ttl": "255", + "queue": "1" + }, + "OP": "SET" + } +] + diff --git a/src/sonic-config-engine/tests/t0-sample-graph.xml b/src/sonic-config-engine/tests/t0-sample-graph.xml index 41e62dca29c2..e359b4fa629f 100644 --- a/src/sonic-config-engine/tests/t0-sample-graph.xml +++ b/src/sonic-config-engine/tests/t0-sample-graph.xml @@ -317,6 +317,21 @@ + + + + switch-t0 + + + ErspanDestinationIpv4 + + 2.2.2.2 + + + + + + switch-t0 Force10-S6000 diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index cf1e32aea519..6ea49efc75f2 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -46,6 +46,25 @@ def test_render_teamd(self, pc): assert pc_name in pc_list test_render_teamd(self, pc_name) + def test_ipinip(self): + ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2') + argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + ipinip_file + ' > ' + self.output_file + self.run_script(argument) + + sample_output_file = os.path.join(self.test_dir, 'sample_output', 'ipinip.json') + + assert filecmp.cmp(sample_output_file, self.output_file) + + def test_everflow(self): + everflow_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'mirror.json.j2') + argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + everflow_file + ' > ' + self.output_file + self.run_script(argument) + + sample_output_file = os.path.join(self.test_dir, 'sample_output', 'mirror.json') + + assert filecmp.cmp(sample_output_file, self.output_file) + + def tearDown(self): try: os.remove(self.output_file) From 385f4dd2a4f0caa1e8265ad439f4b487539aa331 Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Wed, 19 Apr 2017 10:23:11 +0300 Subject: [PATCH 3/7] [swss]: Fix review comments. --- dockers/docker-orchagent/Dockerfile.j2 | 4 ++-- dockers/docker-orchagent/mirror.json.j2 | 2 ++ dockers/docker-orchagent/start.sh | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dockers/docker-orchagent/Dockerfile.j2 b/dockers/docker-orchagent/Dockerfile.j2 index 6383a893f962..55f3b504f820 100755 --- a/dockers/docker-orchagent/Dockerfile.j2 +++ b/dockers/docker-orchagent/Dockerfile.j2 @@ -31,5 +31,5 @@ COPY mirror.json.j2 /usr/share/sonic/templates/mirror.json.j2 RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -ENTRYPOINT ["/bin/bash", "-c"] -CMD ["/usr/bin/config.sh && /usr/bin/start.sh"] +ENTRYPOINT ["/bin/bash"] +CMD ["/usr/bin/start.sh"] diff --git a/dockers/docker-orchagent/mirror.json.j2 b/dockers/docker-orchagent/mirror.json.j2 index 926b36717ebd..38173b49183b 100644 --- a/dockers/docker-orchagent/mirror.json.j2 +++ b/dockers/docker-orchagent/mirror.json.j2 @@ -1,4 +1,5 @@ [ +{% if erspan_dst %} { "MIRROR_SESSION_TABLE:everflow": { "src_ip": "{{ minigraph_lo_interfaces[0]['addr'] }}", @@ -14,5 +15,6 @@ }, "OP": "SET" } +{% endif %} ] diff --git a/dockers/docker-orchagent/start.sh b/dockers/docker-orchagent/start.sh index 720d9fdbfa4a..3edb87eb9949 100755 --- a/dockers/docker-orchagent/start.sh +++ b/dockers/docker-orchagent/start.sh @@ -1,5 +1,7 @@ #!/bin/bash +. config.sh + function start_app { orchagent $ORCHAGENT_ARGS & portsyncd $PORTSYNCD_ARGS & From fdab84b90ff423aa8cc3db8a3d2fdfa533b88ff1 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 21 Apr 2017 13:01:38 -0700 Subject: [PATCH 4/7] Use "dscp_mode":"pipe" for non-mlnx platforms --- dockers/docker-orchagent/ipinip.json.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dockers/docker-orchagent/ipinip.json.j2 b/dockers/docker-orchagent/ipinip.json.j2 index a6a0738f854d..19e98a41295c 100644 --- a/dockers/docker-orchagent/ipinip.json.j2 +++ b/dockers/docker-orchagent/ipinip.json.j2 @@ -4,10 +4,11 @@ "tunnel_type":"IPINIP", "src_ip":"{{ minigraph_lo_interfaces[0]['addr'] }}", "dst_ip":"{{ minigraph_lo_interfaces[0]['addr'] }}", - "dscp_mode":"uniform", {% if minigraph_hwsku in [ 'ACS-MSN2700', 'ACS-MSN2410', 'ACS-MSN2100' ] %} + "dscp_mode":"uniform", "ecn_mode":"standard", {% else %} + "dscp_mode":"pipe", "ecn_mode":"copy_from_outer", {% endif %} "ttl_mode":"pipe" From 0e733f10e49dc0ad66d992e9b9c3c805b9676587 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 21 Apr 2017 13:03:41 -0700 Subject: [PATCH 5/7] "dscp_mode":"pipe" in test sample --- src/sonic-config-engine/tests/sample_output/ipinip.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-config-engine/tests/sample_output/ipinip.json b/src/sonic-config-engine/tests/sample_output/ipinip.json index 04d613a5ad61..00862a379281 100644 --- a/src/sonic-config-engine/tests/sample_output/ipinip.json +++ b/src/sonic-config-engine/tests/sample_output/ipinip.json @@ -4,7 +4,7 @@ "tunnel_type":"IPINIP", "src_ip":"10.1.0.32", "dst_ip":"10.1.0.32", - "dscp_mode":"uniform", + "dscp_mode":"pipe", "ecn_mode":"copy_from_outer", "ttl_mode":"pipe" }, From 628bff4f89adf2378d487d88b22fe5bd67927454 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 21 Apr 2017 13:04:50 -0700 Subject: [PATCH 6/7] Use "queue": "0" for brcm platform --- dockers/docker-orchagent/mirror.json.j2 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dockers/docker-orchagent/mirror.json.j2 b/dockers/docker-orchagent/mirror.json.j2 index 38173b49183b..7a3a9250d7dc 100644 --- a/dockers/docker-orchagent/mirror.json.j2 +++ b/dockers/docker-orchagent/mirror.json.j2 @@ -6,12 +6,13 @@ "dst_ip": "{{ erspan_dst[0] }}", {% if minigraph_hwsku in [ 'ACS-MSN2700', 'ACS-MSN2410', 'ACS-MSN2100' ] %} "gre_type": "0x6558", + "queue": "1", {% else %} "gre_type": "0x88be", + "queue": "0", {% endif %} "dscp": "8", - "ttl": "255", - "queue": "1" + "ttl": "255" }, "OP": "SET" } From 30346df891e33c8908287c75a076fcaf9cc34f8c Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 21 Apr 2017 13:05:29 -0700 Subject: [PATCH 7/7] "queue": "0" in test sample output --- src/sonic-config-engine/tests/sample_output/mirror.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic-config-engine/tests/sample_output/mirror.json b/src/sonic-config-engine/tests/sample_output/mirror.json index 06afbf7935cd..54065700a282 100644 --- a/src/sonic-config-engine/tests/sample_output/mirror.json +++ b/src/sonic-config-engine/tests/sample_output/mirror.json @@ -4,9 +4,9 @@ "src_ip": "10.1.0.32", "dst_ip": "2.2.2.2", "gre_type": "0x88be", + "queue": "0", "dscp": "8", - "ttl": "255", - "queue": "1" + "ttl": "255" }, "OP": "SET" }