Skip to content

Commit

Permalink
Copp Manager Changes (sonic-net#4861)
Browse files Browse the repository at this point in the history
*Introduce CoPP Manager infrastructure
Copp service to generate initial copp config template file

Co-authored-by: dgsudharsan <sudharsan_gopalarat@dell.com>
  • Loading branch information
2 people authored and santhosh-kt committed Feb 25, 2021
1 parent 108cfd4 commit 12d4ebd
Show file tree
Hide file tree
Showing 17 changed files with 164 additions and 91 deletions.
4 changes: 4 additions & 0 deletions dockers/docker-orchagent/base_image_files/monit_swss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
## buffermgrd
## nbrmgrd
## vxlanmgrd
## coppmgrd
##############################################################################
check program swss|orchagent with path "/usr/bin/process_checker swss /usr/bin/orchagent -d /var/log/swss"
if status != 0 for 5 times within 5 cycles then alert repeat every 1 cycles
Expand Down Expand Up @@ -41,3 +42,6 @@ check program swss|nbrmgrd with path "/usr/bin/process_checker swss /usr/bin/nbr

check program swss|vxlanmgrd with path "/usr/bin/process_checker swss /usr/bin/vxlanmgrd"
if status != 0 for 5 times within 5 cycles then alert repeat every 1 cycles

check program swss|coppmgrd with path "/usr/bin/process_checker swss /usr/bin/coppmgrd"
if status != 0 for 5 times within 5 cycles then alert repeat every 1 cycles
85 changes: 0 additions & 85 deletions dockers/docker-orchagent/copp.json.j2

This file was deleted.

1 change: 1 addition & 0 deletions dockers/docker-orchagent/critical_processes
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ program:buffermgrd
program:vrfmgrd
program:nbrmgrd
program:vxlanmgrd
program:coppmgrd
1 change: 0 additions & 1 deletion dockers/docker-orchagent/docker-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ CFGGEN_PARAMS=" \
-t /usr/share/sonic/templates/switch.json.j2,/etc/swss/config.d/switch.json \
-t /usr/share/sonic/templates/ipinip.json.j2,/etc/swss/config.d/ipinip.json \
-t /usr/share/sonic/templates/ports.json.j2,/etc/swss/config.d/ports.json \
-t /usr/share/sonic/templates/copp.json.j2,/etc/swss/config.d/00-copp.config.json \
-t /usr/share/sonic/templates/vlan_vars.j2 \
-t /usr/share/sonic/templates/ndppd.conf.j2,/etc/ndppd.conf \
"
Expand Down
12 changes: 12 additions & 0 deletions dockers/docker-orchagent/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=swssconfig:exited

[program:coppmgrd]
command=/usr/bin/coppmgrd
priority=6
autostart=false
autorestart=unexpected
startretries=0
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=orchagent:running

[program:neighsyncd]
command=/usr/bin/neighsyncd
priority=7
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-orchagent/swssconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [[ "$SYSTEM_WARM_START" == "true" ]] || [[ "$SWSS_WARM_START" == "true" ]]; t
exit 0
fi

SWSSCONFIG_ARGS="00-copp.config.json ipinip.json ports.json switch.json "
SWSSCONFIG_ARGS="ipinip.json ports.json switch.json "

for file in $SWSSCONFIG_ARGS; do
swssconfig /etc/swss/config.d/$file
Expand Down
2 changes: 1 addition & 1 deletion files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function postStartAction()
if [[ -x /usr/local/bin/db_migrator.py ]]; then
# Migrate the DB to the latest schema version if needed
if [ -z "$DEV" ]; then
/usr/bin/db_migrator.py -o migrate
/usr/local/bin/db_migrator.py -o migrate
fi
fi
# Add redis UDS to the redis group and give read/write access to the group
Expand Down
6 changes: 6 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.sh $FILESYSTEM_ROOT/usr/bin/
sudo cp $IMAGE_CONFIGS/interfaces/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
echo "interfaces-config.service" | sudo tee -a $GENERATED_SERVICE_FILE

# Copy CoPP configuration files and templates
sudo cp $IMAGE_CONFIGS/copp/copp-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
sudo cp $IMAGE_CONFIGS/copp/copp-config.sh $FILESYSTEM_ROOT/usr/bin/
sudo cp $IMAGE_CONFIGS/copp/copp_cfg.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
echo "copp-config.service" | sudo tee -a $GENERATED_SERVICE_FILE

# Copy dhcp client configuration template and create an initial configuration
sudo cp files/dhcp/dhclient.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
j2 files/dhcp/dhclient.conf.j2 | sudo tee $FILESYSTEM_ROOT/etc/dhcp/dhclient.conf
Expand Down
11 changes: 11 additions & 0 deletions files/image_config/copp/copp-config.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Update CoPP configuration
Requires=updategraph.service
After=updategraph.service

[Service]
Type=oneshot
ExecStart=/usr/bin/copp-config.sh

[Install]
WantedBy=multi-user.target
3 changes: 3 additions & 0 deletions files/image_config/copp/copp-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sonic-cfggen -d -t /usr/share/sonic/templates/copp_cfg.j2 > /etc/sonic/copp_cfg.json
105 changes: 105 additions & 0 deletions files/image_config/copp/copp_cfg.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"COPP_GROUP": {
"default": {
"queue": "0",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"600",
"cbs":"600",
"red_action":"drop"
},
"queue4_group1": {
"trap_action":"trap",
"trap_priority":"4",
"queue": "4"
},
"queue4_group2": {
"trap_action":"copy",
"trap_priority":"4",
"queue": "4",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"600",
"cbs":"600",
"red_action":"drop"
},
"queue4_group3": {
"trap_action":"trap",
"trap_priority":"4",
"queue": "4"
},
"queue1_group1": {
"trap_action":"trap",
"trap_priority":"1",
"queue": "1",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"6000",
"cbs":"6000",
"red_action":"drop"
},
"queue1_group2": {
"trap_action":"trap",
"trap_priority":"1",
"queue": "1",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"600",
"cbs":"600",
"red_action":"drop"
},
"queue2_group1": {
"cbs": "1000",
"cir": "1000",
"genetlink_mcgrp_name": "packets",
"genetlink_name": "psample",
"meter_type": "packets",
"mode": "sr_tcm",
"queue": "2",
"red_action": "drop",
"trap_action": "trap",
"trap_priority": "1"

}
},
"COPP_TRAP": {
"bgp": {
"trap_ids": "bgp,bgpv6",
"trap_group": "queue4_group1"
},
"lacp": {
"trap_ids": "lacp",
"trap_group": "queue4_group1"
},
"arp": {
"trap_ids": "arp_req,arp_resp,neigh_discovery",
"trap_group": "queue4_group2"
},
"lldp": {
"trap_ids": "lldp",
"trap_group": "queue4_group3"
},
{% if not (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] != "ToRRouter") %}
"dhcp": {
"trap_ids": "dhcp,dhcpv6",
"trap_group": "queue4_group3"
},
{% endif %}
"udld": {
"trap_ids": "udld",
"trap_group": "queue4_group3"
},
"ip2me": {
"trap_ids": "ip2me",
"trap_group": "queue1_group1"
},
"nat": {
"trap_ids": "src_nat_miss,dest_nat_miss",
"trap_group": "queue1_group2"
},
"sflow": {
"trap_group": "queue2_group1",
"trap_ids": "sample_packet"
}
}
}
3 changes: 2 additions & 1 deletion platform/vs/docker-sonic-vs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ $(DOCKER_SONIC_VS)_FILES += $(CONFIGDB_LOAD_SCRIPT) \
$(BUFFERS_CONFIG_TEMPLATE) \
$(QOS_CONFIG_TEMPLATE) \
$(SONIC_VERSION) \
$(UPDATE_CHASSISDB_CONFIG_SCRIPT)
$(UPDATE_CHASSISDB_CONFIG_SCRIPT) \
$(COPP_CONFIG_TEMPLATE)

