Commit Graph
2377 Commits
Author SHA1 Message Date
Martin Willi 4730c4b32b unit-tests: implement tests for array collection 2013-07-17 17:20:17 +02:00
Martin Willi 2621ff4d40 array: introduce an array collection storing elements very efficiently
Currently we use the very versatile linked-list collection to store elements
with variable count. This is fine, but very inefficient: Due to the many
methods in the linked list, on 64-bit platforms an empty list alone is more
than 200 bytes. As we currently have about 50 lists per IKE_SA/CHILD_SA pair,
this takes up to 10KB just for managing the empty lists. This is about the
half of memory used by an IKE_SA/CHILD_SA pair, and obviously way too much.

The new array type is not an object, but a collection of functions on an
abstract type.

The following lists are per IKE_SA and should be considered for a replacement
with more efficient arrays (this uses load-testers on-demand created dynamic
configurations, other scenarios have different lists):

14 -> ike_sa_create() @ src/libcharon/sa/ike_sa.c:2198
10 -> auth_cfg_create() @ src/libstrongswan/credentials/auth_cfg.c:1088
 6 -> task_manager_v2_create() @ src/libcharon/sa/ikev2/task_manager_v2.c:1505
 6 -> proposal_create() @ src/libcharon/config/proposal.c:592
 5 -> peer_cfg_create() @ src/libcharon/config/peer_cfg.c:657
 4 -> child_sa_create() @ src/libcharon/sa/child_sa.c:1090
 2 -> child_cfg_create() @ src/libcharon/config/child_cfg.c:536
 1 -> ike_cfg_create() @ src/libcharon/config/ike_cfg.c:330
 1 -> put_connected_peers() @ src/libcharon/sa/ike_sa_manager.c:854
