Repository navigation
feat: Implement MacSec Controller - #366
sven-rosenzweig wants to merge 3 commits into
Conversation
8163a65 to
90d2868
Compare
90d2868 to
0ec655e
Compare
8b93d0e to
a138d40
Compare
a138d40 to
5a7a6b5
Compare
b2a91f3 to
7f0c17c
Compare
7f0c17c to
dd5de75
Compare
nikatza
left a comment
There was a problem hiding this comment.
This is a cool feature! Thanks for putting time into it :)
So I have lots very small comments that can be addressed quite easy. Other than that, I noticed that the NXOS provider has many inlined todos and fixmes. I am not sure what is the plan with those, so I ask here :)
For validation: I have noticed there are no gNMI test files (those txtars). Could you add those, please? And, do you think it would make sense to add some controller tests to verify the rotation works?
Again, this is really nice and I hope we can deploy soon!! 🚀
| } | ||
|
|
||
| // CryptographicAlgorithm is the MKA key-derivation algorithm used for a pre-shared key. | ||
| // +kubebuilder:validation:Enum=aes-128-cmac;aes-256-cmac |
There was a problem hiding this comment.
| // +kubebuilder:validation:Enum=aes-128-cmac;aes-256-cmac | |
| // +kubebuilder:validation:Enum=AES-128-CMAC;AES-256-CMAC |
| // Sort them in the order they should be used for redundancy rotation. | ||
| // +kubebuilder:validation:MinItems=1 | ||
| // +required | ||
| PreSharedKeys []PreSharedKey `json:"preSharedKeys"` |
There was a problem hiding this comment.
Should this resource internally handle the rotation? I feel like the rotation of keys would be something a higher-level controller would orchestrate and is rather unusual to have on a Brick.
There was a problem hiding this comment.
I would say no. A higher level resource should make sure that there is a valid key associated with the macsec connection. supporting multiple keys allows us to hitless rollover to the new key.
267e582 to
93ff0d4
Compare
Implement layer2 encryption for Cisco IOS-XR and NXOS The MacSec resource is modeled as a tuple of: Device, Interface, Keys and a policy. Multiple secrets are supported to allow key rotation and rollover. Key secrets/passwords are obfuscated with Cisco Type 7 encryption. Follow up is to target the operational status of the keychain and macsec policy Signed-off-by: Sven Rosenzweig <sven.rosenzweig@sap.com>
93ff0d4 to
1517d8f
Compare
Signed-off-by: Sven Rosenzweig <sven.rosenzweig@sap.com>
a39f102 to
3a818fe
Compare
3a818fe to
1e0cd8a
Compare
Merging this branch changes the coverage (6 decrease, 4 increase)
Coverage detailsCompared to commit 33b9ef5 (run #41658633865)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files:
|
| @@ -0,0 +1,181 @@ | |||
| // SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and IronCore contributors | |||
There was a problem hiding this comment.
We should remove the year from here
| "stp-items": { | ||
| "inst-items": { | ||
| "if-items": { | ||
| "If-list": [ | ||
| { | ||
| "bpdufilter": "default", | ||
| "bpduguard": "default", | ||
| "id": "eth1/1", | ||
| "mode": "default" | ||
| } | ||
| ] | ||
| } | ||
| } |
There was a problem hiding this comment.
I am wondering if this piece of config should still be here... is it expected or are we missing some delete?
| "github.com/ironcore-dev/network-operator/api/core/v1alpha1" | ||
| ) | ||
|
|
||
| // log is for logging in this package. |
There was a problem hiding this comment.
| // log is for logging in this package. | |
| // macseclog is for logging in this package. |
| type KeyValidity struct { | ||
| KeyName string | ||
| Valid bool | ||
| } |
There was a problem hiding this comment.
Do you think we need a OperStatus at all? I understand that keys are either configured or not, but they can't be operational per-se (even the models don't expose that). In any case, they should have been rejected by CEL/webhook. So I am wondering if the intention of this is to cover that a key has expired since it was installed? If so may be this needs to be clarified (the naming might be confusing me).
(The initial reason for the OperStatus is that we usually just transport this value from the device, and not create one in the provider, happy to sync about this)
| lifetime := NewLifetime(psk.StartTime.Time, psk.EndTime.Time) | ||
| cryptoAlg, err := ExtractCryptographicAlgo(psk.Algorithm) | ||
| if err != nil { | ||
| return err |
There was a problem hiding this comment.
This should probably return an InvalidArgument error from apiStatus, since this is a configuration that a user needs to fix.
| - source: # Uncomment the following block if you have a DefaultingWebhook (--defaulting ) | ||
| kind: Certificate | ||
| group: cert-manager.io | ||
| version: v1 | ||
| name: serving-cert | ||
| fieldPath: .metadata.namespace # Namespace of the certificate CR | ||
| targets: | ||
| - select: | ||
| kind: MutatingWebhookConfiguration | ||
| fieldPaths: | ||
| - .metadata.annotations.[cert-manager.io/inject-ca-from] | ||
| options: | ||
| delimiter: '/' | ||
| index: 0 | ||
| create: true | ||
| - source: | ||
| kind: Certificate | ||
| group: cert-manager.io | ||
| version: v1 | ||
| name: serving-cert | ||
| fieldPath: .metadata.name | ||
| targets: | ||
| - select: | ||
| kind: MutatingWebhookConfiguration | ||
| fieldPaths: | ||
| - .metadata.annotations.[cert-manager.io/inject-ca-from] | ||
| options: | ||
| delimiter: '/' | ||
| index: 1 | ||
| create: true |
There was a problem hiding this comment.
Is this change actually needed?
|
|
||
| // EndTime is when this key expires. Must be after startTime. | ||
| // +required | ||
| // Validates if the string is a valid datetime in RFC3339 format. |
There was a problem hiding this comment.
The CEL validation is still a cheap thing we could do (while keeping the webhook, which is already useful).
| // +kubebuilder:printcolumn:name="Device",type="string",JSONPath=".spec.deviceRef.name",description="The device this MacSec is configured on" | ||
| // +kubebuilder:printcolumn:name="Interface",type="string",JSONPath=".spec.interfaceRef.name",description="The interface this MacSec is configured on" | ||
| // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status",description="Ready status of the MacSec" | ||
| // +kubebuilder:printcolumn:name="Configured",type=string,JSONPath=`.status.conditions[?(@.type=="Configured")].status`,priority=1 |
There was a problem hiding this comment.
Looking at the changes done to the provider, I wonder what happens when a key expires on the device. Validation webhook won't be called. We essentially detect the drift and try to reinstall the keys (since the controller doesnt validate that either). The device rejects the keys and reenqueue indefinitely (updating the ready condition in the meantime). I am doing several assumptions and might be wrong here. Do you have any thoughts on this regard?
| @@ -0,0 +1,557 @@ | |||
| // SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and IronCore contributors | |||
There was a problem hiding this comment.
Year should be removed here too :)
| return ctrl.Result{}, apistatus.WrapTerminalError(err) | ||
| } | ||
|
|
||
| return ctrl.Result{RequeueAfter: Jitter(r.RequeueInterval)}, nil |
There was a problem hiding this comment.
Should this be a simple ctrl.Result{}? Since there are no errors we should avoid requeuing the resource.
nikatza
left a comment
There was a problem hiding this comment.
Are we missing a macsec.txtar fuer iosxr?
Thanks for your last update, the redacted part is a nice touch!
No description provided.