Skip to content

Commit 12d4ebd

Browse files
Sudharsan Dhamal Gopalarathnamdgsudharsan
authored andcommitted
Copp Manager Changes (sonic-net#4861)
*Introduce CoPP Manager infrastructure Copp service to generate initial copp config template file Co-authored-by: dgsudharsan <sudharsan_gopalarat@dell.com>
1 parent 108cfd4 commit 12d4ebd

17 files changed

+164
-91
lines changed

dockers/docker-orchagent/base_image_files/monit_swss

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
## buffermgrd
1212
## nbrmgrd
1313
## vxlanmgrd
14+
## coppmgrd
1415
##############################################################################
1516
check program swss|orchagent with path "/usr/bin/process_checker swss /usr/bin/orchagent -d /var/log/swss"
1617
if status != 0 for 5 times within 5 cycles then alert repeat every 1 cycles
@@ -41,3 +42,6 @@ check program swss|nbrmgrd with path "/usr/bin/process_checker swss /usr/bin/nbr
4142

4243
check program swss|vxlanmgrd with path "/usr/bin/process_checker swss /usr/bin/vxlanmgrd"
4344
if status != 0 for 5 times within 5 cycles then alert repeat every 1 cycles
45+
46+
check program swss|coppmgrd with path "/usr/bin/process_checker swss /usr/bin/coppmgrd"
47+
if status != 0 for 5 times within 5 cycles then alert repeat every 1 cycles

dockers/docker-orchagent/copp.json.j2

-85
This file was deleted.

dockers/docker-orchagent/critical_processes

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ program:buffermgrd
88
program:vrfmgrd
99
program:nbrmgrd
1010
program:vxlanmgrd
11+
program:coppmgrd

dockers/docker-orchagent/docker-init.sh

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ CFGGEN_PARAMS=" \
88
-t /usr/share/sonic/templates/switch.json.j2,/etc/swss/config.d/switch.json \
99
-t /usr/share/sonic/templates/ipinip.json.j2,/etc/swss/config.d/ipinip.json \
1010
-t /usr/share/sonic/templates/ports.json.j2,/etc/swss/config.d/ports.json \
11-
-t /usr/share/sonic/templates/copp.json.j2,/etc/swss/config.d/00-copp.config.json \
1211
-t /usr/share/sonic/templates/vlan_vars.j2 \
1312
-t /usr/share/sonic/templates/ndppd.conf.j2,/etc/ndppd.conf \
1413
"

dockers/docker-orchagent/supervisord.conf

+12
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ stderr_logfile=syslog
8383
dependent_startup=true
8484
dependent_startup_wait_for=swssconfig:exited
8585

86+
[program:coppmgrd]
87+
command=/usr/bin/coppmgrd
88+
priority=6
89+
autostart=false
90+
autorestart=unexpected
91+
startretries=0
92+
startsecs=0
93+
stdout_logfile=syslog
94+
stderr_logfile=syslog
95+
dependent_startup=true
96+
dependent_startup_wait_for=orchagent:running
97+
8698
[program:neighsyncd]
8799
command=/usr/bin/neighsyncd
88100
priority=7

dockers/docker-orchagent/swssconfig.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ if [[ "$SYSTEM_WARM_START" == "true" ]] || [[ "$SWSS_WARM_START" == "true" ]]; t
5252
exit 0
5353
fi
5454

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

5757
for file in $SWSSCONFIG_ARGS; do
5858
swssconfig /etc/swss/config.d/$file

files/build_templates/docker_image_ctl.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function postStartAction()
138138
if [[ -x /usr/local/bin/db_migrator.py ]]; then
139139
# Migrate the DB to the latest schema version if needed
140140
if [ -z "$DEV" ]; then
141-
/usr/bin/db_migrator.py -o migrate
141+
/usr/local/bin/db_migrator.py -o migrate
142142
fi
143143
fi
144144
# Add redis UDS to the redis group and give read/write access to the group

files/build_templates/sonic_debian_extension.j2

+6
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.sh $FILESYSTEM_ROOT/usr/bin/
330330
sudo cp $IMAGE_CONFIGS/interfaces/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
331331
echo "interfaces-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
332332

333+
# Copy CoPP configuration files and templates
334+
sudo cp $IMAGE_CONFIGS/copp/copp-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
335+
sudo cp $IMAGE_CONFIGS/copp/copp-config.sh $FILESYSTEM_ROOT/usr/bin/
336+
sudo cp $IMAGE_CONFIGS/copp/copp_cfg.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
337+
echo "copp-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
338+
333339
# Copy dhcp client configuration template and create an initial configuration
334340
sudo cp files/dhcp/dhclient.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
335341
j2 files/dhcp/dhclient.conf.j2 | sudo tee $FILESYSTEM_ROOT/etc/dhcp/dhclient.conf
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=Update CoPP configuration
3+
Requires=updategraph.service
4+
After=updategraph.service
5+
6+
[Service]
7+
Type=oneshot
8+
ExecStart=/usr/bin/copp-config.sh
9+
10+
[Install]
11+
WantedBy=multi-user.target
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
sonic-cfggen -d -t /usr/share/sonic/templates/copp_cfg.j2 > /etc/sonic/copp_cfg.json

files/image_config/copp/copp_cfg.j2

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"COPP_GROUP": {
3+
"default": {
4+
"queue": "0",
5+
"meter_type":"packets",
6+
"mode":"sr_tcm",
7+
"cir":"600",
8+
"cbs":"600",
9+
"red_action":"drop"
10+
},
11+
"queue4_group1": {
12+
"trap_action":"trap",
13+
"trap_priority":"4",
14+
"queue": "4"
15+
},
16+
"queue4_group2": {
17+
"trap_action":"copy",
18+
"trap_priority":"4",
19+
"queue": "4",
20+
"meter_type":"packets",
21+
"mode":"sr_tcm",
22+
"cir":"600",
23+
"cbs":"600",
24+
"red_action":"drop"
25+
},
26+
"queue4_group3": {
27+
"trap_action":"trap",
28+
"trap_priority":"4",
29+
"queue": "4"
30+
},
31+
"queue1_group1": {
32+
"trap_action":"trap",
33+
"trap_priority":"1",
34+
"queue": "1",
35+
"meter_type":"packets",
36+
"mode":"sr_tcm",
37+
"cir":"6000",
38+
"cbs":"6000",
39+
"red_action":"drop"
40+
},
41+
"queue1_group2": {
42+
"trap_action":"trap",
43+
"trap_priority":"1",
44+
"queue": "1",
45+
"meter_type":"packets",
46+
"mode":"sr_tcm",
47+
"cir":"600",
48+
"cbs":"600",
49+
"red_action":"drop"
50+
},
51+
"queue2_group1": {
52+
"cbs": "1000",
53+
"cir": "1000",
54+
"genetlink_mcgrp_name": "packets",
55+
"genetlink_name": "psample",
56+
"meter_type": "packets",
57+
"mode": "sr_tcm",
58+
"queue": "2",
59+
"red_action": "drop",
60+
"trap_action": "trap",
61+
"trap_priority": "1"
62+
63+
}
64+
},
65+
"COPP_TRAP": {
66+
"bgp": {
67+
"trap_ids": "bgp,bgpv6",
68+
"trap_group": "queue4_group1"
69+
},
70+
"lacp": {
71+
"trap_ids": "lacp",
72+
"trap_group": "queue4_group1"
73+
},
74+
"arp": {
75+
"trap_ids": "arp_req,arp_resp,neigh_discovery",
76+
"trap_group": "queue4_group2"
77+
},
78+
"lldp": {
79+
"trap_ids": "lldp",
80+
"trap_group": "queue4_group3"
81+
},
82+
{% 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") %}
83+
"dhcp": {
84+
"trap_ids": "dhcp,dhcpv6",
85+
"trap_group": "queue4_group3"
86+
},
87+
{% endif %}
88+
"udld": {
89+
"trap_ids": "udld",
90+
"trap_group": "queue4_group3"
91+
},
92+
"ip2me": {
93+
"trap_ids": "ip2me",
94+
"trap_group": "queue1_group1"
95+
},
96+
"nat": {
97+
"trap_ids": "src_nat_miss,dest_nat_miss",
98+
"trap_group": "queue1_group2"
99+
},
100+
"sflow": {
101+
"trap_group": "queue2_group1",
102+
"trap_ids": "sample_packet"
103+
}
104+
}
105+
}

platform/vs/docker-sonic-vs.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ $(DOCKER_SONIC_VS)_FILES += $(CONFIGDB_LOAD_SCRIPT) \
4848
$(BUFFERS_CONFIG_TEMPLATE) \
4949
$(QOS_CONFIG_TEMPLATE) \
5050
$(SONIC_VERSION) \
51-
$(UPDATE_CHASSISDB_CONFIG_SCRIPT)
51+
$(UPDATE_CHASSISDB_CONFIG_SCRIPT) \
52+
$(COPP_CONFIG_TEMPLATE)
5253

5354
$(DOCKER_SONIC_VS)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER)
5455
SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_VS)