2013-07-17 17:20:17 +02:00
Tobias Brunner e0b868f79e pkcs12: Add plugin dependencies with soft dependencies on the most common algorithms 2013-07-15 10:48:19 +02:00
Martin Willi 1e54e40f5d leak-detective: remove hdr entry when reallocating zero bytes 2013-07-12 20:00:16 +02:00
Martin Willi c93cf85356 leak-detective: print total of allocated/leaked bytes in usage/report 2013-07-12 20:00:14 +02:00
Andreas Steffen 126778679f Recognize critical IssuingDistributionPoint CRL extension 2013-07-12 09:00:47 +02:00
Martin Willi 81959e6406 leak-detective: add a usage threshold option based on the number of allocations 2013-07-10 17:28:45 +02:00
Martin Willi 82d0317be6 leak-detective: set_state() only affects the calling thread
The only user (bfd backtraces) is fine with that, and we really should not
mess the enable flag while doing allocations with other threads.
2013-07-10 17:28:32 +02:00
Martin Willi f960b39061 leak-detective: take a copy of backtrace while printing traces
As we don't want to hold the lock, we must make sure backtraces keep valid
while printing them.
2013-07-10 17:28:24 +02:00
Martin Willi d9c459e855 backtrace: add a clone() method 2013-07-10 17:28:18 +02:00
Martin Willi 3b26f04cf4 leak-detective: remove hdr from the allocation list during realloc()
If realloc moves an allocation, the original allocation gets freed. We
therefore must remove the hdr from the list, as it is invalid. We can add it
afterwards once it has been updated, allowing us to unlock the list during
reallocation.
2013-07-10 16:37:08 +02:00
Tobias Brunner d27f225d9a Use strpfx() helper where appropriate 2013-07-08 18:49:30 +02:00
Tobias Brunner f460facdca utils: Add helper function to check a string for a given prefix 2013-07-08 18:49:30 +02:00
Tobias Brunner 985dcab1c2 utils: Convert string helper macros to static inline functions 2013-07-08 18:49:29 +02:00
Martin Willi 324b90cc46 openssl: RAND_pseudo_bytes() returns 0 if bytes are not cryptographically strong
For our purposes with RNG_WEAK this is fine, so accept a zero return value.
2013-07-04 11:09:54 +02:00
Tobias Brunner b1b0cce396 processor: Simplified the main loop 2013-06-28 17:02:06 +02:00
Tobias Brunner 6ca25ccc04 processor: Don't hold the lock while destroying jobs
If a lock is held when queue_job() is called and the same lock is
required during the destruction of a job, holding the internal lock
in the processor while calling destroy() could result in a deadlock.
2013-06-28 17:02:05 +02:00
Tobias Brunner f95205f580 integrity-checker: Use chunk_hash_static() to calculate checksums 2013-06-28 17:00:29 +02:00
Tobias Brunner ed235dbbf2 chunk: Add predictable hash function
Since chunk_hash() is randomized its output is not predictable, that is,
it is only within the same process.
2013-06-28 17:00:29 +02:00
Tobias Brunner b18a531715 plugin-loader: Removed unused path argument of load() method
Multiple additional search paths can be added with the add_path()
method.
2013-06-28 10:44:15 +02:00
Tobias Brunner 75ff252324 integrity-checker: Fix checksum calculation after randomizing chunk_hash() 2013-06-27 15:34:08 +02:00
Tobias Brunner fcc33c0cd4 unit-tests: Print loaded plugins 2013-06-27 11:27:13 +02:00
Tobias Brunner a6357a62b4 unit-tests: RSA key generation might take longer than 4 seconds
Check uses a default timeout of 4 seconds for each test case, generating
keys of 6 different key sizes might take longer than that.
2013-06-27 11:06:47 +02:00
Tobias Brunner 65d23c7c90 tests: Properly load plugins from build directory
Calling load() incrementally does not really work as dependencies
wouldn't be resolved properly if a required feature was to be provided
by a plugin that is loaded later with a separate call to load().
2013-06-27 11:06:47 +02:00
Tobias Brunner f2086e42ff plugin-loader: Method added to provide additional search paths for plugins 2013-06-27 10:27:24 +02:00
Tobias Brunner ac2ffde4ae capabilities: Return effective UID/GID if user did not configure anything 2013-06-25 17:16:33 +02:00
Tobias Brunner 5e80e387bd capabilities: Report effective UID/GID after dropping capabilities 2013-06-25 17:16:33 +02:00
Tobias Brunner 1937538440 capabilities: Handle CAP_CHOWN specially as it might not be required 2013-06-25 17:16:33 +02:00
Tobias Brunner 9c354c659f capabilities: Check effective UID as fallback if capabilities are not supported 2013-06-25 17:16:33 +02:00
Tobias Brunner 6f15f5e632 dhcp: Require CAP_NET_BIND_SERVICE and CAP_NET_RAW to open/bind sockets 2013-06-25 17:16:32 +02:00
Tobias Brunner 1dd61bf13d socket-default: Require CAP_NET_BIND_SERVICE for ports < 1024
Since we don't know which ports are used with socket-dynamic we can't
demand the capability there, but it might still be required.
2013-06-25 17:16:32 +02:00
Tobias Brunner 41b8546ac0 capabilities: Only plugins that require CAP_NET_ADMIN demand it
The daemon as such does not require this capability.
2013-06-25 17:16:32 +02:00
Tobias Brunner a2eb581781 capabilities: Move global capabilities_t instance to libstrongswan 2013-06-25 17:16:32 +02:00
Tobias Brunner 2e21bac19a capabilities: Ensure required capabilities are actually held by the process/user 2013-06-25 17:16:32 +02:00
Tobias Brunner 66aaabf342 tun-device: Packets sent over utun devices on Mac OS X have the protocol family prepended 2013-06-21 17:03:21 +02:00
Tobias Brunner c8a56512a6 tun-device: Avoid opening /dev/tunX multiple times (e.g. on FreeBSD) 2013-06-21 17:03:21 +02:00
Tobias Brunner 0d2ad63fe2 printf-hook: Avoid double-free when freeing Vstr config
Thread-specific objects get freed when the thread value object is
destroyed (wasn't the case earlier, i.e. before 2b19dd35), which
may cause the second call to vstr_free_conf() to fail in an assert
in Vstr (depending on how it was built).
2013-06-21 17:03:20 +02:00
Tobias Brunner 0d25c4ef87 plugin-loader: Move logging of failed features to status()
Still log an error message if critical features fail, as loaded
plugins/features are not logged in that case.

This way loaded plugins are printed before failed features and
the relation is easier to make for users.  It also allows programs
to log this message on a different level.
2013-06-21 15:22:46 +02:00
Tobias Brunner 607f8e9906 plugin-loader: Add method to print loaded plugins on a given log level 2013-06-21 15:17:53 +02:00
Tobias Brunner 34ee14dd28 plugin-loader: Collect statistics while loading features, print them in case features failed to load
There is no need to explicitly search for failed features in critical
plugins as this is now detected while loading the features.
2013-06-21 15:13:25 +02:00
Tobias Brunner 681e53c70c plugin-loader: Use different log level if failed feature is in critical plugin 2013-06-21 15:13:25 +02:00
Tobias Brunner 13d2d8f634 plugin-loader: Log message when failing to load plugin 2013-06-21 15:13:25 +02:00
Tobias Brunner 51b9d7513d plugin-loader: Reduce verbosity while loading plugins 2013-06-21 15:13:25 +02:00
Martin Willi 092550b03a leak-detective: (re-)whitelist some OpenSSL functions
Some static allocations in plugins won't get freed, because in the test case
process the plugins are not destroyed. If a plugin would clean up allocations
done while just using the plugin, these show up as leak in the child process,
letting tests fail.
2013-06-21 10:53:23 +02:00
Martin Willi ef687db734 unit-tests: load plugins in test-runner from build directory 2013-06-21 10:53:23 +02:00
Martin Willi b950fc48da unit-tests: link test-runner against -lpthread 2013-06-21 10:53:23 +02:00
Martin Willi df1a1a0901 unit-tests: add RSA test cases, very similar to ECDSA 2013-06-21 10:53:23 +02:00
Martin Willi eabf4af0f8 unit-tests: test with /dev/urandom if random plugin is in use 2013-06-21 10:53:22 +02:00
Martin Willi d0c09c84a5 unit-tests: test supported ECDSA schemes only 2013-06-21 10:53:22 +02:00
Martin Willi 2bedb0f270 Move test-runners has_feature() function to plugin loader 2013-06-21 10:53:22 +02:00