-
Notifications
You must be signed in to change notification settings - Fork 3.4k
detecting IPSEC SPI unchanged #34037
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
detecting IPSEC SPI unchanged #34037
Conversation
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.
When I was assigned to the issue that's being addressed here, the originally proposed solution involved checking the key and SPI from an existing XFRM state and comparing it to the key and SPI we read in LoadIPSecKeys
. Overall I prefer the simplicity of the approach here but LoadIPSecKeys
not behaving the same if it's called on the same key file even if underlying kernel state has not changed worries me a bit.
2990185
to
d3f0fed
Compare
I modified the code to:
My last doubt are:
|
d3f0fed
to
d4cb5c4
Compare
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.
I think this is good to go without the first commit.
I'd remove it so we can merge because I suspect the other PR will take a bit longer to get ready.
c81b1e0
to
f9f3549
Compare
/test |
f9f3549
to
0bedf7e
Compare
/test |
0bedf7e
to
e55ab8d
Compare
/test |
e55ab8d
to
c986b49
Compare
/test |
removing myself as Paul has already approved on behalf of sig-datapath |
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.
Left one comment with regards to cleaning state after individual tests, otherwise LGTM. Sorry for the long delay on my part.
This commit introduce a control during the `LoadIPSecKeys` to return an error when providing a new key (e.g., during rotation) without incrementing the SPI. In this fix, such case is intercepted and logged with an error, while preserving status and policies referring to the latest/previous valid key by not inserting the key in `ipSecKeysRemovalTime`. Moreover, this commit adjusts the SPI fields in the test data so that they can preserve their expected behaviour. Finally, a new test is introduced to verify that `LoadIPSecKeys` effectively returns an error when the SPI does not while loading a new IPSec key. This "bug" has a user-visible impact during the IPSec key-rotation: if performing the key rotation without changing the SPI, an error message is logged. In this case, the oldKey is not marked to be removed and is still in use. Expected error in the daemons logs while reproducing after the fix: `invalid SPI: changing IPSec keys requires incrementing the key id`. Fixes: cilium#14873 Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
This commit introduces the `UnsetTestIPSecKey` API for testing purpose only. This function is used to reset the current state of IPSec global variables during testing. In particular, it helps to prevent loading two IPSec keys with the same SPI in `node_linux_test`, which would cause the tests to fail after the previous commit. With this function, it is easy to reset the internal state of the IPSec-related variables either while executing a test or when tearing down a test suite. This function is also used in the local `ipsec_linux_test.go`, to expect a coherent behavior while tearing down a test suite. Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
c986b49
to
609d010
Compare
/test |
@smagnani96 fyi there's an outstanding discussion here, once that is resolved the PR should auto-merge. |
Yep, I wanted to wait for the last feedback from @pchaigno to make sure I got what he meant 👍 |
Adding logic (and unit test) to detect unchanged SPI while creating a new IPSEC key.
Fixes: #14873
@pchaigno @julianwiedmann 😃