13417 Commits

Author SHA1 Message Date
Tobias Brunner
2d38a03d77 ikev1: Make sure proposed IPsec mode matches our own
References #557.
2014-09-09 10:56:16 +02:00
Tobias Brunner
34e402ef8d ike: Reset IKE_SA in state CONNECTING instead of reauthenticating
Due to how reauthentication works for IKEv1 we could get a second
IKE_SA, which might cause problems, when connectivity problems arise
when the connection is initially established.

Fixes #670.
2014-09-09 10:56:15 +02:00
Tobias Brunner
4df9250f26 asn1: Make sure not to exceed buffer for binary OID 2014-09-09 10:56:15 +02:00
Tobias Brunner
f80093e2ee kernel-pfroute: Delete interfaces on RTM_IFANNOUNCE/IFAN_DEPARTURE events
We actually never deleted cached interfaces.  So if the kernel reuses
interface indices events for newly created interfaces could have been
associated with interface objects of deactivated and deleted interfaces.

Since we also didn't update the interface name when such an interface
got reactivated we ended up using the old name e.g. to install routes.

A trigger for this was the deletion and recreation of TUN devices during
reauthentication of SAs that use virtual IPs.
2014-09-09 10:56:15 +02:00
Tobias Brunner
f8613abc8a ip-packet: Define our own structs to handle TCP/UDP headers 2014-09-09 10:56:15 +02:00
Tobias Brunner
25fcbab678 kernel-pfkey: Report packet counts of IPsec SAs
Seems that packet counts can be retrieved after all. At least the Linux
and FreeBSD kernels treat the number of allocations as number of packets.
We actually installed packet limits in that field already.
2014-09-09 10:56:15 +02:00
Tobias Brunner
8a59fa6467 swanctl: Document how connections.*.unique affects initiators 2014-09-09 10:56:15 +02:00
Tobias Brunner
dbd7f4be31 mutex: Use atomics to set current thread in recursive mutex
Because this->thread is also read by threads that don't hold the
mutex the previous implementation was problematic (especially since
pthread_t is an opaque type of unknown length).

Fixes #654.
2014-09-09 10:56:15 +02:00
Tobias Brunner
7e433456fc curl: Log error code too
It seems libcurl does not always return an error message.
2014-09-09 10:56:14 +02:00
Tobias Brunner
4f71ee2cf6 unit-tests: Add option to exclude specific test suites
Listing test suites in TESTS_SUITES_EXCLUDE allows excluding specific
test suites from running.
2014-09-09 10:56:14 +02:00
Tobias Brunner
5818467639 openssl: Report correct key length for EC keys when not using NIST curves
Fixes #688.
2014-09-02 08:15:17 +02:00
Thomas Egerer
8d80528a60 credmgr: Fix copy and paste error in add_validator
This won't hurt as long as sets and validators are of the same class.
But as soon as one of the object's class is changed this will cause
either a compile error (best option), or result (most likely) in a
crash.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2014-08-29 13:22:23 +02:00
Andreas Steffen
51da5b920b Generated new test certificates 2014-08-28 21:34:40 +02:00
Martin Willi
e1c7e1bc1f ha: Don't adopt IKEv1 children when building without IKEv1 support
The adopt_children_job_create() function is not available when IKEv1 support
is disabled. Fixes uncommon builds using --enable-ha --disable-ikev1.

