Skip to content

Commit

Permalink
Fix yang model for ICMP and ICMPV6 (sonic-net#18311)
Browse files Browse the repository at this point in the history
* Fix yang model for ICMP and ICMPV6

* Change ICMP type and code to 0-255
  • Loading branch information
bingwang-ms authored and mssonicbld committed Mar 11, 2024
1 parent 4ae9a3d commit 13a0d7e
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/acl.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
"ACL_RULE_WITH_VALID_OUT_PORTS": {
"desc": "Configure ACL_RULE with valid OUT_PORTS."
},
"ACL_RULE_WITH_VALID_ICMPV4_CODE": {
"desc": "Configure ACL_RULE with valid ICMPV4 type and code."
},
"ACL_RULE_WITH_VALID_ICMPV6_CODE": {
"desc": "Configure ACL_RULE with valid ICMPV6 type and code."
},
"ACL_TABLE_EMPTY_PORTS": {
"desc": "Configure ACL_TABLE with empty ports."
},
Expand Down
110 changes: 110 additions & 0 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 @@ -590,6 +590,116 @@
}
}
},
"ACL_RULE_WITH_VALID_ICMPV4_CODE": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_RULE": {
"ACL_RULE_LIST": [
{
"ACL_TABLE_NAME": "NO-NSW-PACL-V4",
"ICMP_CODE": 0,
"ICMP_TYPE": 0,
"IP_TYPE": "IPV4",
"PACKET_ACTION": "FORWARD",
"PRIORITY": 999960,
"RULE_NAME": "Rule_40"
}
]
},
"sonic-acl:ACL_TABLE": {
"ACL_TABLE_LIST": [
{
"ACL_TABLE_NAME": "NO-NSW-PACL-V4",
"policy_desc": "Filter IPv4",
"ports": [
"Ethernet0",
"Ethernet1"
],
"stage": "EGRESS",
"type": "L3"
}
]
}
},
"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
},
{
"admin_status": "up",
"alias": "eth1",
"description": "Ethernet1",
"lanes": "4,5,6,7",
"mtu": 9000,
"name": "Ethernet1",
"speed": 25000
}
]
}
}
},
"ACL_RULE_WITH_VALID_ICMPV6_CODE": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_RULE": {
"ACL_RULE_LIST": [
{
"ACL_TABLE_NAME": "NO-NSW-PACL-V6",
"ICMPV6_CODE": 0,
"ICMPV6_TYPE": 129,
"IP_TYPE": "IPV6",
"PACKET_ACTION": "FORWARD",
"PRIORITY": 999960,
"RULE_NAME": "Rule_40"
}
]
},
"sonic-acl:ACL_TABLE": {
"ACL_TABLE_LIST": [
{
"ACL_TABLE_NAME": "NO-NSW-PACL-V6",
"policy_desc": "Filter IPv6",
"ports": [
"Ethernet0",
"Ethernet1"
],
"stage": "EGRESS",
"type": "L3"
}
]
}
},
"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
},
{
"admin_status": "up",
"alias": "eth1",
"description": "Ethernet1",
"lanes": "4,5,6,7",
"mtu": 9000,
"name": "Ethernet1",
"speed": 25000
}
]
}
}
},
"ACL_TABLE_DEFAULT_VALUE_STAGE": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_TABLE": {
Expand Down
8 changes: 4 additions & 4 deletions src/sonic-yang-models/yang-templates/sonic-acl.yang.j2
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ module sonic-acl {
when "not(IP_TYPE) or boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV4' or .='IPv4ANY' or .='ARP'])";
leaf ICMP_TYPE {
type uint8 {
range 1..44;
range 0..255;
}
}

leaf ICMP_CODE {
type uint8 {
range 1..16;
range 0..255;
}
}
}
Expand All @@ -217,13 +217,13 @@ module sonic-acl {
when "not(IP_TYPE) or boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPv6ANY'])";
leaf ICMPV6_TYPE {
type uint8 {
range 1..44;
range 0..255;
}
}

leaf ICMPV6_CODE {
type uint8 {
range 1..16;
range 0..255;
}
}
}
Expand Down

0 comments on commit 13a0d7e

Please sign in to comment.