Commit Graph

3783 Commits

Author SHA1 Message Date
Tobias Brunner 6f74b8748a counters: Move IKE event counter collection from stroke to a separate plugin 2017-11-08 16:28:28 +01:00
Tobias Brunner c81b87ac26 systime-fix: Add timeout option to stop waiting for valid system time
A certificate check is forced once the timeout is reached even if the
system time appears to be invalid.
2017-11-08 16:20:35 +01:00
Tobias Brunner 6ebf852c3f shunt-mananger: Make outbound FWD shunt policies optional 2017-11-02 10:47:53 +01:00
Thomas Egerer 2dad293647 ike: Do not send initial contact only for UNIQUE_NEVER
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2017-11-02 10:17:24 +01:00
Tobias Brunner 2d244f178f vici: Make setting mark on inbound SA configurable 2017-11-02 09:59:38 +01:00
Tobias Brunner ea43f8ffe5 child-cfg: Optionally set mark on inbound SA 2017-11-02 09:59:38 +01:00
Tobias Brunner 655924074b eap-radius: Optionally send Class attributes in RADIUS accounting messages
If enabled, add the RADIUS Class attributes received in Access-Accept messages
to RADIUS accounting messages as suggested by RFC 2865 section 5.25.

Fixes #2451.
2017-11-02 09:57:05 +01:00
Tobias Brunner 26bda4e904 ikev2: Abort make-before-break reauth if we don't find children to recreate
We do something similar in reestablish() for break-before-make reauth.
If we don't abort we'd be sending an IKE_AUTH without any TS payloads.

References #2430.
2017-11-02 09:48:56 +01:00
Andreas Steffen 7f86b0f639 libcharon: Added Cisco FlexVPN Supported VID 2017-10-27 20:14:57 +02:00
Tobias Brunner e1803a208a kernel-netlink: Add strings for newer XFRM attribute types 2017-10-06 16:41:09 +02:00
Tobias Brunner 039b85dd43 kernel-pfroute: Delay call to if_indextoname(3) when handling RTM_IFINFO
It seems that there is a race, at least in 10.13, that lets
if_indextoname() fail for the new TUN device. So we delay the call a bit,
which seems to "fix" the issue. It's strange anyway that the previous
delay was only applied when an iface entry was already found.
2017-09-26 09:33:46 +02:00
Tobias Brunner ab7d5e32d3 controller: Consider any IKE_SA destruction as success when terminating 2017-09-25 18:40:55 +02:00
Tobias Brunner e433d512f4 dhcp: Fix warning regarding unaligned pointer value due to packed struct
We don't need to access this as uint32_t so just cast it to a char*.
2017-09-18 12:16:54 +02:00
Tobias Brunner 787cc3a4e5 dhcp: Don't use signed char for DHCP options
The value of DHCP_OPTEND is 255.  When it is assigned this result in a
sign change as the positive int constant is cast to a signed char and -1
results. Clang 4.0 complains about this.
2017-09-18 12:16:54 +02:00
Tobias Brunner e7276f78aa child-create: Don't consider a DH group mismatch as failure as responder
This causes problems e.g. on Android where we handle the alert (and
reestablish the IKE_SA) even though it usually is no problem if the
peer retries with the requested group.  We don't consider it as a
failure on the initiator either.
2017-09-18 10:51:39 +02:00
Tobias Brunner da479ae2c9 child-delete: Only let SAs expire naturally if they not already did 2017-09-15 12:16:45 +02:00
Tobias Brunner c353996191 ike: Reset local SPI if retrying to connect in state IKE_CONNECTING
In case we send retransmits for an IKE_SA_INIT where we propose a DH
group the responder will reject we might later receive delayed responses
that either contain INVALID_KE_PAYLOAD notifies with the group we already
use or, if we retransmitted an IKE_SA_INIT with the requested group but
then had to restart again, a KE payload with a group different from the
one we proposed.  So far we didn't change the initiator SPI when
restarting the connection, i.e. these delayed responses were processed
and might have caused fatal errors due to a failed DH negotiation or
because of the internal retry counter in the ike-init task.  Changing
the initiator SPI avoids that as we won't process the delayed responses
anymore that caused this confusion.
2017-09-04 11:16:00 +02:00
Tobias Brunner eaedcf8c00 ike-sa-manager: Add method to change the initiator SPI of an IKE_SA 2017-09-04 11:16:00 +02:00
Tobias Brunner bd371590ab ike-init: Fail if DH group in KE payload does not match proposed group 2017-09-04 11:02:55 +02:00
Tobias Brunner 66805c7b32 ike-cfg: Fix memory leak when checking for configured address 2017-08-29 16:25:42 +02:00
Tobias Brunner 062a34e722 kernel-netlink: Set usable state whenever an interface appears
If an interface is renamed we already have an entry (based on the
ifindex) allocated but previously only set the usable state once
based on the original name.

