-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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]: Add yang model for MACsec #10559
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e8f1cc3
Add macsec yang model
Pterosaur b255215
Add regular testcase
Pterosaur 41c0296
Add more testcases
Pterosaur 0caac8a
Add newline at the end of files
Pterosaur ee0de56
add sample
Pterosaur 753b7fb
Fix bug
Pterosaur 2a28135
remove useless newlines
Pterosaur 515aa88
Polish code
Pterosaur 77695fb
Move import to the beggin of module
Pterosaur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/sonic-yang-models/tests/yang_model_tests/tests/macsec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"VALID_PROFILE": { | ||
"desc": "Valid MACsec profile test" | ||
}, | ||
"DUPLICATE_CKN": { | ||
"desc": "Primary CKN equals than fallback CKN", | ||
"eStrKey": "Must" | ||
}, | ||
"INVALID_CAK_LENGTH": { | ||
"desc": "Invalid CAK length", | ||
"eStrKey": "Pattern" | ||
}, | ||
"INVALID_CAK_CHARACTER": { | ||
"desc": "Invalid CAK character", | ||
"eStrKey": "Pattern" | ||
}, | ||
"INVALID_CIPHER_LOWERCASE": { | ||
"desc": "Invalid cipher with lowercase", | ||
"eStrKey": "Pattern" | ||
}, | ||
"MISMATCH_LENGTH_PRIMARY_FALLBACK": { | ||
"desc": "Mismatch length of primary and fallback", | ||
"eStrKey": "Must" | ||
}, | ||
"SET_REPLAY_WINDOW_WHEN_DISABLE_REPLAY_PROTECT": { | ||
"desc": "Set replay window when disable replay protect", | ||
"eStrKey": "When" | ||
} | ||
} |
141 changes: 141 additions & 0 deletions
141
src/sonic-yang-models/tests/yang_model_tests/tests_config/macsec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
{ | ||
"VALID_PROFILE": { | ||
"sonic-macsec:sonic-macsec": { | ||
"sonic-macsec:MACSEC_PROFILE": { | ||
"MACSEC_PROFILE_LIST": [ | ||
{ | ||
"name": "test32", | ||
"priority": 64, | ||
"cipher_suite": "GCM-AES-128", | ||
"primary_cak": "0123456789ABCDEF0123456789ABCDEF", | ||
"primary_ckn": "6162636465666768696A6B6C6D6E6F70", | ||
"fallback_cak": "00000000000000000000000000000000", | ||
"fallback_ckn": "11111111111111111111111111111111", | ||
"policy": "security", | ||
"enable_replay_protect": "true", | ||
"replay_window": 64, | ||
"send_sci": "true", | ||
"rekey_period": 3600 | ||
}, | ||
{ | ||
"name": "test64", | ||
"priority": 64, | ||
"cipher_suite": "GCM-AES-XPN-256", | ||
"primary_cak": "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF", | ||
"primary_ckn": "6162636465666768696A6B6C6D6E6F706162636465666768696A6B6C6D6E6F70", | ||
"fallback_cak": "0000000000000000000000000000000000000000000000000000000000000000", | ||
"fallback_ckn": "1111111111111111111111111111111111111111111111111111111111111111", | ||
"policy": "security", | ||
"enable_replay_protect": "true", | ||
"replay_window": 64, | ||
"send_sci": "true", | ||
"rekey_period": 3600 | ||
} | ||
] | ||
} | ||
}, | ||
"sonic-port:sonic-port": { | ||
"sonic-port:PORT": { | ||
"PORT_LIST": [ | ||
{ | ||
"admin_status": "up", | ||
"alias": "eth8", | ||
"description": "Ethernet8", | ||
"fec": "rs", | ||
"lanes": "65", | ||
"mtu": 9000, | ||
"pfc_asym": "on", | ||
"name": "Ethernet8", | ||
"tpid": "0x8100", | ||
"speed": 25000, | ||
"macsec": "test32" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"INVALID_CIPHER_LOWERCASE": { | ||
"sonic-macsec:sonic-macsec": { | ||
"sonic-macsec:MACSEC_PROFILE": { | ||
"MACSEC_PROFILE_LIST": [ | ||
{ | ||
"name": "test", | ||
"cipher_suite": "gcm-aes-128", | ||
"primary_cak": "0123456789ABCDEF0123456789ABCDEF", | ||
"primary_ckn": "6162636465666768696A6B6C6D6E6F70" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"DUPLICATE_CKN": { | ||
"sonic-macsec:sonic-macsec": { | ||
"sonic-macsec:MACSEC_PROFILE": { | ||
"MACSEC_PROFILE_LIST": [ | ||
{ | ||
"name": "test", | ||
"primary_cak": "0123456789ABCDEF0123456789ABCDEF", | ||
"primary_ckn": "6162636465666768696A6B6C6D6E6F70", | ||
"fallback_cak": "0123456789ABCDEF0123456789ABCDEF", | ||
"fallback_ckn": "6162636465666768696A6B6C6D6E6F70" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"INVALID_CAK_LENGTH": { | ||
"sonic-macsec:sonic-macsec": { | ||
"sonic-macsec:MACSEC_PROFILE": { | ||
"MACSEC_PROFILE_LIST": [ | ||
{ | ||
"name": "test", | ||
"primary_cak": "0123456789ABCDEF0123456789ABCDEFA", | ||
"primary_ckn": "6162636465666768696A6B6C6D6E6F70A" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"INVALID_CAK_CHARACTER": { | ||
"sonic-macsec:sonic-macsec": { | ||
"sonic-macsec:MACSEC_PROFILE": { | ||
"MACSEC_PROFILE_LIST": [ | ||
{ | ||
"name": "test", | ||
"primary_cak": "X123456789ABCDEF0123456789ABCDEF", | ||
"primary_ckn": "X162636465666768696A6B6C6D6E6F70" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"MISMATCH_LENGTH_PRIMARY_FALLBACK": { | ||
"sonic-macsec:sonic-macsec": { | ||
"sonic-macsec:MACSEC_PROFILE": { | ||
"MACSEC_PROFILE_LIST": [ | ||
{ | ||
"name": "test", | ||
"primary_cak": "0123456789ABCDEF0123456789ABCDEF", | ||
"primary_ckn": "6162636465666768696A6B6C6D6E6F70", | ||
"fallback_cak": "0000000000000000000000000000000000000000000000000000000000000000", | ||
"fallback_ckn": "1111111111111111111111111111111111111111111111111111111111111111" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"SET_REPLAY_WINDOW_WHEN_DISABLE_REPLAY_PROTECT": { | ||
"sonic-macsec:sonic-macsec": { | ||
"sonic-macsec:MACSEC_PROFILE": { | ||
"MACSEC_PROFILE_LIST": [ | ||
{ | ||
"name": "test", | ||
"primary_cak": "0123456789ABCDEF0123456789ABCDEF", | ||
"primary_ckn": "6162636465666768696A6B6C6D6E6F70", | ||
"replay_window": 64 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
module sonic-macsec { | ||
|
||
yang-version 1.1; | ||
|
||
namespace "http://github.com/Azure/sonic-macsec"; | ||
|
||
prefix macsec; | ||
|
||
description "MACsec yang Module for SONiC OS"; | ||
|
||
revision 2022-04-12 { | ||
description "First Revision"; | ||
} | ||
|
||
|
||
container sonic-macsec { | ||
|
||
container MACSEC_PROFILE { | ||
|
||
description "MACsec profile of config_db.json"; | ||
|
||
list MACSEC_PROFILE_LIST { | ||
|
||
key "name"; | ||
|
||
leaf name { | ||
type string { | ||
length 1..128; | ||
} | ||
} | ||
|
||
leaf priority { | ||
type uint8; | ||
default 255; | ||
} | ||
|
||
leaf cipher_suite { | ||
type string { | ||
pattern "GCM-AES-128|GCM-AES-256|GCM-AES-XPN-128|GCM-AES-XPN-256"; | ||
} | ||
default "GCM-AES-128"; | ||
} | ||
|
||
leaf primary_cak { | ||
type string { | ||
pattern "[0-9a-fA-F]{32}|[0-9a-fA-F]{64}"; | ||
} | ||
mandatory true; | ||
} | ||
|
||
leaf primary_ckn { | ||
type string { | ||
pattern "[0-9a-fA-F]{32}|[0-9a-fA-F]{64}"; | ||
} | ||
mandatory true; | ||
} | ||
|
||
leaf fallback_cak { | ||
type string { | ||
pattern "[0-9a-fA-F]{32}|[0-9a-fA-F]{64}"; | ||
} | ||
} | ||
|
||
leaf fallback_ckn { | ||
type string { | ||
pattern "[0-9a-fA-F]{32}|[0-9a-fA-F]{64}"; | ||
} | ||
} | ||
|
||
must "string-length(primary_cak) = string-length(primary_ckn)"; | ||
|
||
must "string-length(fallback_cak) = string-length(fallback_ckn)"; | ||
|
||
must "string-length(fallback_cak) = string-length(primary_cak)"; | ||
|
||
must "primary_ckn != fallback_ckn"; | ||
|
||
leaf policy { | ||
type string { | ||
pattern "integrity_only|security"; | ||
} | ||
default "security"; | ||
} | ||
|
||
leaf enable_replay_protect { | ||
type string { | ||
pattern "true|false"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
default "false"; | ||
} | ||
|
||
leaf replay_window { | ||
when "current()/../enable_replay_protect = 'true'"; | ||
type uint32; | ||
} | ||
|
||
leaf send_sci { | ||
type string { | ||
pattern "true|false"; | ||
} | ||
default "true"; | ||
} | ||
|
||
leaf rekey_period { | ||
description "The period of proactively refresh (Unit second). | ||
If the value is 0, which means never proactive refresh SAK."; | ||
type uint32; | ||
default 0; | ||
} | ||
|
||
} /* end of list MACSEC_PROFILE_LIST */ | ||
|
||
} /* end of container MACSEC_PROFILE */ | ||
|
||
} /* end of container sonic-macsec */ | ||
|
||
} /* end of module sonic-macsec */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you please remove the ','