Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[yang] In ACL_RULE PRIORITY is mandatory and also PACKET_ACTION for CTRLPLANE ACLs #10248

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 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 @@ -4,6 +4,16 @@
"eStrKey" : "InvalidValue",
"eStr": ["PACKET_ACTION"]
},
"ACL_RULE_FOR_CTRLPLANE_ACL_REQUIRES_PACKET_ACTION": {
"desc": "ACL_RULE for CTRLPLANE ACLs require PACKET_ACTION.",
"eStrKey" : "Must",
"eStr": ["CTRLPLANE", "PACKET_ACTION"]
},
"ACL_RULE_MANDATORY_PRIORITY": {
"desc": "ACL_RULE MANDATORY PRIORITY field.",
"eStrKey" : "Mandatory",
"eStr": ["ACL_RULE", "PRIORITY"]
},
"ACL_TABLE_EMPTY_PORTS": {
"desc": "Configure ACL_TABLE with empty ports."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,63 @@
}
}
},
"ACL_RULE_FOR_CTRLPLANE_ACL_REQUIRES_PACKET_ACTION": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_RULE": {
"ACL_RULE_LIST": [
{
"ACL_TABLE_NAME": "MGMT_ONLY",
"DST_IP": "10.186.72.0/26",
"IP_TYPE": "IPv4ANY",
"PRIORITY": 999980,
"RULE_NAME": "Rule_20",
"SRC_IP": "10.176.0.0/15"
}
]
},
"sonic-acl:ACL_TABLE": {
"ACL_TABLE_LIST": [
{
"ACL_TABLE_NAME": "MGMT_ONLY",
"policy_desc": "Filter IPv4",
"services": [
"SNMP"
],
"stage": "EGRESS",
"type": "CTRLPLANE"
}
]
}
}
},
"ACL_RULE_MANDATORY_PRIORITY": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_RULE": {
"ACL_RULE_LIST": [
{
"ACL_TABLE_NAME": "EVERFLOW",
"DST_IP": "10.186.72.0/26",
"IP_TYPE": "IPv4ANY",
"RULE_NAME": "Rule_20",
"SRC_IP": "10.176.0.0/15"
}
]
},
"sonic-acl:ACL_TABLE": {
"ACL_TABLE_LIST": [
{
"ACL_TABLE_NAME": "EVERFLOW",
"policy_desc": "Filter IPv4",
"services": [
"SNMP"
],
"stage": "EGRESS",
"type": "MIRROR"
}
]
}
}
},
"ACL_RULE_WITH_NON_EXIST_ACL_TABLE": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_RULE": {
Expand Down
4 changes: 4 additions & 0 deletions src/sonic-yang-models/yang-templates/sonic-acl.yang.j2
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ module sonic-acl {
type stypes:packet_action;
}

/* Validating 'PACKET_ACTION' exist if ACL type is 'CTRLPLANE' */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bingwang-ms Is PACKET_ACTION mandatory for data plane ACL?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, PACKET_ACTION is not mandatory for data plane ACL.
For example, we can have below config for an ACL rule

# redis-cli -n 4 hgetall "ACL_RULE|EVERFLOW|RULE_3"             
1) "PRIORITY"
2) "9997"
3) "MIRROR_INGRESS_ACTION"
4) "session_1"
5) "L4_SRC_PORT"
6) "4661"

must "(not(../../ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME=current()/ACL_TABLE_NAME]/type = 'CTRLPLANE')) or (boolean(PACKET_ACTION))";

leaf MIRROR_INGRESS_ACTION {
type leafref {
path "/sms:sonic-mirror-session/sms:MIRROR_SESSION/sms:MIRROR_SESSION_LIST/sms:name";
Expand All @@ -86,6 +89,7 @@ module sonic-acl {
}

leaf PRIORITY {
mandatory true;
type uint32 {
range 0..999999;
}
Expand Down