Skip to content

Commit

Permalink
[YANG SONIC-ACL] Fix Yang definition of ACL_TABLE_TYPE (sonic-net#16247)
Browse files Browse the repository at this point in the history
How I did it
Update Yang definition of ACL_TABLE_TYPE.
Update existing testcase.
Add new testcase to cover lowercase key scenario.

How to verify it
Verified by building sonic_yang_models-1.0-py3-none-any.whl. While building the target package, unit tests were run and passed.
  • Loading branch information
lizhijianrd authored and mssonicbld committed Oct 20, 2023
1 parent 638cded commit 763f846
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -2084,16 +2084,16 @@
},
"ACL_TABLE_TYPE": {
"CUSTOM_L3": {
"matches": [
"MATCHES": [
"IN_PORTS",
"OUT_PORTS",
"SRC_IP"
],
"actions": [
"ACTIONS": [
"PACKET_ACTION",
"MIRROR_INGRESS_ACTION"
],
"bind_points": [
"BIND_POINTS": [
"PORT",
"LAG"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def initTest(self):
'Range': ['does not satisfy', 'range'],
'MinElements': ['Too few'],
'MaxElements': ['Too many'],
'UnknownElement': ['Unknown element'],
'None': []
}

Expand Down
8 changes: 6 additions & 2 deletions src/sonic-yang-models/tests/yang_model_tests/tests/acl.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,18 @@
"eStrKey": "MinElements"
},
"ACL_TABLE_CUSTOM_TABLE_TYPE_NO_ACTIONS": {
"desc": "ACL_TABLE LOAD TABLE TYPE SUCCESSFULLY WITH NO ACTIONS.",
"desc": "ACL_TABLE LOAD TABLE TYPE WITH NO ACTIONS.",
"eStrKey" : "Verify",
"verify": {
"xpath": "/sonic-acl:sonic-acl/ACL_TABLE_TYPE/ACL_TABLE_TYPE_LIST[ACL_TABLE_TYPE_NAME='CUSTOM_L3']/ACL_TABLE_TYPE_NAME",
"key": "sonic-acl:actions",
"key": "sonic-acl:ACTIONS",
"value": [""]
}
},
"ACL_TABLE_CUSTOM_TABLE_TYPE_LOWERCASE_KEY": {
"desc": "ACL_TABLE LOAD TABLE TYPE WITH KEY ACTIONS/BIND_POINTS/MATCHES WRITTEN IN LOWERCASE.",
"eStrKey": "UnknownElement"
},
"ACL_TABLE_L2_ACL_FIELDS": {
"desc": "Configure L2 ACL with proper rule fields"
},
Expand Down
63 changes: 56 additions & 7 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/acl.json
Original file line number Diff line number Diff line change
Expand Up @@ -723,14 +723,14 @@
"ACL_TABLE_TYPE_LIST": [
{
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
"matches": [
"MATCHES": [
"SRC_IP",
"IN_PORTS"
],
"actions": [
"ACTIONS": [
"PACKET_ACTION"
],
"bind_points": [
"BIND_POINTS": [
"PORT"
]
}
Expand Down Expand Up @@ -772,10 +772,10 @@
"ACL_TABLE_TYPE_LIST": [
{
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
"actions": [
"ACTIONS": [
"PACKET_ACTION"
],
"bind_points": [
"BIND_POINTS": [
"PORT"
]
}
Expand Down Expand Up @@ -817,11 +817,11 @@
"ACL_TABLE_TYPE_LIST": [
{
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
"matches": [
"MATCHES": [
"SRC_IP",
"IN_PORTS"
],
"actions": [
"ACTIONS": [
"PACKET_ACTION"
]
}
Expand All @@ -845,6 +845,52 @@
}
},
"ACL_TABLE_CUSTOM_TABLE_TYPE_NO_ACTIONS": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_TABLE": {
"ACL_TABLE_LIST": [
{
"ACL_TABLE_NAME": "NO-NSW-PACL-V6",
"policy_desc": "Filter IPv6",
"ports": [
"Ethernet0"
],
"stage": "EGRESS",
"type": "CUSTOM_L3"
}
]
},
"sonic-acl:ACL_TABLE_TYPE": {
"ACL_TABLE_TYPE_LIST": [
{
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
"MATCHES": [
"SRC_IP",
"IN_PORTS"
],
"BIND_POINTS": [
"PORT"
]
}
]
}
},
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth0",
"description": "Ethernet0",
"lanes": "0,1,2,3",
"mtu": 9000,
"name": "Ethernet0",
"speed": 25000
}
]
}
}
},
"ACL_TABLE_CUSTOM_TABLE_TYPE_LOWERCASE_KEY": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_TABLE": {
"ACL_TABLE_LIST": [
Expand All @@ -867,6 +913,9 @@
"SRC_IP",
"IN_PORTS"
],
"actions": [
"PACKET_ACTION"
],
"bind_points": [
"PORT"
]
Expand Down
6 changes: 3 additions & 3 deletions src/sonic-yang-models/yang-templates/sonic-acl.yang.j2
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,17 @@ module sonic-acl {
type string;
}

leaf-list matches {
leaf-list MATCHES {
type string;
min-elements 1;
}

leaf-list actions {
leaf-list ACTIONS {
type string;
default "";
}

leaf-list bind_points {
leaf-list BIND_POINTS {
type enumeration {
enum PORT;
enum LAG;
Expand Down

0 comments on commit 763f846

Please sign in to comment.