Fixes #690.
2014-08-28 10:19:57 +02:00
Tobias Brunner
6095714e64 testing: Make sure the kernel exists when starting 2014-08-25 10:58:46 +02:00
Martin Willi
cfdc620a3f unity: Do not bump TS to 0.0.0.0/0 as initiator when no Split-Include received
When having the unity plugin enabled and both peers send the Unity Vendor ID,
we proposed 0.0.0.0/0 as traffic selector, even if no Split-Include has been
received on the SA. This can break compatibility with some responders, as
they don't narrow the TS themselves, but expect the configured TS.
2014-08-25 10:02:44 +02:00
Tobias Brunner
a45ba880c8 unity: Handle narrowing according to roles in the IKE_SA
Since the narrow hook types reflect the roles in the Quick Mode exchange
the plugin behaved incorrectly if the server initiated the CHILD_SA
rekeying.
2014-08-25 09:59:43 +02:00
Martin Willi
cb98380fe9 Merge branch 'push-mode-reauth'
Fixes IKEv1 re-authentication when using push mode by reassigning the same
IP lease to the client.
2014-08-25 09:57:30 +02:00
Martin Willi
4f243dfaa9 ikev1: Defer Mode Config push after CHILD adoption when using XAuth 2014-08-25 09:55:44 +02:00
Martin Willi
891bbbd4bb ikev1: Defer Mode Config push after CHILD adoption and reauth detection
When an initiator starts reauthentication on a connection that uses push
mode to assign a virtual IP, we can't execute the Mode Config before releasing
the virtual IP. Otherwise we would request a new and different lease, which
the client probably can't handle. Defer Mode Config execution, so the same IP
gets first released then reassigned during reauthentication.
2014-08-25 09:55:44 +02:00
Martin Willi
898c8b12f9 ikev1: Extend adopt_children_job by task queuing, executed after adoption 2014-08-25 09:55:44 +02:00
Martin Willi
cd9bba508b ikev1: Accept Quick Mode DELETES while Quick Mode rekeying is active
If a peer immediately sends DELETE messages when completing Quick Mode rekeying,
the third Quick Mode message and the DELETE are sent simultaneously. This
implies that DELETE messages may arrive before the completing third Quick Mode
message.

Handle this case by ignoring the DELETE INFORMATIONAL in Quick Mode and let
the delete task handle it.
2014-08-25 09:53:02 +02:00
Martin Willi
11bf11c1f5 utils: Check if the parameter passed to countof() is actually an array type
This should avoid errors such as the one fixed with 118b2879.
2014-08-25 09:48:53 +02:00
Martin Willi
bb6be26197 utils: Add some initial build time assertion macros
These are useful to assert constants during build time. We evaluate the
expression to 0 when valid, so we can safely use the evaluated value.
2014-08-25 09:48:53 +02:00
Martin Willi
8986e2da47 starter: Do not close all file descriptors after fork()
As we use libstrongswan and expect that it still works after the fork, we
can't just closefrom() all file descriptors. Watcher, for example, uses
a pipe to notify FDSET changes, which must be kept open.

Reverts 652ddf5ce2fad08f6569096dd56a821500cc5ba4.
2014-08-25 09:47:46 +02:00
Christophe Gouault
c08b74c524 ike-sa-manager: Use transient hasher for IKE_SA_INIT hash calculation
To check if a received IKE_SA_INIT request is a new request or a
retransmit, charon maintains hashes of the pending IKE_SA_INIT
exchanges.

However, the hash calculation is not reentrant because a single hasher
is used for the whole IKE SA manager. It leads to bogus calculations
under high load and hence dropped messages on responder
(IkeInInvalidSpi incremented).

Don't share a single hasher in the IKE SA manager, create a transient
one whenever a message must be hashed.

Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
2014-08-25 09:45:14 +02:00
Martin Willi
46184b07c1 diffie-hellman: Explicitly initialize DH exponent sizes during initialization
To avoid any race conditions when multiple threads call and initialize
diffie_hellman_get_params(), explicitly examine the optimum DH exponent size
during library initialization.

Fixes #655.
2014-08-25 09:43:29 +02:00
Tobias Brunner
52ba4f6bf4 kernel-pfroute: Fix kernel response handling
The condvar is signaled for every handled message received from the
kernel not only for replies (this changed with 2a2d7a4dc8).  This may
cause segfaults because this->reply is not set when the waiting thread is
woken due to an IP address change.

Since this->reply is only set when it is actually the expected reply (and
only one request is sent at a time, thanks to c9a323c1d9) we only have
to make sure the reply is there (and clear it once we handled it).

Using separate condvars could also be an option in the future.
2014-08-19 14:03:00 +02:00
Tobias Brunner
b04f40406d configure: Add additional includes when checking for linux/fib_rules.h
This seems to be required on Cent OS 6.5.
2014-08-11 18:40:18 +02:00
Martin Willi
508f90131a starter: Wait indefinitely for charon when using --attach-gdb
This makes sure the user has time to set break points etc. before it runs
charon under gdb.
2014-08-08 16:36:00 +02:00
Thomas Egerer
f51c923f69 starter: Don't monitor child if debugger is attached
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2014-08-08 09:59:57 +02:00
Andreas Steffen
eafe8795ca Added Debian 7.6 to IMV database 2014-08-06 08:04:42 +02:00
Andreas Steffen
78ec8c6085 unused os_info_t object removed 2014-08-06 07:55:54 +02:00
Andreas Steffen
bc14124147 Updated build-database.sh to 3.13.0-32-generic Ubuntu kernel 2014-08-06 07:54:57 +02:00
Tobias Brunner
fafed376e7 imv-swid: Use pkg-config to check for libjson-c
The package/library is called libjson-c on recent distributions.
Some like Ubuntu 14.04 provide symlinks with the old name but these
will eventually disappear.  Using pkg-config allows us to easily check
for it (with a fallback) and configure the proper compiler flags.

