Skip to content

Commit 86b4d38

Browse files
[YANG SONIC-ACL] Fix Yang definition of ACL_TABLE_TYPE (#16247) (#16472)
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. Co-authored-by: Zhijian Li <[email protected]>
1 parent 4adaa28 commit 86b4d38

File tree

5 files changed

+69
-15
lines changed

5 files changed

+69
-15
lines changed

src/sonic-yang-models/tests/files/sample_config_db.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1965,16 +1965,16 @@
19651965
},
19661966
"ACL_TABLE_TYPE": {
19671967
"CUSTOM_L3": {
1968-
"matches": [
1968+
"MATCHES": [
19691969
"IN_PORTS",
19701970
"OUT_PORTS",
19711971
"SRC_IP"
19721972
],
1973-
"actions": [
1973+
"ACTIONS": [
19741974
"PACKET_ACTION",
19751975
"MIRROR_INGRESS_ACTION"
19761976
],
1977-
"bind_points": [
1977+
"BIND_POINTS": [
19781978
"PORT",
19791979
"LAG"
19801980
]

src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def initTest(self):
4848
'Range': ['does not satisfy', 'range'],
4949
'MinElements': ['Too few'],
5050
'MaxElements': ['Too many'],
51+
'UnknownElement': ['Unknown element'],
5152
'None': []
5253
}
5354

src/sonic-yang-models/tests/yang_model_tests/tests/acl.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,18 @@
9898
"eStrKey": "MinElements"
9999
},
100100
"ACL_TABLE_CUSTOM_TABLE_TYPE_NO_ACTIONS": {
101-
"desc": "ACL_TABLE LOAD TABLE TYPE SUCCESSFULLY WITH NO ACTIONS.",
101+
"desc": "ACL_TABLE LOAD TABLE TYPE WITH NO ACTIONS.",
102102
"eStrKey" : "Verify",
103103
"verify": {
104104
"xpath": "/sonic-acl:sonic-acl/ACL_TABLE_TYPE/ACL_TABLE_TYPE_LIST[ACL_TABLE_TYPE_NAME='CUSTOM_L3']/ACL_TABLE_TYPE_NAME",
105-
"key": "sonic-acl:actions",
105+
"key": "sonic-acl:ACTIONS",
106106
"value": [""]
107107
}
108108
},
109+
"ACL_TABLE_CUSTOM_TABLE_TYPE_LOWERCASE_KEY": {
110+
"desc": "ACL_TABLE LOAD TABLE TYPE WITH KEY ACTIONS/BIND_POINTS/MATCHES WRITTEN IN LOWERCASE.",
111+
"eStrKey": "UnknownElement"
112+
},
109113
"ACL_TABLE_L2_ACL_FIELDS": {
110114
"desc": "Configure L2 ACL with proper rule fields"
111115
},

src/sonic-yang-models/tests/yang_model_tests/tests_config/acl.json

+56-7
Original file line numberDiff line numberDiff line change
@@ -723,14 +723,14 @@
723723
"ACL_TABLE_TYPE_LIST": [
724724
{
725725
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
726-
"matches": [
726+
"MATCHES": [
727727
"SRC_IP",
728728
"IN_PORTS"
729729
],
730-
"actions": [
730+
"ACTIONS": [
731731
"PACKET_ACTION"
732732
],
733-
"bind_points": [
733+
"BIND_POINTS": [
734734
"PORT"
735735
]
736736
}
@@ -772,10 +772,10 @@
772772
"ACL_TABLE_TYPE_LIST": [
773773
{
774774
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
775-
"actions": [
775+
"ACTIONS": [
776776
"PACKET_ACTION"
777777
],
778-
"bind_points": [
778+
"BIND_POINTS": [
779779
"PORT"
780780
]
781781
}
@@ -817,11 +817,11 @@
817817
"ACL_TABLE_TYPE_LIST": [
818818
{
819819
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
820-
"matches": [
820+
"MATCHES": [
821821
"SRC_IP",
822822
"IN_PORTS"
823823
],
824-
"actions": [
824+
"ACTIONS": [
825825
"PACKET_ACTION"
826826
]
827827
}
@@ -845,6 +845,52 @@
845845
}
846846
},
847847
"ACL_TABLE_CUSTOM_TABLE_TYPE_NO_ACTIONS": {
848+
"sonic-acl:sonic-acl": {
849+
"sonic-acl:ACL_TABLE": {
850+
"ACL_TABLE_LIST": [
851+
{
852+
"ACL_TABLE_NAME": "NO-NSW-PACL-V6",
853+
"policy_desc": "Filter IPv6",
854+
"ports": [
855+
"Ethernet0"
856+
],
857+
"stage": "EGRESS",
858+
"type": "CUSTOM_L3"
859+
}
860+
]
861+
},
862+
"sonic-acl:ACL_TABLE_TYPE": {
863+
"ACL_TABLE_TYPE_LIST": [
864+
{
865+
"ACL_TABLE_TYPE_NAME": "CUSTOM_L3",
866+
"MATCHES": [
867+
"SRC_IP",
868+
"IN_PORTS"
869+
],
870+
"BIND_POINTS": [
871+
"PORT"
872+
]
873+
}
874+
]
875+
}
876+
},
877+
"sonic-port:sonic-port": {
878+
"sonic-port:PORT": {
879+
"PORT_LIST": [
880+
{
881+
"admin_status": "up",
882+
"alias": "eth0",
883+
"description": "Ethernet0",
884+
"lanes": "0,1,2,3",
885+
"mtu": 9000,
886+
"name": "Ethernet0",
887+
"speed": 25000
888+
}
889+
]
890+
}
891+
}
892+
},
893+
"ACL_TABLE_CUSTOM_TABLE_TYPE_LOWERCASE_KEY": {
848894
"sonic-acl:sonic-acl": {
849895
"sonic-acl:ACL_TABLE": {
850896
"ACL_TABLE_LIST": [
@@ -867,6 +913,9 @@
867913
"SRC_IP",
868914
"IN_PORTS"
869915
],
916+
"actions": [
917+
"PACKET_ACTION"
918+
],
870919
"bind_points": [
871920
"PORT"
872921
]

src/sonic-yang-models/yang-templates/sonic-acl.yang.j2

+3-3
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,17 @@ module sonic-acl {
281281
type string;
282282
}
283283

284-
leaf-list matches {
284+
leaf-list MATCHES {
285285
type string;
286286
min-elements 1;
287287
}
288288

289-
leaf-list actions {
289+
leaf-list ACTIONS {
290290
type string;
291291
default "";
292292
}
293293

294-
leaf-list bind_points {
294+
leaf-list BIND_POINTS {
295295
type enumeration {
296296
enum PORT;
297297
enum LAG;

0 commit comments

Comments
 (0)