Skip to content

Commit

Permalink
SONiC Yang model support for COPP (#7199)
Browse files Browse the repository at this point in the history
* SONiC Yang model support for COPP
* Tables: COPP_GROUP, COPP_TRAP.
  • Loading branch information
amaneti authored Jun 29, 2021
1 parent 9de7e68 commit 5acf234
Show file tree
Hide file tree
Showing 6 changed files with 406 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'./yang-models/sonic-bgp-neighbor.yang',
'./yang-models/sonic-bgp-peergroup.yang',
'./yang-models/sonic-breakout_cfg.yang',
'./yang-models/sonic-copp.yang',
'./yang-models/sonic-crm.yang',
'./yang-models/sonic-device_metadata.yang',
'./yang-models/sonic-device_neighbor.yang',
Expand Down
19 changes: 18 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,6 @@
"local_ip": "12.12.0.2"
}
},

"BGP_GLOBALS": {
"default": {
"router_id": "5.5.5.5",
Expand Down Expand Up @@ -907,6 +906,24 @@
"PREFIX": {
"prefix1|1|10.0.0.0/8|8..16": {
}
},
"COPP_GROUP": {
"queue1_group1": {
"queue": "1",
"trap_priority":"1",
"trap_action":"trap",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"6000",
"cbs":"6000",
"red_action":"drop"
}
},
"COPP_TRAP": {
"ip2me": {
"trap_ids": "ip2me",
"trap_group": "queue1_group1"
}
}
},

Expand Down
29 changes: 29 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/copp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"COPP_TRAP_WITH_EXIST_GROUP": {
"desc": "Configure COPP_TRAP with group in COPP_GROUP table."
},
"COPP_TRAP_WITH_NON_EXIST_GROUP": {
"desc": "Configure COPP_TRAP with group which does not exist in COPP_GROUP table.",
"eStrKey" : "LeafRef"
},
"COPP_GROUP_MANDATORY_TRAP_ACTION": {
"desc": "Configure COPP_GROUP with no trap_action.",
"eStrKey" : "Mandatory"
},
"COPP_GROUP_MANDATORY_METER_TYPE": {
"desc": "Configure COPP_GROUP with no meter_type.",
"eStrKey" : "Mandatory"
},
"COPP_GROUP_PIR_LESS_THAN_CIR": {
"desc": "Configure COPP_GROUP with PIR less than CIR.",
"eStr": ["pir must be greater than or equal to cir"]
},
"COPP_TRAP_MANDATORY_TRAP_IDS": {
"desc": "Configure COPP_TRAP with no trap_ids.",
"eStrKey" : "Mandatory"
},
"COPP_GROUP_WHEN_SRTCM_WITH_PIR": {
"desc": "Configure COPP_GROUP with srtcm and pir.",
"eStrKey" : "When"
}
}
147 changes: 147 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/copp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
{
"COPP_TRAP_WITH_EXIST_GROUP": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue1_group1",
"trap_action":"trap",
"trap_priority":"1",
"queue": "1",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"6000",
"cbs":"6000",
"red_action":"drop"
}]
},
"sonic-copp:COPP_TRAP": {
"COPP_TRAP_LIST": [{
"name": "ip2me",
"trap_ids": "ip2me",
"trap_group": "queue1_group1"
}]
}
}
},

"COPP_TRAP_WITH_NON_EXIST_GROUP": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue2_group2",
"trap_action":"trap",
"trap_priority":"2",
"queue": "2",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"5000",
"cbs":"5000",
"red_action":"drop"
}]
},
"sonic-copp:COPP_TRAP": {
"COPP_TRAP_LIST": [{
"name": "udld",
"trap_ids": "udld",
"trap_group": "queue3_group3"
}]
}
}
},

"COPP_GROUP_MANDATORY_TRAP_ACTION": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue3_group4",
"trap_priority":"3",
"queue": "3",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"5000",
"cbs":"5000",
"red_action":"drop"
}]
}
}
},

"COPP_GROUP_MANDATORY_METER_TYPE": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue4_group5",
"trap_action":"trap",
"trap_priority":"4",
"queue": "4",
"mode":"sr_tcm",
"cir":"5000",
"cbs":"5000",
"red_action":"drop"
}]
}
}
},

"COPP_GROUP_PIR_LESS_THAN_CIR": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue5_group6",
"trap_action":"trap",
"trap_priority":"5",
"queue": "5",
"mode":"tr_tcm",
"cir":"5000",
"cbs":"5000",
"pir":"4000",
"pbs":"4000",
"red_action":"drop"
}]
}
}
},

"COPP_TRAP_MANDATORY_TRAP_IDS": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue6_group7",
"trap_action":"trap",
"trap_priority":"6",
"queue": "6",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"6000",
"cbs":"6000",
"red_action":"drop"
}]
},
"sonic-copp:COPP_TRAP": {
"COPP_TRAP_LIST": [{
"name": "bgp",
"trap_group": "queue6_group7"
}]
}
}
},

"COPP_GROUP_WHEN_SRTCM_WITH_PIR": {
"sonic-copp:sonic-copp": {
"sonic-copp:COPP_GROUP": {
"COPP_GROUP_LIST": [{
"name": "queue6_group7",
"trap_action":"trap",
"trap_priority":"6",
"queue": "6",
"meter_type":"packets",
"mode":"sr_tcm",
"cir":"6000",
"cbs":"6000",
"pir":"6000",
"red_action":"drop"
}]
}
}
}
}
Loading

0 comments on commit 5acf234

Please sign in to comment.