Fixes #663.
2014-07-30 16:57:00 +02:00
Tobias Brunner
ffa9b67189 dns-proxy: Don't use proxy socket if we fail to bypass it
This will result in an infinite loop as packets sent over that socket
will again pass through the TUN device and the DNS proxy.

Apparently, bypassing fails when airplane mode is enabled.

Fixes #662.
2014-07-30 09:48:08 +02:00
Tobias Brunner
d236db8701 swanctl: Fix documentation of options for send_cert setting 2014-07-28 10:38:34 +02:00
Tobias Brunner
8d31df9099 android: New release after adding certificate import, DNS proxy and GUI changes 2014-07-22 11:34:09 +02:00
Tobias Brunner
1ddc1ec0b3 Merge branch 'android-dns-proxy'
Adds a DNS proxy feature that uses VPN-protected sockets to resolve the
VPN gateway's hostname while reestablishing the IKE_SA, which is
required because we keep the TUN device up to avoid leaking plaintext
traffic.

The TUN device is recreated without DNS servers before reestablishing in
case the VPN server pushed DNS servers to the client that are only
reachable via VPN.

Fixes #622.
2014-07-22 11:14:00 +02:00
Tobias Brunner
ffff7219ef android: For keyingtries > 0 notify the GUI if the limit is reached when reestablishing
The IKE_SA is destroyed anyway, so letting the GUI remain in
"connecting" state would be incorrect.

We still use keyingtries=0 for now, though. And we still abort after the
first failed attempt initially, in case there is a configuration error.
2014-07-22 11:10:36 +02:00
Tobias Brunner
5fd9e5fd00 android: Terminate IKE_SA if initial IKE_SA_INIT fails
Since VpnStateService.disconnect() is now not called until the error
dialog is dismissed the daemon would continue to try connecting.
So while the error dialog is shown the connection might actually be
successfully established in the background, which is not intended.

This way the IKE_SA is destroyed right after sending the IKE_SA_INIT of
the second connection attempt (due to keyingtries=0).
2014-07-22 11:10:36 +02:00
Tobias Brunner
945832c67d android: Only allow DNS queries for the configured hostname 2014-07-22 11:10:36 +02:00
Tobias Brunner
e77f226a0f android: Add optional filter functionality to DNS proxy
If specified only queries for a list of allowed host names will be
proxied.
2014-07-22 11:10:36 +02:00
Tobias Brunner
c66f5f844d android: Recreate the TUN device without DNS when reestablishing IKE_SAs
This enables DNS resolution while reestablishing if the VPN gateway pushed
DNS servers to the client that are only reachable via VPN.
2014-07-22 11:10:36 +02:00
Tobias Brunner
36aab70ab0 android: Add method to BuilderAdapter to re-establish without DNS-related data
Non-DNS data is cached in the BuilderAdapter so the TUN device can be
recreated easily (since the CHILD_SA is gone we couldn't actually gather
that information).
2014-07-22 11:10:36 +02:00
Tobias Brunner
cc1712a8f4 android: Use DNS proxy when reestablishing IKE_SAs 2014-07-22 11:10:36 +02:00
Tobias Brunner
614359a7d5 bus: Add ike_reestablish_pre hook, called before DNS resolution
The old hook is renamed to ike_reestablish_post and is now also called
when the initiation of the new IKE_SA failed.
2014-07-22 11:10:36 +02:00
Tobias Brunner
2dc26c557e android: Add DNS proxy implementation
This class proxies DNS requests over VPN-protected UDP sockets.
It is not really Android specific and might be useful for
kernel-libipsec or libipsec in general too, so we could maybe move it later
to libipsec (might need some portability work).
2014-07-22 11:10:36 +02:00
Tobias Brunner
16e519d42c ip_packet: Add function to easily encode UDP packets 2014-07-22 11:10:35 +02:00
Tobias Brunner
108a67893f ip_packet: Apply transport protocol ports when encoding IP packet 2014-07-22 11:10:35 +02:00