Tobias Brunner
2f211ced9c
proposal: Parse modpnone as MODP_NONE(0)
2016-06-17 18:48:07 +02:00
Tobias Brunner
09711198a7
ike-rekey: Make sure to ignore task when detecting collisions if ike-init subtask failed
...
For instance, if INVALID_KE_PAYLOAD is returned we don't want this task
to affect any active rekeying (no new SA has been established so far).
2016-06-17 18:48:06 +02:00
Tobias Brunner
2e33d1f9ae
unit-tests: Add test for rekey collision if one CREATE_CHILD_SA response is delayed
2016-06-17 18:48:06 +02:00
Tobias Brunner
566134b25a
unit-tests: Add tests for IKE_SA rekeying if collision is not detected by one peer
2016-06-17 18:48:06 +02:00
Tobias Brunner
f67199378d
ike-rekey: Handle undetected collisions also if delete is delayed
...
If the peer does not detect the rekey collision and deletes the old
IKE_SA and then receives the colliding rekey request it will respond with
TEMPORARY_FAILURE. That notify may arrive before the DELETE does, in
which case we may just conclude the rekeying initiated by the peer.
Also, since the IKE_SA is destroyed in any case when we receive a delete
there is no point in storing the delete task in collide() as process_i()
in the ike-rekey task will never be called.
2016-06-17 18:48:06 +02:00
Tobias Brunner
7426576184
ike-rekey: There is no passive reauth task, so it will never collide with one
2016-06-17 18:48:06 +02:00
Tobias Brunner
724d65900c
ike-rekey: Ignore colliding rekey tasks that did not create an IKE_SA
...
This simplifies collision handling and we don't need to know about these
tasks when concluding the rekeying we initiated.
2016-06-17 18:48:06 +02:00
Tobias Brunner
1b989dd4c5
ike-rekey: Properly handle situation if the peer did not notice the rekey collision
...
We conclude the rekeying before deleting the IKE_SA. Waiting for the
potential TEMPORARY_FAILURE notify is no good because if that response
does not reach us the peer will not retransmit it upon our retransmits
of the rekey request if it already deleted the IKE_SA after receiving
our response to the delete.
2016-06-17 18:48:06 +02:00
Tobias Brunner
6270bbde6a
ike-delete: Handle deletes while rekeying differently if there was a collision
...
We treat these as if we concluded the rekeying, the active ike-rekey task
will handle the collision afterwards.
2016-06-17 18:48:06 +02:00
Tobias Brunner
13da616118
ike-rekey: Add method to check if there was a rekey collision
2016-06-17 18:48:06 +02:00
Tobias Brunner
1cca20705a
ikev2: Check for collisions after handling IKE deletion
2016-06-17 18:48:06 +02:00
Tobias Brunner
0a2cad40a6
unit-tests: Add tests for IKE/CHILD delete collisions
2016-06-17 18:48:06 +02:00
Tobias Brunner
144bebe4b2
child-delete: Reply as usual when concurrently rekeying the IKE_SA
...
As per RFC 7296, 2.25.2 (what we did before was the behavior described
in RFC 4718).
2016-06-17 18:48:06 +02:00
Tobias Brunner
7b3eccfff4
unit-tests: Add tests for IKE/CHILD rekey collisions
2016-06-17 18:48:05 +02:00
Tobias Brunner
869b7075fc
child-create: Respond with TEMPORARY_FAILURE while rekeying/deleting IKE_SA
2016-06-17 18:48:05 +02:00
Tobias Brunner
83191e56b2
ike-rekey: Respond with TEMPORARY_FAILURE if CHILD_SAs are currently rekeyed/deleted/established
2016-06-17 18:48:05 +02:00
Tobias Brunner
7015994a94
unit-tests: Add tests for collisions between IKE_SA rekeying and deletion
2016-06-17 18:48:05 +02:00
Tobias Brunner
8a78e41f29
ike-rekey: Handle TEMPORARY_FAILURE notify
2016-06-17 18:48:05 +02:00
Tobias Brunner
c0976a5e01
ike-rekey: Respond with TEMPORARY_FAILURE if we are deleting the SA
2016-06-17 18:48:05 +02:00
Tobias Brunner
72c295df5b
unit-tests: Add tests for IKE SA deletion
2016-06-17 18:48:05 +02:00
Tobias Brunner
78e8152d01
ike-delete: No need to wait for a response in case of concurrent deletes
...
RFC 7296 explicitly says we SHOULD reply as usual and forget about our
own close request.
2016-06-17 18:48:05 +02:00
Tobias Brunner
40d9a4c892
unit-tests: Only deliver messages to the SA they are addressed to
2016-06-17 18:48:05 +02:00
Tobias Brunner
498a46d22f
unit-tests: Add test for simple IKE rekey collision
2016-06-17 18:48:05 +02:00
Tobias Brunner
bb3899739d
ikev2: Add a new state to track rekeyed IKE_SAs
...
This makes handling such IKE_SAs more specifically compared to keeping them
in state IKE_CONNECTING or IKE_ESTABLISHED (which we did when we lost a
collision - even triggering the ike_updown event), or using IKE_REKEYING for
them, which would also be ambiguous.
For instance, we can now reject anything but DELETES for such SAs.
2016-06-17 18:48:05 +02:00
Tobias Brunner
d6ac7496e6
ike-rekey: Add the name/ID of the redundant IKE_SAs to the log messages
2016-06-17 18:48:04 +02:00
Tobias Brunner
b5695bbffc
unit-tests: Add tests for IKE_SA rekeying
2016-06-17 18:48:04 +02:00
Tobias Brunner
d7b3ee6cca
unit-tests: Add asserts against IKE_SAs
2016-06-17 18:48:04 +02:00
Tobias Brunner
735bd4ca14
unit-tests: Make sure to flush the IKE_SA manager before destroying the sender
...
As the static plugin that creates and destroys the default sender was
not initialized because of the missing socket the daemon won't destroy
our sender. Test cases will eventually have to flush the IKE_SA manager to
satisfy the leak detective. However, in case of a test failure and if there
are IKE_SAs in the manager the daemon will flush the SAs when deinitializing,
which will cause deletes to get sent. This crashes if the sender is already
destroyed.
2016-06-17 18:48:04 +02:00
Tobias Brunner
b76c1decd4
unit-tests: Return status from process_message()
2016-06-17 18:48:04 +02:00
Tobias Brunner
7c6e0c2979
unit-tests: Use wrapper for add_listener in bus_t related asserts
2016-06-17 18:48:04 +02:00
Tobias Brunner
5d10ef316d
unit-tests: Provide a wrapper around bus_t::add_listener and unregister them during cleanup
...
In case listeners on the stack are triggered while cleaning up after a
test failed (e.g. via ike_sa_manager_t::flush) remaining listeners defined on
the stack would cause a segmentation fault.
2016-06-17 18:48:04 +02:00
Tobias Brunner
b7fac1d96e
ike-sa-manager: Make sure rng is defined before destroying it in flush()
...
This allows calling flush() multiple times.
2016-06-17 18:48:04 +02:00
Tobias Brunner
851ee4eeb7
ike-rekey: Establish new IKE_SA earlier as responder, but only if no collision
...
Moving to the new SA only after receiving the DELETE for the old SA was
not ideal as it rendered the new SA unusable (because it simply didn't
exist in the manager) if the DELETE was delayed/got dropped.
2016-06-17 18:48:04 +02:00
Tobias Brunner
b6a3c444e4
unit-tests: Add tests where a peer is not aware of a CHILD_SA rekey collision
2016-06-17 18:48:04 +02:00
Tobias Brunner
7a23226c32
child-delete: Check if the deleted CHILD_SA is the redundant SA of a collision
...
This happens if the peer deletes the redundant SA before we are able to
handle the response. The deleted SA will be in state CHILD_INSTALLED but
we don't want to trigger the child_updown() event for it or recreate it.
2016-06-17 18:48:04 +02:00
Tobias Brunner
4f1012b3e1
child-rekey: Add method to check for the redundant SA created in a collision
2016-06-17 18:48:04 +02:00
Tobias Brunner
f97bac5594
unit-tests: Test for rekeying if INVALID_KE_PAYLOAD notifies are received
2016-06-17 18:48:03 +02:00
Tobias Brunner
5ef033c53b
child-rekey: Don't change state to INSTALLED if it was already REKEYING
...
This happens if there is a rekey collision and the peers disagree on the
DH group.
2016-06-17 18:48:03 +02:00
Tobias Brunner
557e262f04
unit-tests: Make IKE and ESP proposals configurable
2016-06-17 18:48:03 +02:00
Tobias Brunner
42af3b4cce
unit-tests: Add tests for CHILD_SA rekeying/deletion collisions
2016-06-17 18:48:03 +02:00
Tobias Brunner
62a2567b06
unit-tests: Add asserts against job scheduling
2016-06-17 18:48:03 +02:00
Tobias Brunner
cdbf942889
ikev2: Use CHILD_REKEYED for replaced CHILD_SAs after rekeying
...
This allows handling collisions better, in particular with deletions.
2016-06-17 18:48:03 +02:00
Tobias Brunner
b79beba518
unit-tests: Add asserts against task queues of IKE_SAs
2016-06-17 18:48:03 +02:00
Tobias Brunner
5bbb9d703c
child-rekey: Use more appropriate error notifies if CHILD_SA is not found or getting deleted
...
These are the notifies we should return according to RFC 7296.
2016-06-17 18:48:02 +02:00
Tobias Brunner
334b0bc84a
child-rekey: Recreate the CHILD_SA if we receive a CHILD_SA_NOT_FOUND notify
2016-06-17 18:48:02 +02:00
Tobias Brunner
b7b414463d
child-create: Handle TEMPORARY_FAILURE notify as failure
...
We will later add code to retry creating the CHILD_SA if we are not
rekeying. Rekeying is already rescheduled as with any other errors.
2016-06-17 18:48:02 +02:00
Tobias Brunner
fa098aa97c
unit-tests: Add unit tests for basic CHILD_SA rekeying
2016-06-17 18:48:02 +02:00
Tobias Brunner
14588d99a4
unit-tests: Add asserts against ike|child_rekey hooks
2016-06-17 18:48:02 +02:00
Tobias Brunner
5d7f03dcaa
unit-tests: Match in and outbound SPIs in SA asserts
...
Since we use unique sequential SPIs that should be OK.
2016-06-17 18:48:02 +02:00
Tobias Brunner
dda5aab0f4
unit-tests: Register nonce generator and make first nonce byte configurable
2016-06-17 18:48:02 +02:00