From f68aedd7910e19f4b2655c89f2e32baacefd8ba3 Mon Sep 17 00:00:00 2001 From: Abhishek Dosi Date: Mon, 27 Jul 2020 17:46:44 -0700 Subject: [PATCH 1/3] Changes to add template support for copp.json. This is needed so that we can install differnt type of Traps based on Device Role (Tor/Leaf/Mgmt/etc...). Initial use case is to install DHCP/DHCPv6 tarp only for tor router. Signed-off-by: Abhishek Dosi --- dockers/docker-orchagent/copp.json.j2 | 85 +++++++++++++++++++ dockers/docker-orchagent/docker-init.sh | 1 + .../generate_asic_config_checksum.py | 2 +- 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 dockers/docker-orchagent/copp.json.j2 diff --git a/dockers/docker-orchagent/copp.json.j2 b/dockers/docker-orchagent/copp.json.j2 new file mode 100644 index 000000000000..bca660f0f9a1 --- /dev/null +++ b/dockers/docker-orchagent/copp.json.j2 @@ -0,0 +1,85 @@ +[ + { + "COPP_TABLE:default": { + "queue": "0", + "meter_type":"packets", + "mode":"sr_tcm", + "cir":"600", + "cbs":"600", + "red_action":"drop" + }, + "OP": "SET" + }, + { + "COPP_TABLE:trap.group.bgp.lacp": { + "trap_ids": "bgp,bgpv6,lacp", + "trap_action":"trap", + "trap_priority":"4", + "queue": "4" + }, + "OP": "SET" + }, + { + "COPP_TABLE:trap.group.arp": { + "trap_ids": "arp_req,arp_resp,neigh_discovery", + "trap_action":"copy", + "trap_priority":"4", + "queue": "4", + "meter_type":"packets", + "mode":"sr_tcm", + "cir":"600", + "cbs":"600", + "red_action":"drop" + }, + "OP": "SET" + }, +{% if DEVICE_METADATA['localhost']['type'] == "ToRRouter" %} + { + "COPP_TABLE:trap.group.lldp.dhcp.dhcpv6.udld": { + "trap_ids": "lldp,dhcp,dhcpv6,udld", + "trap_action":"trap", + "trap_priority":"4", + "queue": "4" + }, + "OP": "SET" + }, +{% else %} + { + "COPP_TABLE:trap.group.lldp.udld": { + "trap_ids": "lldp,udld", + "trap_action":"trap", + "trap_priority":"4", + "queue": "4" + }, + "OP": "SET" + }, +{% endif %} + { + "COPP_TABLE:trap.group.ip2me": { + "trap_ids": "ip2me", + "trap_action":"trap", + "trap_priority":"1", + "queue": "1", + "meter_type":"packets", + "mode":"sr_tcm", + "cir":"6000", + "cbs":"6000", + "red_action":"drop" + }, + "OP": "SET" + }, + { + "COPP_TABLE:trap.group.nat": { + "trap_ids": "src_nat_miss,dest_nat_miss", + "trap_action":"trap", + "trap_priority":"1", + "queue": "1", + "meter_type":"packets", + "mode":"sr_tcm", + "cir":"600", + "cbs":"600", + "red_action":"drop" + }, + "OP": "SET" + } +] diff --git a/dockers/docker-orchagent/docker-init.sh b/dockers/docker-orchagent/docker-init.sh index 82ae41b117bf..9d2aa16aab74 100755 --- a/dockers/docker-orchagent/docker-init.sh +++ b/dockers/docker-orchagent/docker-init.sh @@ -5,6 +5,7 @@ mkdir -p /etc/swss/config.d/ sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t /usr/share/sonic/templates/switch.json.j2 > /etc/swss/config.d/switch.json sonic-cfggen -d -t /usr/share/sonic/templates/ipinip.json.j2 > /etc/swss/config.d/ipinip.json sonic-cfggen -d -t /usr/share/sonic/templates/ports.json.j2 > /etc/swss/config.d/ports.json +sonic-cfggen -d -t /usr/share/sonic/templates/copp.json.j2 > /etc/swss/config.d/00-copp.config.json # Executed HWSKU specific initialization tasks. if [ -x /usr/share/sonic/hwsku/hwsku-init ]; then diff --git a/files/build_scripts/generate_asic_config_checksum.py b/files/build_scripts/generate_asic_config_checksum.py index ca83f4f26a6f..638259ce938a 100644 --- a/files/build_scripts/generate_asic_config_checksum.py +++ b/files/build_scripts/generate_asic_config_checksum.py @@ -9,7 +9,7 @@ CHUNK_SIZE = 8192 CONFIG_FILES = { - os.path.abspath('./src/sonic-swss/swssconfig/sample/'): ['netbouncer.json', '00-copp.config.json'] + os.path.abspath('./src/sonic-swss/swssconfig/sample/'): ['netbouncer.json'] } OUTPUT_FILE = os.path.abspath('./asic_config_checksum') From cafd6acc016b17855e3f0148d127ac70d0de90c3 Mon Sep 17 00:00:00 2001 From: Abhishek Dosi Date: Wed, 29 Jul 2020 17:50:19 -0700 Subject: [PATCH 2/3] Fixed based on review comments. Signed-off-by: Abhishek Dosi --- dockers/docker-orchagent/copp.json.j2 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dockers/docker-orchagent/copp.json.j2 b/dockers/docker-orchagent/copp.json.j2 index bca660f0f9a1..a9437b7ed62b 100644 --- a/dockers/docker-orchagent/copp.json.j2 +++ b/dockers/docker-orchagent/copp.json.j2 @@ -33,7 +33,7 @@ }, "OP": "SET" }, -{% if DEVICE_METADATA['localhost']['type'] == "ToRRouter" %} +{% if DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] == "ToRRouter" %} { "COPP_TABLE:trap.group.lldp.dhcp.dhcpv6.udld": { "trap_ids": "lldp,dhcp,dhcpv6,udld", @@ -43,7 +43,7 @@ }, "OP": "SET" }, -{% else %} +{% elif DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined %} { "COPP_TABLE:trap.group.lldp.udld": { "trap_ids": "lldp,udld", @@ -53,6 +53,16 @@ }, "OP": "SET" }, +{% else %} + { + "COPP_TABLE:trap.group.lldp.dhcp.dhcpv6.udld": { + "trap_ids": "lldp,dhcp,dhcpv6,udld", + "trap_action":"trap", + "trap_priority":"4", + "queue": "4" + }, + "OP": "SET" + }, {% endif %} { "COPP_TABLE:trap.group.ip2me": { From a6676b08c06d8f0273cd2ffe38be884f4d71b958 Mon Sep 17 00:00:00 2001 From: Abhishek Dosi Date: Thu, 30 Jul 2020 14:38:26 -0700 Subject: [PATCH 3/3] Fixed based on review comment. --- dockers/docker-orchagent/copp.json.j2 | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/dockers/docker-orchagent/copp.json.j2 b/dockers/docker-orchagent/copp.json.j2 index a9437b7ed62b..49173a54e99f 100644 --- a/dockers/docker-orchagent/copp.json.j2 +++ b/dockers/docker-orchagent/copp.json.j2 @@ -33,17 +33,7 @@ }, "OP": "SET" }, -{% if DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] == "ToRRouter" %} - { - "COPP_TABLE:trap.group.lldp.dhcp.dhcpv6.udld": { - "trap_ids": "lldp,dhcp,dhcpv6,udld", - "trap_action":"trap", - "trap_priority":"4", - "queue": "4" - }, - "OP": "SET" - }, -{% elif DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined %} +{% if DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] != "ToRRouter" %} { "COPP_TABLE:trap.group.lldp.udld": { "trap_ids": "lldp,udld",