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
Tobias Brunner
c1289eb578
unit-tests: Add mock nonce generator
...
We don't make the full nonces configurable but only the first byte,
which should be enough to force a nonce to be smaller than others.
2016-06-17 18:48:02 +02:00
Tobias Brunner
fbb0b3cb0a
unit-tests: Make message asserts more flexible
2016-06-17 18:48:02 +02:00
Tobias Brunner
32cfe1e00c
unit-tests: Add another CHILD_SA delete collision
2016-06-17 18:48:02 +02:00
Tobias Brunner
7e5424868d
unit-tests: Register mock DH implementation as static plugin feature
2016-06-17 18:48:02 +02:00
Tobias Brunner
1f73a74be0
unit-tests: Add mock DH implementation that's basically a noop
...
If the openssl plugin is built DH isn't that much of an overhead as
ecp256 is used, but the default MODP group is now modp3072.
2016-06-17 18:48:01 +02:00
Tobias Brunner
29f1637b9a
unit-tests: Make IKE SPIs predictable
2016-06-17 18:48:01 +02:00
Tobias Brunner
5d97e5c30f
unit-tests: Call methods on IKE_SAs in their context
2016-06-17 18:48:01 +02:00
Tobias Brunner
33e2620b8c
unit-tests: Add a unit test for CHILD_SA DELETE collisions
2016-06-17 18:48:01 +02:00
Tobias Brunner
94012e3f42
child-delete: Remove unnecessary call to destroy_child_sa()
...
Generally, we will not find the CHILD_SA by searching for it with the
outbound SPI (the initiator of the DELETE sent its inbound SPI) - and if
we found a CHILD_SA it would most likely be the wrong one (one in which
we used the same inbound SPI as the peer used for the one it deletes).
And we don't actually want to destroy the CHILD_SA at this point as we
know we already initiated a DELETE ourselves, which means that task
still has a reference to it and will destroy the CHILD_SA when it
receives the response from the other peer.
2016-06-17 18:48:01 +02:00
Tobias Brunner
632ba2a21e
unit-tests: Add asserts against hooks on listener_t and messages captured there
2016-06-17 18:48:01 +02:00
Tobias Brunner
735b0cdd01
unit-tests: Add asserts against SAs (e.g. their states)
2016-06-17 18:48:01 +02:00
Tobias Brunner
d3c4d55391
unit-tests: Add separate test runner to test IKEv2 exchanges
...
This allows proper initialization of the daemon and the helper object.
2016-06-17 18:48:01 +02:00
Tobias Brunner
c7f5259cde
unit-tests: Add helper class/object to test IKE exchanges
2016-06-17 18:48:01 +02:00
Tobias Brunner
7a5dd544f6
unit-tests: Add mock kernel_ipsec_t implementation for unit tests
...
Provides predictable sequential SPIs.
2016-06-17 18:48:01 +02:00
Tobias Brunner
87539617f1
unit-tests: Add mock sender_t implementation for unit testing
...
This allows to retrieve packets sent by an IKE_SA and pass it to another
IKE_SA directly via process_message().
2016-06-17 18:48:01 +02:00
Tobias Brunner
3b50e6fc3e
unit-tests: Don't unload plugins before calling libcharon_deinit()
...
libcharon_deinit() already calls all the functions we called manually.
Unloading the plugins will not work if charon->initialize() is called
as charon's static plugin features would already be unloaded before the
destroyed members are accessed in destroy() to flush them.
2016-06-17 18:48:01 +02:00
Tobias Brunner
4082821964
kernel-netlink: Don't set replay window for outbound SAs
...
It's not necessary and might waste memory. However, if ESN is used we set
the window to 1 as the kernel rejects the attribute otherwise.
2016-06-17 18:46:33 +02:00
Tobias Brunner
21aa924233
kernel-pfkey: Only set the replay window for inbound SAs
...
It is not necessary for outbound SAs and might waste memory when large
window sizes are used.
2016-06-17 18:46:33 +02:00
Tobias Brunner
941ac92b95
daemon: Don't hold settings lock while executing start/stop scripts
...
If a called script interacts with the daemon or one of its plugins
another thread might have to acquire the write lock (e.g. to configure a
fallback or set a value). Holding the read lock prevents that, potentially
resulting in a deadlock.
2016-06-17 18:43:35 +02:00
Tobias Brunner
9e01d7ca32
quick-mode: Fix reporting lifebytes if lifetime is configured
2016-06-17 11:34:26 +02:00
Tobias Brunner
5947d48fb9
load-tester: Fix load-tester on platforms where plain char is signed
...
fgetc() returns an int and EOF is usually -1 so when this gets casted to
a char the result depends on whether `char` means `signed char` or
`unsigned char` (the C standard does not specify it). If it is unsigned
then its value is 0xff so the comparison with EOF will fail as that is an
implicit signed int.
2016-06-17 10:22:25 +02:00
Martin Willi
518a5b2ece
configure: Check for and explicitly link against -latomic
...
Some C libraries, such as uClibc, require an explicit link for some atomic
functions. Check for any libatomic, and explcily link it.
2016-06-14 14:27:20 +02:00
Tobias Brunner
b1f7d10800
resolve: Add refcounting for installed DNS servers
...
This fixes DNS server installation if make-before-break reauthentication
is used as there the new SA and DNS server is installed before it then
is removed again when the old IKE_SA is torn down.
2016-06-10 18:40:01 +02:00
Tobias Brunner
f1064ca59a
resolve: Use process abstraction when calling resolvconf
...
This allows us to capture output written to stderr/stdout.
2016-06-10 18:39:53 +02:00
Tobias Brunner
f4a20b74fd
resolve: Make sure to clean up if calling resolvconf failed
...
If running resolvconf fails handle() fails release() is not called, which
might leave an interface file on the system (or depending on which script
called by resolvconf actually failed even the installed DNS server).
2016-06-10 18:39:21 +02:00
Tobias Brunner
b52e540f43
kernel-pfroute: Return interface to reach destination from get_nexthop()
2016-06-10 17:52:26 +02:00
Tobias Brunner
b98afc0a37
kernel-pfkey: Install routes with OUT policies
2016-06-10 15:25:46 +02:00
Tobias Brunner
aea3c1052e
kernel-netlink: Install routes with OUT policies
...
This is the direction we actually need routes in and makes the code
easier to read.
2016-06-10 15:25:09 +02:00