platform/vs/docker-sonic-vs/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ COPY ["start.sh", "orchagent.sh", "files/update_chassisdb_config", "/usr/bin/"]
143143
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
144144
COPY ["files/configdb-load.sh", "/usr/bin/"]
145145
COPY ["files/arp_update", "/usr/bin/"]
146-
COPY ["files/buffers_config.j2", "files/qos_config.j2", "files/arp_update_vars.j2", "/usr/share/sonic/templates/"]
146+
COPY ["files/buffers_config.j2", "files/qos_config.j2", "files/arp_update_vars.j2", "files/copp_cfg.j2", "/usr/share/sonic/templates/"]
147147
COPY ["files/sonic_version.yml", "/etc/sonic/"]
148148
COPY ["database_config.json", "/etc/default/sonic-db/"]
149149
COPY ["hostname.j2", "/usr/share/sonic/templates/"]

platform/vs/docker-sonic-vs/start.sh

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ else
4646
sed -i "s/up/down/g" /tmp/ports.json
4747
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
4848
fi
49+
sonic-cfggen -t /usr/share/sonic/templates/copp_cfg.j2 > /etc/sonic/copp_cfg.json
4950

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

@@ -94,6 +95,8 @@ supervisorctl start portsyncd
9495

9596
supervisorctl start orchagent
9697

