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]Fixing Ethertype field regex in acl rule yang to accept decimal values #26

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@
"V4-ACL-TABLE|DEFAULT_DENY": {
"PACKET_ACTION": "DROP",
"IP_TYPE": "IPv4ANY",
"PRIORITY": "0"
"PRIORITY": "0",
"ETHER_TYPE": "2048"
},
"V4-ACL-TABLE|Rule_20": {
"PACKET_ACTION": "FORWARD",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@
"eStrKey" : "Pattern"
},
"ACL_RULE_L2_INVALID_ETHER": {
"desc": "Configure invalid MAC address format.",
"desc": "Configure invalid ethertype.",
"eStrKey" : "Pattern"
},
"ACL_RULE_L2_VALID_ETHER_IN_DECIMAL": {
"desc": "Configure valid ethertype in decimal format."
},
"ACL_RULE_L2_INVALID_ETHER_IN_DECIMAL": {
"desc": "Configure invalid ethertype in decimal format.",
"eStrKey" : "Pattern"
},
"ACL_PACKET_ACTION_VALIDATE_VALUE_ACCEPT": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,8 @@
"ACL_RULE_LIST": [
{
"ACL_TABLE_NAME": "L2ACL_INVALID_ETHER",
"SRC_MAC": "00.00.AB.CD.EF.00/FF.FF.FF.00.00.00",
"DST_MAC": "00.00.AB.CD.EF.FF/FF.FF.FF.FF.FF.FF",
"SRC_MAC": "00:00:AB:CD:EF:00/FF:FF:FF:00:00:00",
"DST_MAC": "00:00:AB:CD:EF:FF/FF:FF:FF:FF:FF:FF",
"ETHER_TYPE": "64",
"PACKET_ACTION": "FORWARD",
"PRIORITY": 999980,
Expand All @@ -790,6 +790,62 @@
}
}
},
"ACL_RULE_L2_VALID_ETHER_IN_DECIMAL": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_RULE": {
"ACL_RULE_LIST": [
{
"ACL_TABLE_NAME": "L2ACL_VALID_ETHER_DECIMAL",
"SRC_MAC": "00:00:AB:CD:EF:00/FF:FF:FF:00:00:00",
"DST_MAC": "00:00:AB:CD:EF:FF/FF:FF:FF:FF:FF:FF",
"ETHER_TYPE": "2048",
"PACKET_ACTION": "FORWARD",
"PRIORITY": 999980,
"RULE_NAME": "Rule_20"
}
]
},
"sonic-acl:ACL_TABLE": {
"ACL_TABLE_LIST": [
{
"ACL_TABLE_NAME": "L2ACL_VALID_ETHER_DECIMAL",
"policy_desc": "L2ACL Test",
"ports": [ "" ],
"stage": "INGRESS",
"type": "L2"
}
]
}
}
},
"ACL_RULE_L2_INVALID_ETHER_IN_DECIMAL": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_RULE": {
"ACL_RULE_LIST": [
{
"ACL_TABLE_NAME": "L2ACL_INVALID_ETHER_DECIMAL",
"SRC_MAC": "00:00:AB:CD:EF:00/FF:FF:FF:00:00:00",
"DST_MAC": "00:00:AB:CD:EF:FF/FF:FF:FF:FF:FF:FF",
"ETHER_TYPE": "66789",
"PACKET_ACTION": "FORWARD",
"PRIORITY": 999980,
"RULE_NAME": "Rule_20"
}
]
},
"sonic-acl:ACL_TABLE": {
"ACL_TABLE_LIST": [
{
"ACL_TABLE_NAME": "L2ACL_INVALID_ETHER_DECIMAL",
"policy_desc": "L2ACL Test",
"ports": [ "" ],
"stage": "INGRESS",
"type": "L2"
}
]
}
}
},
"ACL_PACKET_ACTION_VALIDATE_VALUE_ACCEPT": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_RULE": {
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-yang-models/yang-templates/sonic-acl.yang.j2
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ module sonic-acl {

leaf ETHER_TYPE {
type string {
pattern "0x0[6-9a-fA-F][0-9a-fA-F]{2}|0x[1-9a-fA-F][0-9a-fA-F]{3}";
pattern "0x0[6-9a-fA-F][0-9a-fA-F]{2}|0x[1-9a-fA-F][0-9a-fA-F]{3}|153[6-9]|15[4-9][0-9]|1[6-9][0-9][0-9]|[2-9][0-9]{3}|[1-5][0-9]{4}|6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}";
Copy link

Choose a reason for hiding this comment

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

since both dec and hex are all supported, is it possible to validate against the range [0, 65535]?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hi Kebo,
I believe the intention is to restrict the ethertypes to ethernet specific values which start from 1536 or 0x600
https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml. So I didn't want to change the behavior.

}
}

Expand Down