Skip to content

Commit acad2e6

Browse files
lizhijianrdmssonicbld
authored andcommitted
[YANG SONIC-ACL] Fix Yang definition of IN_PORTS and OUT_PORTS (#16220)
How I did it Update Yang definition of IN_PORTS and OUT_PORTS to string. Since we cannot split the string with comma (,) and validate each substring is a valid SONiC port name. The only restriction for them is must be a string. 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. Build a SONiC image based on 202205 branch and installed on physical DUT. Re try the steps in [Yang] Incorrect definition of IN_PORTS and OUT_PORTS in sonic-acl.yang #16190 and can see below success response:
1 parent b3979d6 commit acad2e6

File tree

3 files changed

+120
-6
lines changed

3 files changed

+120
-6
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
"eStrKey" : "Mandatory",
1515
"eStr": ["ACL_RULE", "PRIORITY"]
1616
},
17+
"ACL_RULE_WITH_VALID_IN_PORTS": {
18+
"desc": "Configure ACL_RULE with valid IN_PORTS."
19+
},
20+
"ACL_RULE_WITH_VALID_OUT_PORTS": {
21+
"desc": "Configure ACL_RULE with valid OUT_PORTS."
22+
},
1723
"ACL_TABLE_EMPTY_PORTS": {
1824
"desc": "Configure ACL_TABLE with empty ports."
1925
},

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

+108
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,114 @@
482482
}
483483
}
484484
},
485+
"ACL_RULE_WITH_VALID_IN_PORTS": {
486+
"sonic-acl:sonic-acl": {
487+
"sonic-acl:ACL_RULE": {
488+
"ACL_RULE_LIST": [
489+
{
490+
"ACL_TABLE_NAME": "NO-NSW-PACL-V4",
491+
"IN_PORTS": "Ethernet0,Ethernet1",
492+
"PACKET_ACTION": "FORWARD",
493+
"PRIORITY": 9999,
494+
"RULE_NAME": "Rule_20",
495+
"SRC_IPV6": "2001::1/64"
496+
}
497+
]
498+
},
499+
"sonic-acl:ACL_TABLE": {
500+
"ACL_TABLE_LIST": [
501+
{
502+
"ACL_TABLE_NAME": "NO-NSW-PACL-V4",
503+
"policy_desc": "Filter IPv4",
504+
"ports": [
505+
"Ethernet0",
506+
"Ethernet1"
507+
],
508+
"stage": "INGRESS",
509+
"type": "L3"
510+
}
511+
]
512+
}
513+
},
514+
"sonic-port:sonic-port": {
515+
"sonic-port:PORT": {
516+
"PORT_LIST": [
517+
{
518+
"admin_status": "up",
519+
"alias": "eth0",
520+
"description": "Ethernet0",
521+
"lanes": "0,1,2,3",
522+
"mtu": 9000,
523+
"name": "Ethernet0",
524+
"speed": 25000
525+
},
526+
{
527+
"admin_status": "up",
528+
"alias": "eth1",
529+
"description": "Ethernet1",
530+
"lanes": "4,5,6,7",
531+
"mtu": 9000,
532+
"name": "Ethernet1",
533+
"speed": 25000
534+
}
535+
]
536+
}
537+
}
538+
},
539+
"ACL_RULE_WITH_VALID_OUT_PORTS": {
540+
"sonic-acl:sonic-acl": {
541+
"sonic-acl:ACL_RULE": {
542+
"ACL_RULE_LIST": [
543+
{
544+
"ACL_TABLE_NAME": "NO-NSW-PACL-V4",
545+
"OUT_PORTS": "Ethernet0,Ethernet1",
546+
"PACKET_ACTION": "FORWARD",
547+
"PRIORITY": 9999,
548+
"RULE_NAME": "Rule_20",
549+
"SRC_IPV6": "2001::1/64"
550+
}
551+
]
552+
},
553+
"sonic-acl:ACL_TABLE": {
554+
"ACL_TABLE_LIST": [
555+
{
556+
"ACL_TABLE_NAME": "NO-NSW-PACL-V4",
557+
"policy_desc": "Filter IPv4",
558+
"ports": [
559+
"Ethernet0",
560+
"Ethernet1"
561+
],
562+
"stage": "EGRESS",
563+
"type": "L3"
564+
}
565+
]
566+
}
567+
},
568+
"sonic-port:sonic-port": {
569+
"sonic-port:PORT": {
570+
"PORT_LIST": [
571+
{
572+
"admin_status": "up",
573+
"alias": "eth0",
574+
"description": "Ethernet0",
575+
"lanes": "0,1,2,3",
576+
"mtu": 9000,
577+
"name": "Ethernet0",
578+
"speed": 25000
579+
},
580+
{
581+
"admin_status": "up",
582+
"alias": "eth1",
583+
"description": "Ethernet1",
584+
"lanes": "4,5,6,7",
585+
"mtu": 9000,
586+
"name": "Ethernet1",
587+
"speed": 25000
588+
}
589+
]
590+
}
591+
}
592+
},
485593
"ACL_TABLE_DEFAULT_VALUE_STAGE": {
486594
"sonic-acl:sonic-acl": {
487595
"sonic-acl:ACL_TABLE": {

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ module sonic-acl {
128128
}
129129
}
130130

131-
leaf-list IN_PORTS {
132-
/* Values in leaf list are UNIQUE */
133-
type uint16;
131+
leaf IN_PORTS {
132+
/* Values is a list of SONiC port name (/port:sonic-port/port:PORT/port:PORT_LIST/port:name) joined by comma */
133+
type string;
134134
}
135135

136-
leaf-list OUT_PORTS {
137-
/* Values in leaf list are UNIQUE */
138-
type uint16;
136+
leaf OUT_PORTS {
137+
/* Values is a list of SONiC port name (/port:sonic-port/port:PORT/port:PORT_LIST/port:name) joined by comma */
138+
type string;
139139
}
140140

141141
choice src_port {

0 commit comments

Comments
 (0)