$(DOCKER_SONIC_VS)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER)
SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_VS)
2 changes: 1 addition & 1 deletion platform/vs/docker-sonic-vs/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ COPY ["start.sh", "orchagent.sh", "files/update_chassisdb_config", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/configdb-load.sh", "/usr/bin/"]
COPY ["files/arp_update", "/usr/bin/"]
COPY ["files/buffers_config.j2", "files/qos_config.j2", "files/arp_update_vars.j2", "/usr/share/sonic/templates/"]
COPY ["files/buffers_config.j2", "files/qos_config.j2", "files/arp_update_vars.j2", "files/copp_cfg.j2", "/usr/share/sonic/templates/"]
COPY ["files/sonic_version.yml", "/etc/sonic/"]
COPY ["database_config.json", "/etc/default/sonic-db/"]
COPY ["hostname.j2", "/usr/share/sonic/templates/"]
Expand Down
3 changes: 3 additions & 0 deletions platform/vs/docker-sonic-vs/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ else
sed -i "s/up/down/g" /tmp/ports.json
sonic-cfggen -j /etc/sonic/init_cfg.json -j /tmp/buffers.json -j /tmp/qos.json -j /tmp/ports.json --print-data > /etc/sonic/config_db.json
fi
sonic-cfggen -t /usr/share/sonic/templates/copp_cfg.j2 > /etc/sonic/copp_cfg.json

mkdir -p /etc/swss/config.d/

Expand Down Expand Up @@ -94,6 +95,8 @@ supervisorctl start portsyncd

supervisorctl start orchagent

supervisorctl start coppmgrd

supervisorctl start neighsyncd

supervisorctl start teamsyncd
Expand Down
8 changes: 8 additions & 0 deletions platform/vs/docker-sonic-vs/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:coppmgrd]
command=/usr/bin/coppmgrd
priority=7
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:neighsyncd]
command=/usr/bin/neighsyncd
priority=8
Expand Down
1 change: 1 addition & 0 deletions rules/scripts.dep
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ $(BUFFERS_CONFIG_TEMPLATE)_CACHE_MODE := none
$(UPDATE_PROC_VARIABLES_SCRIPT)_CACHE_MODE := none
$(QOS_CONFIG_TEMPLATE)_CACHE_MODE := none
$(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)_CACHE_MODE := none
$(COPP_CONFIG_TEMPLATE)_CACHE_MODE := none
6 changes: 5 additions & 1 deletion rules/scripts.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ $(UPDATE_CHASSISDB_CONFIG_SCRIPT)_PATH = files/scripts
SWSS_VARS_TEMPLATE = swss_vars.j2
$(SWSS_VARS_TEMPLATE)_PATH = files/build_templates

COPP_CONFIG_TEMPLATE = copp_cfg.j2
$(COPP_CONFIG_TEMPLATE)_PATH = files/image_config/copp

SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
$(ARP_UPDATE_SCRIPT) \
$(ARP_UPDATE_VARS_TEMPLATE) \
Expand All @@ -35,4 +38,5 @@ SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
$(SYSCTL_NET_CONFIG)
$(SYSCTL_NET_CONFIG) \
$(UPDATE_CHASSISDB_CONFIG_SCRIPT) \
$(SWSS_VARS_TEMPLATE)
$(SWSS_VARS_TEMPLATE) \
$(COPP_CONFIG_TEMPLATE)

0 comments on commit 12d4ebd

Please sign in to comment.