98+
supervisorctl start coppmgrd
99+
97100
supervisorctl start neighsyncd
98101

99102
supervisorctl start teamsyncd

platform/vs/docker-sonic-vs/supervisord.conf

+8
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ autorestart=false
5959
stdout_logfile=syslog
6060
stderr_logfile=syslog
6161

62+
[program:coppmgrd]
63+
command=/usr/bin/coppmgrd
64+
priority=7
65+
autostart=false
66+
autorestart=false
67+
stdout_logfile=syslog
68+
stderr_logfile=syslog
69+
6270
[program:neighsyncd]
6371
command=/usr/bin/neighsyncd
6472
priority=8

rules/scripts.dep

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ $(BUFFERS_CONFIG_TEMPLATE)_CACHE_MODE := none
77
$(UPDATE_PROC_VARIABLES_SCRIPT)_CACHE_MODE := none
88
$(QOS_CONFIG_TEMPLATE)_CACHE_MODE := none
99
$(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)_CACHE_MODE := none
10+
$(COPP_CONFIG_TEMPLATE)_CACHE_MODE := none

rules/scripts.mk

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ $(UPDATE_CHASSISDB_CONFIG_SCRIPT)_PATH = files/scripts
2626
SWSS_VARS_TEMPLATE = swss_vars.j2
2727
$(SWSS_VARS_TEMPLATE)_PATH = files/build_templates
2828

29+
COPP_CONFIG_TEMPLATE = copp_cfg.j2
30+
$(COPP_CONFIG_TEMPLATE)_PATH = files/image_config/copp
31+
2932
SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
3033
$(ARP_UPDATE_SCRIPT) \
3134
$(ARP_UPDATE_VARS_TEMPLATE) \
@@ -35,4 +38,5 @@ SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
3538
$(SYSCTL_NET_CONFIG)
3639
$(SYSCTL_NET_CONFIG) \
3740
$(UPDATE_CHASSISDB_CONFIG_SCRIPT) \
38-
$(SWSS_VARS_TEMPLATE)
41+
$(SWSS_VARS_TEMPLATE) \
42+
$(COPP_CONFIG_TEMPLATE)

0 commit comments

Comments
 (0)