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

Policy Base Metering #12

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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/yang-templates/sonic-acl.yang.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ module sonic-acl {
prefix sms;
}

import sonic-policer {
prefix policer;
}

description "ACL YANG Module for SONiC OS";

revision 2019-07-01 {
Expand Down Expand Up @@ -72,6 +76,12 @@ module sonic-acl {
/* Validating 'PACKET_ACTION' exist if ACL type is 'CTRLPLANE' */
must "(not(../../ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME=current()/ACL_TABLE_NAME]/type = 'CTRLPLANE')) or (boolean(PACKET_ACTION))";

leaf POLICER_ACTION {
type leafref {
path "/policer:sonic-policer/policer:POLICER/policer:POLICER_LIST/policer:name";
}
}

leaf MIRROR_INGRESS_ACTION {
type leafref {
path "/sms:sonic-mirror-session/sms:MIRROR_SESSION/sms:MIRROR_SESSION_LIST/sms:name";
Expand Down
9 changes: 9 additions & 0 deletions src/sonic-yang-models/yang-templates/sonic-policer.yang.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ module sonic-policer {
prefix stypes;
}

import sonic-acl {
prefix acl;
}

description "Policer YANG Module for SONiC OS";

revision 2022-02-03 {
Expand Down Expand Up @@ -119,6 +123,11 @@ module sonic-policer {
default "forward";
description "Red action";
}

/* prevent deletion of polocer that referenced by ACL rule.
Note that new policer won't be referenced by any ACL rules initially */
must "not(current()/../acl:sonic-acl/acl:ACL_RULE/acl:ACL_RULE_LIST[acl:POLICER_ACTION=current()/name])" {
error-message "Policer cannot be deleted when referenced by an ACL rule.";
}
/* end of list POLICER_LIST */
}
Expand Down
1 change: 1 addition & 0 deletions src/sonic-yang-models/yang-templates/sonic-types.yang.j2
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ module sonic-types {
enum MIRRORV6;
enum MIRROR_DSCP;
enum CTRLPLANE;
enum POLICER;
}
}

Expand Down
Loading