Fixes #2403.
2017-08-23 12:10:39 +02:00
Tobias Brunner ca280574ba Fixed some typos, courtesy of codespell 2017-08-07 17:22:01 +02:00
Tobias Brunner 6fadc6a859 kernel-netlink: Wipe buffer used to read Netlink messages
When querying SAs the keys will end up in this buffer (the allocated
messages that are returned are already wiped). The kernel also returns
XFRM_MSG_NEWSA as response to XFRM_MSG_ALLOCSPI but we can't distinguish
this here as we only see the response.

References #2388.
2017-08-07 16:55:40 +02:00
Eyal Birger 32e5c49234 child-sa: Allow requesting different unique marks for in/out
When requiring unique flags for CHILD_SAs, allow the configuration to
request different marks for each direction by using the %unique-dir keyword.

This is useful when different marks are desired for each direction but the
number of peers is not predefined.

An example use case is when implementing a site-to-site route-based VPN
without VTI devices.

A use of 0.0.0.0/0 - 0.0.0.0/0 traffic selectors with identical in/out marks
results in outbound traffic being wrongfully matched against the 'fwd'
policy - for which the underlay 'template' does not match - and dropped.

Using different marks for each direction avoids this issue as the 'fwd' policy
uses the 'in' mark will not match outbound traffic.

Closes strongswan/strongswan#78.
2017-08-07 14:22:27 +02:00
Tobias Brunner 1a8226429a trap-manager: Don't require that remote is resolvable during installation
Initiation might later fail, of course, but we don't really
require an IP address when installing, that is, unless the remote
traffic selector is dynamic. As that would result in installing a
0.0.0.0/0 remote TS which is not ideal when a single IP is expected as
remote.
2017-08-07 14:22:13 +02:00
Tobias Brunner 7bcd48d1b1 child-create: Don't log CHILD_SA initiation until we know the unique ID 2017-08-07 14:22:13 +02:00
Tobias Brunner 663b749c9f child-rekey: Add CHILD_SA name and unique ID to collision log messages 2017-08-07 14:22:13 +02:00
Tobias Brunner 859dae255c child-sa: Suppress CHILD_SA state changes if there is no change 2017-08-07 14:22:13 +02:00
Tobias Brunner 15e745cf4d child-rekey: Don't install outbound SA in case of lost collisions
This splits the SA installation also on the initiator, so we can avoid
installing the outbound SA if we lost a rekey collision, which might
have caused traffic loss depending on the timing of the DELETEs that are
sent in both directions.
2017-08-07 10:46:00 +02:00
Tobias Brunner f9fbcbb1a0 bus: Don't trigger child_updown() for rekeyed CHILD_SAs
We don't trigger it either when they are deleted individually.
2017-08-07 10:44:05 +02:00
Tobias Brunner a146b4c9ef child-sa: Install outbound SA immediately if kernel supports SPIs on policies 2017-08-07 10:44:05 +02:00
Tobias Brunner 2c116ef589 child-sa: Use flags to track installation of outbound SA and policies separately 2017-08-07 10:44:05 +02:00
Tobias Brunner 2699c8387a kernel-netlink: Set SPI on outbound policy
This should cause the right SA to get used if there are multiple outbound
SAs and the policies are installed properly.
2017-08-07 10:44:05 +02:00
Tobias Brunner a46d233c0e kernel-interface: Not all kernel interfaces support SPIs on policies 2017-08-07 10:44:05 +02:00
Tobias Brunner 67ad553a2c unit-tests: Stringify direction in message asserts early
x86_64-w64-mingw32-gcc on Windows requires this.
2017-07-28 11:18:59 +02:00
Tobias Brunner 8d4ebb3ac4 peer-cfg: Use an rwlock instead of a mutex to safely access child-cfgs
If multiple threads want to enumerate child-cfgs and potentially lock
other locks (e.g. check out IKE_SAs) while doing so a deadlock could
be caused (as was the case with VICI configs with start_action=start).
It should also improve performance for roadwarrior connections and lots
of clients connecting concurrently.

Fixes #2374.
2017-07-27 13:34:40 +02:00
Tobias Brunner 791cfe82a1 ikev2: AES-CMAC-PRF-128 only uses the first 64 bits of each nonce
References #2377.
2017-07-27 13:09:26 +02:00
Tobias Brunner ed926a73df error-notify: Don't stop sending notifies after removing a disconnected listener
This prevented new listeners from receiving notifies if they joined
after another listener disconnected previously, and if they themselves
disconnected their old connection would prevent them again from getting
notifies.
2017-07-27 13:07:24 +02:00
Tobias Brunner 6138b8d629 farp: Only remove one tracked entry
Multiple CHILD_SAs sharing the same traffic selectors (e.g. during
make-before-break reauthentication) also have the same reqid assigned.
If all matching entries are removed we could end up without entry even
though an SA exists that still uses these traffic selectors.

Fixes #2373.
2017-07-27 13:07:23 +02:00
Tobias Brunner a0cde76958 ike: Trigger CHILD_INSTALLED state change after corresponding log message
This way we get the log message in stroke and swanctl as last message
when establishing a connection. It's already like this for the IKE_SA
where IKE_ESTABLISHED is set after the corresponding log message.

Fixes #2364.
2017-07-27 13:07:23 +02:00
Tobias Brunner fd0a7b4795 kernel-pfroute: Make sure there is a netmask when enumerating subnets 2017-07-05 10:21:25 +02:00
Tobias Brunner 7aa30575d5 sql: Use qualified names in SQL query statements
VIRTUAL is a new reserved keyword in MySQL 5.7.6 that caused some of these
queries to fail.

Fixes #2359.
2017-07-05 10:13:39 +02:00
Tobias Brunner a3bcbb4c64 stroke: Don't load configs with invalid proposals
References #2347.
2017-07-05 10:08:36 +02:00
Tobias Brunner 5d580ae063 ikev1: Determine transform ID before mapping integrity algorithm ID
Due to the lookup based on the mapped algorithm ID the resulting AH
proposals were invalid.

Fixes #2347.

Fixes: 8456d6f5a8 ("ikev1: Don't require AH mapping for integrity algorithm when generating proposal")
2017-07-05 10:08:20 +02:00
Tobias Brunner 1aba82bfd7 eap-aka-3gpp: Add plugin that implements 3GPP MILENAGE algorithm in software
This is similar to the eap-aka-3gpp2 plugin. K (optionally concatenated
with OPc) may be configured as binary EAP secret in ipsec.secrets or
swanctl.conf.

Based on a patch by Thomas Strangert.

Fixes #2326.
2017-07-05 10:03:38 +02:00
Tobias Brunner 083208e805 ikev1: Only delete redundant CHILD_SAs if configured
If we find a redundant CHILD_SA (the peer probably rekeyed the SA before
us) we might not want to delete the old SA because the peer might still
use it (same applies to old CHILD_SAs after rekeyings).  So only delete
them if configured to do so.

Fixes #2358.
2017-06-26 10:33:16 +02:00
Tobias Brunner a09e79ed5d ike-cfg: Fix memory leak when matching against ranges
traffic_selector_t::to_subnet() always sets the net/host (unless the
address family was invalid).

Fixes: 3070697f9f ("ike: support multiple addresses, ranges and subnets in IKE address config")
2017-05-29 10:50:58 +02:00
Tobias Brunner 00d547119e ike: Apply retransmission_limit before applying the jitter 2017-05-26 18:16:40 +02:00
Tobias Brunner 8ed3168406 eap-sim-file: Remove redundant enumerator allocation 2017-05-26 16:42:59 +02:00
Tobias Brunner bb494cde03 sql: Remove redundant enumerator allocation
Interestingly, this doesn't show up in the regression tests because the
compiler removes the first assignment (and thus the allocation) due to
-O2 that's included in our default CFLAGS.
2017-05-26 16:39:33 +02:00