Commit Graph

2213 Commits

Author SHA1 Message Date
Adi Nissim 8ced1570ab child-cfg: Make HW offload auto mode configurable
Until now the configuration available to user for HW offload were:
hw_offload = no
hw_offload = yes

With this commit users will be able to configure auto mode using:
hw_offload = auto

Signed-off-by: Adi Nissim <adin@mellanox.com>
Reviewed-by: Aviv Heller <avivh@mellanox.com>
2018-03-21 10:32:02 +01:00
Tobias Brunner ee26f7156f kernel-netlink: Cleanup and fix some HW offload code issues
Besides some style issues there were some incorrect allocations
for ethtool requests.
2018-03-21 10:29:57 +01:00
Adi Nissim 338cc5812e kernel-netlink: Add new automatic hw_offload mode
Until now there were 2 hw_offload modes: no/yes
* hw_offload = no  : Configure the SA without HW offload.
* hw_offload = yes : Configure the SA with HW offload.
                     In this case, if the device does not support
                     offloading, SA creation will fail.

This commit introduces a new mode: hw_offload = auto
----------------------------------------------------
If the device and kernel support HW offload, configure
the SA with HW offload, but do not fail SA creation otherwise.

Signed-off-by: Adi Nissim <adin@mellanox.com>
Reviewed-by: Aviv Heller <avivh@mellanox.com>
2018-03-21 10:28:44 +01:00
Tobias Brunner 70d99d67d6 vici: Make sure to read all requested data from socket in Perl binding
Closes strongswan/strongswan#91.
2018-03-21 10:10:35 +01:00
Tobias Brunner 0acd1ab4d0 stroke: Ensure a minimum message length 2018-03-19 18:06:00 +01:00
Tobias Brunner 53827a5fde load-tester: Start numbering IDs from 1 again
ref_get() increments the number before returning it.

Fixes: 2cbaa63295 ("load-tester: Fix race condition issuing same identity")
2018-03-07 15:41:56 +01:00
Tobias Brunner 0d06cbd66e unit-tests: Ignore binaries of renamed test runners
Fixes: 9cc61baaf5 ("unit-tests: Rename targets for libstrongswan and kernel-netlink")
2018-03-02 17:11:27 +01:00
Tobias Brunner 2f5d6be5a0 kernel-netlink: Ignore local routes in any table
Such routes seem to show up in tables other than local with recent kernels.

Fixes #2555.
2018-02-28 15:32:41 +01:00
Tobias Brunner 9189aec666 kernel-netlink: Ignore routes with next hop during local subnet enumeration
These are not locally attached and we do the same already in kernel-pfroute.

Fixes #2554.
2018-02-28 15:32:30 +01:00
Tobias Brunner d9400f44d8 kernel-netlink: Simplify rt_entry_t initialization 2018-02-28 15:32:25 +01:00
Tobias Brunner 24fa1bb02a trap-manager: Remove reqid parameter from install() and change return type
Reqids for the same traffic selectors are now stable so we don't have to
pass reqids of previously installed CHILD_SAs.  Likewise, we don't need
to know the reqid of the newly installed trap policy as we now uninstall
by name.
2018-02-22 11:31:05 +01:00
Tobias Brunner ca213e1907 trap-manager: Uninstall trap policies by name and not reqid
If a trap policy is concurrently uninstalled and reinstalled under a
different name the reqid will be the same so the wrong trap might be
removed.
2018-02-22 11:31:05 +01:00
Tobias Brunner 6f569263a0 vici: Remove external enumeration to uninstall shunt policies 2018-02-22 11:31:05 +01:00
Tobias Brunner 9d69d8a399 stroke: Remove external enumeration to unroute shunt policies 2018-02-22 11:31:05 +01:00
Tobias Brunner fb545dd34d vici: Also return close action 2018-02-16 09:55:22 +01:00
Tobias Brunner bac71410f3 save-keys: Add warning message to log if keys are being saved 2018-02-15 23:03:29 +01:00
Tobias Brunner 1da1ba01c4 save-keys: Add options to enable saving IKE and/or ESP keys 2018-02-15 23:03:29 +01:00
Codrut Cristian Grosu 88e151d10d save-keys: Store derived CHILD_SA keys in Wireshark format 2018-02-15 23:03:29 +01:00
Codrut Cristian Grosu 4be7db5f60 save-keys: Store derived IKE_SA keys in Wireshark format
The path has to be set first, otherwise, nothing is done.
2018-02-15 23:03:29 +01:00
Codrut Cristian Grosu 345cd4684c save-keys: Add save-keys plugin
This plugin will export IKE_SA and CHILD_SA secret keys in the format used
by Wireshark.

It has to be loaded explicitly.
2018-02-15 23:03:29 +01:00
Andreas Steffen 4eaf08c35b vici: list-conn reports DPD settings and swanctl displays them 2018-02-15 16:28:06 +01:00
Tobias Brunner ce048c30ff ha: Double receive buffer size for HA messages and make it configurable
With IKEv1 we transmit both public DH factors (used to derive the initial
IV) besides the shared secret.  So these messages could get significantly
larger than 1024 bytes, depending on the DH group (modp2048 just about
fits into it).  The new default of 2048 bytes should be fine up to modp4096
and for larger groups the buffer size may be increased (an error is
logged should this happen).
2018-02-14 14:52:18 +01:00
Tobias Brunner 2db6d5b8b3 Fixed some typos, courtesy of codespell 2018-02-13 12:19:54 +01:00
Tobias Brunner 4664992f7d kernel-netlink: Optionally trigger roam events on routing rule changes
This can be useful if routing rules (instead of e.g. route metrics) are used
to switch from one to another interface (i.e. from one to another
routing table).  Since we currently don't evaluate routing rules when
doing the route lookup this is only useful if the kernel-based route
lookup is used.

Resolves strongswan/strongswan#88.
2018-02-09 15:51:28 +01:00
Tobias Brunner a9f3016ef3 stroke: Don't ignore %any as owner of shared secrets
If users want to associate secrets with any identity, let 'em. This is
also possible with vici and might help if e.g. the remote identity is
actually %any as that would match a PSK with local IP and %any better
than one with local and different remote IP.

Fixes #2497.
2017-12-22 10:33:27 +01:00
Tobias Brunner 3c36c95539 kernel-netlink: Fix compilation on old kernels not defining IFA_F_NODAD
Fixes #2490.
2017-12-22 10:28:05 +01:00
Tobias Brunner 381f6d982c kernel-pfkey: Fix extended replay configuration on FreeBSD 11.1
Fixes: 88a8fba1c7 ("kernel-pfkey: Support anti-replay windows > 2k")
Fixes #2501.
2017-12-22 10:19:49 +01:00
Tobias Brunner a7f613ca2e vici: Document NTLM secrets in README.md
Fixes #2481.
2017-12-22 10:09:26 +01:00
Tobias Brunner 859d645c44 vici: Accept XAUTH as shared key type too
Fixes #2481.
2017-12-22 10:09:22 +01:00
Tobias Brunner 527b3f0ca5 Fixed some typos, courtesy of codespell 2017-11-15 10:21:13 +01:00
Thomas Egerer 9cc61baaf5 unit-tests: Rename targets for libstrongswan and kernel-netlink
libstrongswan and kernel-netlink are the only two components which do
not adhere to the naming scheme used for all other tests. If the tests
are run by an external application this imposes problems due to clashing
names.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2017-11-09 09:11:42 +01:00
Tobias Brunner 88a8fba1c7 kernel-pfkey: Support anti-replay windows > 2k
FreeBSD 11.1 supports a new extension to configure larger anti-replay
windows, now configured as number of packets.

Fixes #2461.
2017-11-08 16:35:38 +01:00
Tobias Brunner 21a500a092 kernel-pfkey: Don't include keys in SADB_UPDATE message to update IPs on FreeBSD
The FreeBSD kernel explicitly rejects messages containing keys for mature SAs.

Fixes #2457.
2017-11-08 16:34:12 +01:00
Tobias Brunner fdf33b0f1c vici: Add 'get|reset-counters' commands 2017-11-08 16:28:28 +01:00
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 2d244f178f vici: Make setting mark on inbound SA configurable 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 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 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 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
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 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 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 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 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
Tobias Brunner b2473e94a2 Fixed some typos, courtesy of codespell 2017-05-26 14:44:06 +02:00
Tobias Brunner 2e4d110d1e linked-list: Change return value of find_first() and signature of its callback
This avoids the unportable five pointer hack.
2017-05-26 13:56:44 +02:00
Tobias Brunner 8a2e4d4a8b linked-list: Change interface of callback for invoke_function()
This avoids the unportable five pointer hack.
2017-05-26 13:56:44 +02:00
Tobias Brunner 525cc46cab Change interface for enumerator_create_filter() callback
This avoids the unportable 5 pointer hack, but requires enumerating in
the callback.
2017-05-26 13:56:44 +02:00
Tobias Brunner 95a63bf281 Migrate all enumerators to venumerate() interface change 2017-05-26 13:56:44 +02:00
Tobias Brunner 0afe0eca67 vici: Make 96-bit truncation for SHA-256 configurable 2017-05-26 11:22:28 +02:00
Tobias Brunner 4270c8fcb0 stroke: Make 96-bit truncation for SHA-256 configurable 2017-05-26 11:22:28 +02:00
Tobias Brunner 7b476029e6 android-log: Link against liblog 2017-05-26 09:40:14 +02:00
Tobias Brunner 4989aba822 child-sa: Change API used to set/install policies
This way we only have to pass the traffic selectors once.
2017-05-23 18:41:31 +02:00
Tobias Brunner a9b698f5be tnc-ifmap: Null-terminate buffer to make sscanf()-calls safe 2017-05-23 18:29:13 +02:00
Tobias Brunner 70855696ad kernel-netlink: Use total retransmit timeout as acquire timeout
By using the total retransmit timeout, modifications of timeout settings
automatically reflect on the value of xfrm_acq_expires.  If set, the
value of xfrm_acq_expires configured by the user takes precedence over
the calculated value.
2017-05-23 18:05:58 +02:00
Thomas Egerer d140b3bd3f kernel-netlink: Try to add new inbound SA if update fails
When establishing a traffic-triggered CHILD_SA involves the setup of an
IKE_SA more than one exchange is required. As a result the temporary
acquire state may have expired -- even if the acquire expiration
(xfrm_acq_expires) time is set properly (165 by default).  The expire
message sent by the kernel is not processed in charon since no trap can
be found by the trap manager.
A possible solution could be to track allocated SPIs.  But since this is
a corner case and the tracking introduces quite a bit of overhead, it
seems much more sensible to add a new state if the update of a state
fails with NOT_FOUND.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2017-05-23 17:58:51 +02:00
Tobias Brunner bf08e39441 kernel-pfkey: Update SA addresses if supported by the kernel
Upcoming FreeBSD kernels will support updating the addresses of existing
SAs with new SADB_X_EXT_NEW_ADDRESS_SRC|DST extensions for the SADB_UPDATE
message.
2017-05-23 17:58:50 +02:00
Tobias Brunner a080cfece0 kernel-pfkey: Use new encap flag on Mac OS X when updating SAs 2017-05-23 17:58:50 +02:00
Tobias Brunner 48ea655016 kernel-netlink: Update hardware offload attribute when SAs are updated 2017-05-23 16:58:06 +02:00
Tobias Brunner 0b5dfaeb5c kernel-netlink: Base SA update on correct message in multi-message response 2017-05-23 16:58:06 +02:00
Tobias Brunner 7c4f88d4be vici: Make hardware offload configurable 2017-05-23 16:58:00 +02:00
Tobias Brunner 749ac175fa child-cfg: Use flags for boolean options
Makes it potentially easier to add new flags.
2017-05-23 16:51:15 +02:00
Tobias Brunner d42948fc05 kernel-netlink: Enable hardware offloading if configured for an SA 2017-05-23 16:51:03 +02:00
Tobias Brunner 7caec9e4a4 kernel-netlink: Directly handle Netlink messages if thread pool is empty
During initialization of the plugins the thread pool is not yet
initialized so there is no watcher thread that could handle the queued
Netlink message and the main thread will wait indefinitely for a
response.

Fixes #2199.
2017-05-23 16:49:39 +02:00
Martin Willi 9b29003cd9 socket-default: Add an option to force the sending interface via IP_PKTINFO
On Linux, setting the source address is insufficient to force a packet to be
sent over a certain path. The kernel uses the best route to select the outgoing
interface, even if we set a source address of a lower priority interface. This
is not only true for interfaces attaching to the same subnet, but also for
unrelated interfaces; the kernel (at least on 4.7) sends out the packet on
whatever interface it sees fit, even if that network does not expect packets
from the source address we force to.

When a better interface becomes available, strongSwan sends its MOBIKE address
list update using the old source address. But the kernel sends that packet over
the new best interface. If that network drops packets having the unexpected
source address from the old path, the MOBIKE update fails and the SA finally
times out.

To enforce a specific interface for our packet, we explicitly set the interface
index from the interface where the source address is installed. According to
ip(7), this overrules the specified source address to the primary interface
address. As this could have side effects to installations using multiple
addresses on a single interface, we disable the option by default for now.

This also allows using IPv6 link-local addresses, which won't work if
the outbound interface is not set explicitly.
2017-05-23 16:49:39 +02:00
Tobias Brunner 46a3f92a76 Add an option to announce support for IKE fragmentation but not sending fragments 2017-05-23 16:41:57 +02:00
Tobias Brunner 605a98c7ce vici: Return key ID from load-key command
We already do this for load-token and this should simplify client
implementations.
2017-05-23 16:41:02 +02:00
Tobias Brunner a1aede8065 attr-sql: Make release of online leases during startup optional
This cleanup prevents sharing the same DB between multiple VPN gateways.
2017-05-19 15:22:51 +02:00
Andreas Steffen 2fad3460fa eap-simaka-sql: Fixed database column from use to used 2017-04-26 20:38:00 +02:00
odi79 0d66b01a81 vici: Fix type error exception in Python bindings
Line 66 yields "TypeError: can't concat bytes to str" using Python 3.4.
"requestdata" was introduced in 22f08609f1 but is not actually used.
Since the original "request" is not used anywhere else this can be changed
to be similar to the other UTF-8 encoding changes in that commit.

Fixes: 22f08609f1 ("vici: Explicitly set the Python encoding type").
Closes strongswan/strongswan#66.
2017-04-19 10:00:21 +02:00
Jiri Horky 6fe1d78a0d kernel-netlink: Avoid O(n^2) copy operations when concatenating Netlink responses
When constructing the result, all responses from Netlink were concatenated
iteratively, i.e. for each response, the previously acquired result was
copied to newly allocated memory and the current response appended to it.
This results in O(n^2) copy operations. Instead, we now check for the
total final length of the result and copy the individual responses to it
in one pass, i.e. in O(n) copy operations. In particular, this issue caused
very high CPU usage in memcpy() function as the result is copied over and
over. Common way how to hit the issue is when having 1000+ routes and 5+
connecting clients a second. In that case, the memcpy() function can
take 50%+ of one CPU thread on a decent CPU and the whole charon daemon
is stuck just reading routes and concatenating them together (connecting
clients are blocked in that particular case as this is done under mutex).

Closes strongswan/strongswan#65.
References #2055.
2017-03-27 11:05:26 +02:00
Martin Willi 3610d7607e addrblock: Narrow selectors when rekeying a CHILD_SA as original responder
If a the original responder narrows the selectors of its peer in addrblock,
the peer gets a subset of that selectors. However, once the original responder
initiates rekeying of that CHILD_SA, it sends the full selectors to the peer,
and then narrows the received selectors locally for the installation, only.

This is insufficient, as the peer ends up with wider selectors, sending traffic
that the original responder will reject to the stricter IPsec policy. So
additionally narrow the selectors when rekeying CHILD_SAs before sending the
TS list to the peer.
2017-03-24 08:17:01 +01:00
Tobias Brunner 9d240b0761 kernel-wfp: Don't redefine IPPROTO_IP* if already defined 2017-03-23 18:29:18 +01:00
Tobias Brunner 550bd654a7 vici: Don't fall back to uninstalling traps if a matching shunt was found
This is different if `ike` and `child` are provided and uninstall()
fails as we call that without knowing whether a matching shunt exists.
But if `ike` is not provided we explicitly search for a matching shunt
and if found don't need to look for a trap policy.
2017-03-23 18:29:18 +01:00
Tobias Brunner 1003cf2330 Fixed some typos, courtesy of codespell 2017-03-23 18:29:18 +01:00
Martin Willi 46d4d2a71e vici: Document how we pronounce the vici protocol and plugin 2017-03-20 10:39:10 +01:00
Tobias Brunner 6d86d0f516 kernel: Make range of SPIs for IPsec SAs configurable 2017-03-02 08:52:56 +01:00
Martin Willi d536b94e0d addrblock: Use dynamic TS narrowing instead of rejecting the whole CHILD_SA
Previously, the client had to propose no wider selectors than the certificate
permits, otherwise the complete CHILD_SA was rejected. However, with IKEv2
we can dynamically narrow the selectors to what the certificate allows. This
makes client and gateway configurations very simple by just proposing 0.0.0.0/0,
narrowed to selectors the client is permitted to route into the network.
2017-03-02 08:24:02 +01:00
Martin Willi d1317adb9a addrblock: Support an optional non-strict mode accepting certs without addrblock
This allows a gateway to enforce the addrblock policy on certificates that
actually have the extension only. For (legacy) certificates not having the
extension, traffic selectors are validated/narrowed by other means, most
likely by the configuration.
2017-03-02 08:24:02 +01:00
Tobias Brunner 8bd8dcd522 vici: Only log messages if there actually is a listener 2017-02-16 19:24:09 +01:00
Tobias Brunner fa5f6ba26c vici: Let has_event_listeners() actually check if clients are registered
Fixes: 8d96f90a79 ("vici: Add function to test if an event should be
generated")
2017-02-16 19:24:09 +01:00
Tobias Brunner f927ba975b vici: Add support for mediation extension 2017-02-16 19:24:09 +01:00
Tobias Brunner ed96fe72cf peer-cfg: Store mediated_by as name and not peer-cfg reference
This way updates to the mediation config are respected and the order in
which configs are configured/loaded does not matter.

The SQL plugin currently maintains the strong relationship between
mediated and mediation connection (we could theoretically change that to a
string too).
2017-02-16 19:24:09 +01:00
Tobias Brunner ec5f127a45 vici: Include uniqueness policy in list-conns 2017-02-16 19:24:09 +01:00
Tobias Brunner 808472c9f9 vici: Add command to initiate SA rekeying 2017-02-16 19:24:08 +01:00
Tobias Brunner 04c0219e55 vici: Use unique names for CHILD_SAs in the list-sas command
The original name is returned in the new "name" attribute.

This fixes an issue with bindings that map VICI messages to
dictionaries.  For instance, in roadwarrior scenarios where every
CHILD_SA has the same name only the information of the last CHILD_SA
would end up in the dictionary for that name.
2017-02-16 19:24:08 +01:00
Tobias Brunner bd6ef6be7e vici: Add support to load CA certificates from tokens and paths in authority sections 2017-02-16 19:24:08 +01:00
Tobias Brunner 2f8354ca6c vici: Add support to load certificates from file paths
Probably not that useful via swanctl.conf but could be when used via VICI.
2017-02-16 19:24:08 +01:00
Tobias Brunner 00bf6a2a49 vici: Add support to load certificates from tokens 2017-02-16 19:24:08 +01:00
Tobias Brunner 2ceeb96db5 vici: Add command to load a private key from a token
PINs are stored in a "hidden" credential set, so that its shared
secrets are not exposed via VICI.  Since they are not explicitly loaded as
shared secrets via VICI a client might consider them as removed secrets and
remove them.
2017-02-16 19:24:07 +01:00
Tobias Brunner b657740e16 vici: List namespace/peer-cfg name with policies and allow filtering
The two names are also transmitted in separate keys.
2017-02-16 19:24:07 +01:00
Tobias Brunner 7627f5f9c7 vici: Explicitly use peer name when uninstalling trap and shunt policies
Also adds an `ike` parameter to the `uninstall` command.
2017-02-16 19:24:07 +01:00
Tobias Brunner 02767e4309 stroke: Use peer name as namespace for shunt policies
The same goes for the start-action-job.  When unrouting, we search for
the first policy with a matching child-cfg.
2017-02-16 19:24:07 +01:00
Tobias Brunner 7a0fdbab42 shunt-manager: Add an optional namespace for each shunt
This will allow us to reuse the names of child configs e.g. when they
are defined in different connections.
2017-02-16 19:24:07 +01:00
Tobias Brunner ed105f45af vici: Add support for NT Hash secrets
Fixes #1002.
2017-02-16 19:23:51 +01:00
Tobias Brunner 3bedf10b25 vici: Add support for IPv6 Transport Proxy Mode 2017-02-16 19:23:50 +01:00
Tobias Brunner e00bc9f6b2 vici: Add support for certificate policies 2017-02-16 19:23:50 +01:00
Tobias Brunner 44fcc83310 vici: Add missing dscp setting for IKE_SAs
Fixes #2170.
2017-02-16 19:23:31 +01:00
Tobias Brunner cf57d9a98f vici: Add possibility to remove shared keys by a unique identifier
This identifier can be set when adding/replacing a secret.  The unique
identifiers of all secrets may be enumerated.
2017-02-16 19:21:13 +01:00
Tobias Brunner 2a56acf501 vici: Add commands to enumerate and remove private keys
They are identified by their SHA-1 key identifier.
2017-02-16 19:21:12 +01:00
Tobias Brunner d20bf50e04 vici: Update get_pools() in Python and Ruby bindings 2017-02-16 19:21:12 +01:00
Tobias Brunner 71fa1224ec vici: Add option to query a specific pool 2017-02-16 19:21:12 +01:00
Tobias Brunner c2129d1cbe bypass-lan: Don't use interfaces in policies
After an interface disappeared we can't remove the policies correctly as
the name doesn't resolve to the previous index anymore.
And making the policies so specific might not provide that much benefit.

To handle the interfaces on the policies correctly would require some
changes to the child-cfg, kernel-interface etc. so they'd take interface
indices directly so we could target the policies correctly even if an
interface disappeared (or reappeared and got a new index).
2017-02-16 19:20:18 +01:00
Martin Willi 395500b8c1 kernel-netlink: Use RTA_SRC to specify route source in kernel-based lookups
For table dumps the kernel accepts RTA_PREFSRC to filter the routes, which is
what we do when doing userspace route calculations. For kernel-based route
lookups, however, the RTA_PREFSRC attribute is ignored and we must specify
RTA_SRC for policy based route lookups.
2017-02-13 15:11:20 +01:00
Martin Willi 558691b3b0 kernel-netlink: Use kernel-based route lookup if we do not install routes
For gateways with many connections, installing routes is often disabled,
as we can use a static route configuration to achieve proper routing with
a single rule. If this is the case, there is no need to dump all routes and
do userspace route lookups, as there is no need to exclude routes we installed
ourself.

Doing kernel-based route lookups is not only faster with may routes, but also
can use the full power of Linux policy based routing; something we can hardly
rebuild in userspace when calculating routes.
2017-02-13 15:11:20 +01:00
Martin Willi 0b4e539cb3 vici: Include the Netfilter marks in listed CHILD_SAs 2017-02-13 15:11:20 +01:00
Martin Willi 22f08609f1 vici: Explicitly set the Python encoding type
When using vici over RPyC and its (awesome) splitbrain, encoding and decoding
strings fails in vici, most likely because of the Monkey-Patch magic splitbrain
uses.

When specifying the implicit UTF-8 as encoding scheme explicitly, Python uses
the correct method to encode/decode the string, making vici useable in
splitbrain contexts.
2017-02-13 15:04:44 +01:00
Tobias Brunner 21df4cc1ed kernel-pfroute: Implement enumeration of local subnets 2017-02-08 10:38:28 +01:00
Tobias Brunner 0aabfe0780 bypass-lan: Allow ignoring or only considering subnets of specific interfaces
The config can also be reloaded by sending a SIGHUP to charon.
2017-02-08 10:38:28 +01:00
Tobias Brunner 62b58a40da bypass-lan: Configure interface on bypass policy
Currently, only the kernel-netlink plugin supports this, the others will
just ignore it.
2017-02-08 10:38:28 +01:00
Tobias Brunner 2406474158 kernel-netlink: Return interface name in local subnet enumerator 2017-02-08 10:38:28 +01:00
Tobias Brunner 46c21e3cc3 kernel-interface: Add interface name to local subnet enumerator 2017-02-08 10:38:28 +01:00
Tobias Brunner f8a362bfbc bypass-lan: Add plugin that installs bypass policies for locally attached subnets 2017-02-08 10:38:28 +01:00
Tobias Brunner eac584a37d kernel-netlink: Implement enumerator for local subnets 2017-02-08 10:38:28 +01:00
Tobias Brunner 3c46ce2834 kernel-pfkey: Use the same priority range for trap and regular policies
Same as the change in the kernel-netlink plugin.
2017-02-08 10:36:38 +01:00
Tobias Brunner 0e9d6c4605 kernel-netlink: Use the same priority range for trap and regular policies
While trap and regular policies now often look the same (mainly because
reqids are kept constant) trap policies still need to have a lower priority
than regular policies to handle unroute/route correctly if e.g. IPComp
is used or the mode changes.  But if we use a completely different
priority range that's lower than that of regular policies it is not possible
to install overlapping trap policies.  By differentiating trap from
regular policies via the priority's LSB this issue is avoided while
still maintaining the proper ordering of trap and regular policies.

Fixes #1243.
2017-02-08 10:36:38 +01:00
Tobias Brunner 6606393b8c kernel-netlink: Fix spacing in log message when policy is unchanged 2017-02-08 10:36:37 +01:00
James Laird-Wah 094a4d15cf forecast: Mark correct port in UDP NAT-T rule
Closes strongswan/strongswan#62.
2017-02-08 09:54:02 +01:00
Tobias Brunner 865fd804ee eap-dynamic: Publish the get_auth() method of the wrapped EAP method
Fixes #2238.
2017-02-07 10:52:24 +01:00
Tobias Brunner b062d3cc44 kernel-netlink: Set NODAD flag for virtual IPv6 addresses
The Optimistic Duplicate Address Detection (DAD) seems to fail in some
cases (`dadfailed` in `ip addr`) rendering the virtual IP address unusable.

Fixes #2183.
2017-02-06 11:10:44 +01:00
Tobias Brunner 7a40162cb7 kernel-netlink: Prefer matching label when selecting IPv6 source addresses
This implements rule 6 of RFC 6724 using the default priority table,
so that e.g. global addresses are preferred over ULAs (which also have
global scope) when the destination is a global address.

Fixes #2138.
2017-02-06 11:06:22 +01:00
Tobias Brunner 965daa1df3 kernel-netlink: Use correct 4 byte alignment for AH with IPv4
By default, the kernel incorrectly uses an 8 byte alignment, which is
mandatory for IPv6 but prohibited for IPv4.  For many algorithms this
doesn't matter but that's not the case for HMAC_SHA2_256_128.
Since 2.6.39 the kernel can be explicitly configured to use a 4 byte
alignment.
2017-01-25 17:51:35 +01:00
Thomas Egerer 8a91729dfe kernel-netlink: Allow change of Netlink socket receive buffer size
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2017-01-25 17:42:38 +01:00
Tobias Brunner 4ae2209e3d kernel-pfkey: Set state to SADB_SASTATE_MATURE when adding/updating SAs
Picky kernels might otherwise reject our messages as RFC 2367 explicitly
mandates this.

Fixes #2212.
2017-01-25 17:30:57 +01:00
Tobias Brunner da565d9832 kernel-pfroute: Don't set a gateway if it is of a different address family than the destination 2017-01-25 17:29:44 +01:00
Tobias Brunner 69b58e347e stroke: Default to %dynamic if no valid TS are specified in left|rightsubnet
Otherwise, we'd end up with an empty TS list, which is not valid.

Because end->tohost is set to !end->subnets in starter the removed branch was
never used.
2017-01-25 16:56:28 +01:00
Tobias Brunner 83bf6db303 vici: Reload loggers after reloading strongswan.conf via reload-setting command 2017-01-25 14:58:12 +01:00
Tobias Brunner 4e382f5ffc ha: Fix assignment of IP addresses if multiple pools are defined
Fixes #2146.
2017-01-25 12:28:34 +01:00
Tobias Brunner 0e3c8cc4a2 ha: Delete passive IKE_SA on other node after half-open timeout
Fixes #1192.
2017-01-25 12:27:21 +01:00
Thomas Egerer 7085ca68d6 kernel-netlink: Return const pointer from lookup_algorithm()
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2017-01-23 18:53:58 +01:00
Andreas Steffen bd2f2b11fc stroke: Load general PKCS#8 private keys 2016-12-17 18:06:11 +01:00
Weilu Jia 351179d4dc vici: Check for closed connection in Python bindings
The Python VICI library does not check if the socket is closed.
If the daemon closes the connection, _recvall() spins forever.

Closes strongswan/strongswan#56.
2016-12-14 11:35:31 +01:00
Tobias Brunner 564a199674 kernel-netlink: Add support for AES-CMAC-96 (RFC 4494)
The kernel apparently supports this since 3.10.
2016-12-12 11:43:06 +01:00
Volker Rümelin d17b780eaa farp: Fix BPF jump false offset
Jump to BPF_STMT(BPF_RET+BPF_K, 0) if protocol_size != 4
2016-10-31 14:46:14 +01:00
Tim Kent 87875086d0 connmark: Add CAP_NET_RAW to capabilities keep list
Fix for "Permission denied (you must be root)" error when calling
iptc_init(), which opens a RAW socket to communicate with the kernel,
when built with "--with-capabilities=libcap".

Closes strongswan/strongswan#53.
Fixes #2157.
2016-10-25 09:46:23 +02:00
Christophe Gouault a63a7af197 kernel-netlink: Fix get_route() interface determination
A wrong variable is used (route instead of best), so much that the
returned interface belongs to the last seen route instead of the best
choice route.

get_route() may therefore return mismatching interface and gateway.

Fixes: 66e9165bc6 ("kernel-netlink: Return outbound interface in get_nexthop()")

Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
2016-10-12 19:25:31 +02:00
Andreas Steffen 85b5a6ace2 Save both base and delta CRLs to disk 2016-10-11 17:18:22 +02:00
Andreas Steffen 2a2669ee3e vici: strongswan.conf cache_crls = yes saves fetched CRLs to disk 2016-10-11 17:18:22 +02:00
Tobias Brunner bfc595a36a kernel-netlink: Consider RTA_SRC when looking for a source address 2016-10-05 11:44:53 +02:00
Tobias Brunner d5c6a0bac4 vici: Enable IKE fragmentation by default 2016-10-04 10:08:21 +02:00
Tobias Brunner 33d3ffde25 kernel-netlink: Pass zero mark to kernel if mask is set
The kernel will apply the mask to the mark on the packet and then
compare it to the configured mark.  So to match only unmarked packets we
have to be able to set 0/0xffffffff.
2016-09-30 15:35:32 +02:00
Tobias Brunner ac9759a532 kernel-netlink: Support configuring XFRM policy hashing thresholds
If the number of flows over a gateway exceeds the flow cache size of the Linux
kernel, policy lookup gets very expensive. Policies covering more than a single
address don't get hash-indexed by default, which results in wasting most of
the cycles in xfrm_policy_lookup_bytype() and its xfrm_policy_match() use.
Starting with several hundred policies the overhead gets inacceptable.

Starting with Linux 3.18, Linux can hash the first n-bit of a policy subnet
to perform indexed lookup. With correctly chosen netbits, this can completely
eliminate the performance impact of policy lookups, freeing the resources
for ESP crypto.

WARNING: Due to a bug in kernels 3.19 through 4.7, the kernel crashes with a
NULL pointer dereference if a socket policy is installed while hash thresholds
are changed.  And because the hashtable rebuild triggered by the threshold
change that causes this is scheduled it might also happen if the socket
policies are seemingly installed after setting the thresholds.
The fix for this bug - 6916fb3b10b3 ("xfrm: Ignore socket policies when
rebuilding hash tables") - is included since 4.8 (and might get backported).
As a workaround `charon.plugins.kernel-netlink.port_bypass` may be enabled
to replace the socket policies that allow IKE traffic with port specific
bypass policies.
2016-09-30 14:54:52 +02:00
Tobias Brunner 50721a61d8 vici: Make installation of outbound FWD policies configurable 2016-09-28 17:56:43 +02:00
Tobias Brunner 175d78df60 kernel-netlink: Update cached reqid when updating policies 2016-09-28 17:55:01 +02:00
Tobias Brunner 70ac90c552 eap-peap: Fix memory leaks when handling tunneled methods 2016-09-20 15:36:15 +02:00
Tobias Brunner 0b4ba9c53d ipseckey: Properly free enumerated certificates 2016-09-20 15:36:15 +02:00
Tobias Brunner c0c14af8c2 ipseckey: Properly free public key after creating certificate 2016-09-20 15:36:15 +02:00
Tobias Brunner 149b7de35c dnscert: Properly free enumerated certificates 2016-09-20 15:36:15 +02:00
Tobias Brunner d344474b3d vici: Fix indention of flush_certs() method in Python bindings 2016-09-20 15:33:18 +02:00
Tobias Brunner d8f27ba679 maemo: Remove unused plugin 2016-09-15 18:33:52 +02:00
Andreas Steffen 2c7cfe7630 vici: flush-certs command flushes certificate cache
When fresh CRLs are released with a high update frequency (e.g.
every 24 hours) or OCSP is used then the certificate cache gets
quickly filled with stale CRLs or OCSP responses. The new VICI
flush-certs command allows to flush e.g. cached CRLs or OCSP
responses only. Without the type argument all kind of certificates
(e.g. also received end entity and intermediate CA certificates)
are purged.
2016-09-13 17:02:59 +02:00
Andreas Steffen 04208ac5d4 xof: Defined Extended Output Functions 2016-07-29 12:36:14 +02:00
Andreas Steffen 7f65a8c271 vici: Increased various string buffers to BUF_LEN (512 bytes) 2016-07-29 12:34:40 +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 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
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
Tobias Brunner 85fed13c18 kernel-pfkey: Don't install routes for drop policies and if protocol/ports are in the selector 2016-06-10 15:25:05 +02:00
Tobias Brunner e7369a9dc5 kernel-netlink: Don't install routes for drop policies and if protocol/ports are in the selector
We don't need them for drop policies and they might even mess with other
routes we install.  Routes for policies with protocol/ports in the
selector will always be too broad and might conflict with other routes
we install.
2016-06-10 14:01:36 +02:00
Tobias Brunner 50798628c5 kernel-pfkey: Also use interface returned by get_nexthop() for IPsec policies
An exception is if the local address is virtual, in which case we want
the route to be via TUN device.
2016-06-10 13:57:27 +02:00
Tobias Brunner d1f8628420 kernel-netlink: Also use interface returned by get_nexthop() for IPsec policies 2016-06-10 13:57:27 +02:00
Tobias Brunner c158331bfc kernel-pfkey: Use interface to next hop for shunt policies 2016-06-10 13:57:27 +02:00
Tobias Brunner 4ba5ea407b kernel-netlink: Use interface to next hop for shunt policies
Using the source address to determine the interface is not correct for
net-to-net shunts between two interfaces on which the host has IP addresses
for each subnet.
2016-06-10 13:57:27 +02:00
Tobias Brunner 66e9165bc6 kernel-netlink: Return outbound interface in get_nexthop() 2016-06-10 13:54:18 +02:00
Tobias Brunner 99a57aa5ee kernel-net: Let get_nexthop() return an optional interface name
The returned name should be the interface over which the destination
address/net is reachable.
2016-06-10 13:54:18 +02:00
Tobias Brunner ebeaac1f2b kernel-netlink: Let only a single thread work on a specific policy
Other threads are free to add/update/delete other policies.

This tries to prevent race conditions caused by releasing the mutex while
sending messages to the kernel.  For instance, if break-before-make
reauthentication is used and one thread on the responder is delayed in
deleting the policies that another thread is concurrently adding for the
new SA.  This could have resulted in no policies being installed
eventually.

Fixes #1400.
2016-06-10 10:45:35 +02:00
Tobias Brunner 471b907613 kernel-netlink: Add priority and refcount to policy log 2016-06-10 10:34:09 +02:00
Tobias Brunner 25178f4594 kernel-netlink: Consistently print mark in log messages only if set 2016-06-10 10:34:09 +02:00
Tobias Brunner a0178fe26e kernel-netlink: Provide error information for Netlink sockets
#1467.
2016-06-10 10:34:09 +02:00
Tobias Brunner fc21465c66 kernel-netlink: Allow definition of a custom priority calculation function 2016-06-10 10:33:17 +02:00
Tobias Brunner 1ba2b015fa kernel-pfkey: Use ipsec_sa_cfg_equals() 2016-06-08 16:12:52 +02:00
Tobias Brunner 87ed9a5ffb kernel-netlink: Use ipsec_sa_cfg_equals() and compare marks properly 2016-06-08 16:12:52 +02:00
Tobias Brunner 5005325020 eap-simaka-pseudonym: Properly store mappings
If a pseudonym changed a new entry was added to the table storing
permanent identity objects (that are used as keys in the other table).
However, the old mapping was not removed while replacing the mapping in
the pseudonym table caused the old pseudonym to get destroyed.  This
eventually caused crashes when a new pseudonym had the same hash value as
such a defunct entry and keys had to be compared.

Fixes strongswan/strongswan#46.
2016-06-06 14:27:19 +02:00
Thomas Egerer aa6d4a3d54 error-notify: Notify listeners upon IKE retransmit
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2016-06-06 14:11:02 +02:00
Tobias Brunner 2eb89ee1e3 stroke: Permanently store PINs in credential set
This fixes authentication with tokens that require the PIN for every
signature.

Fixes #1369.
2016-06-06 14:03:23 +02:00
Tobias Brunner 3427e43f4b p-cscf: Remove libhydra reference in Makefile 2016-05-27 18:24:59 +02:00
Tobias Brunner 09328c5210 vici: Put source distribution in the dist dir in the build directory
This fixes the out-of-tree build.
2016-05-11 14:33:08 +02:00
Tobias Brunner 81b9de0126 vici: Add target to build a source package and universal wheel of the Python package 2016-05-11 11:36:51 +02:00
Tobias Brunner fa844a798b vici: Add README.rst to be used as description on PyPI 2016-05-11 11:16:43 +02:00
Tobias Brunner 5d5ecd8e72 vici: Replace dr with dev in version numbers for the Python egg
The versioning scheme used by Python (PEP 440) supports the rcN suffix
but development releases have to be named devN, not drN, which are
not supported and considered legacy versions.
2016-05-10 12:16:13 +02:00
Tobias Brunner 1ff7ff5ac8 vici: Update setup.py 2016-05-10 11:42:29 +02:00
Tobias Brunner 756cd28fb8 vici: Ensure we read exactly the specified amount of bytes from the socket in Python
recv() will return less bytes than specified (as that's the buffer size)
if not as many are ready to be read from the socket.
2016-05-10 11:42:29 +02:00
Tobias Brunner fee991c259 kernel-netlink: Check proper watcher state in parallel mode
After adding the read callback the state is WATCHER_QUEUED and it is
switched to WATCHER_RUNNING only later by an asynchronous job. This means
that a thread that sent a Netlink message shortly after registration
might see the state as WATCHER_QUEUED.  If it then tries to read the
response and the watcher thread is quicker to actually read the message
from the socket, it could block on recv() while still holding the lock.
And the asynchronous job that actually read the message and tries to queue
it will block while trying to acquire the lock, so we'd end up in a deadlock.

This is probably mostly a problem in the unit tests.
2016-05-06 16:00:32 +02:00
Tobias Brunner 3f4cc30b19 kernel-netlink: Order routes by prefix before comparing priority/metric
Metrics are basically defined to order routes with equal prefix, so ordering
routes by metric first makes not much sense as that could prefer totally
unspecific routes over very specific ones.

For instance, the previous code did break installation of routes for
passthrough policies with two routes like these in the main routing table:

  default via 192.168.2.1 dev eth0 proto static
  192.168.2.0/24 dev eth0 proto kernel scope link src 192.168.2.10 metric 1

Because the default route has no metric set (0) it was used, instead of the
more specific other one, to determine src and next hop when installing a route
for a passthrough policy for 192.168.2.0/24.  Therefore, the installed route
in table 220 did then incorrectly redirect all local traffic to "next hop"
192.168.2.1.

The same issue occurred when determining the source address while
installing trap policies.

Fixes 6b57790270 ("kernel-netlink: Respect kernel routing priorities for IKE routes").
Fixes #1416.
2016-05-06 15:48:45 +02:00
Andreas Steffen b1df631212 vici list-conns sends reauthentication and rekeying time information 2016-05-04 18:13:52 +02:00
Tobias Brunner 254726b59e kernel-pfkey: Add support for manual priorities
Also orders policies with equals priorities by their automatic priority.
2016-04-15 10:39:01 +02:00
Tobias Brunner 4e59618382 kernel-pfkey: Update priority calculation formula to the new one in kernel-netlink
Since the selectors are not exactly the same (no port masks, no interface)
some small tweaks have been applied.
2016-04-15 10:39:00 +02:00
Tobias Brunner 869f4e90b1 kernel-netlink: Order policies with equal priorities by their automatic priority
This allows using manual priorities for traps, which have a lower
base priority than the resulting IPsec policies.  This could otherwise
be problematic if, for example, swanctl --install/uninstall is used while
an SA is established combined with e.g. IPComp, where the trap policy does
not look the same as the IPsec policy (which is now otherwise often the case
as the reqids stay the same).

It also orders policies by selector size if manual priorities are configured
and narrowing occurs.
2016-04-15 10:39:00 +02:00
Andreas Steffen d3af3b799f Extended IPsec kernel policy scheme
The kernel policy now considers src and dst port masks as well as
restictions to a given network interface. The base priority is
100'000 for passthrough shunts, 200'000 for IPsec policies,
300'000 for IPsec policy traps and 400'000 for fallback drop shunts.
The values 1..30'000 can be used for manually set priorities.
2016-04-09 16:51:02 +02:00
Andreas Steffen e9704e90cf Include manual policy priorities and restriction to interfaces in vici list-conn command 2016-04-09 16:51:02 +02:00
Andreas Steffen c26e4330e7 Implemented IPsec policies restricted to given network interface 2016-04-09 16:51:02 +02:00
Andreas Steffen 7f57c4f9fb Support manually-set IPsec policy priorities 2016-04-09 16:51:01 +02:00
Tobias Brunner 2ba5dadb12 peer-cfg: Use struct to pass data to constructor 2016-04-09 16:51:01 +02:00
Tobias Brunner 8a00a8452d child-cfg: Use struct to pass data to constructor 2016-04-09 16:51:01 +02:00
Tobias Brunner fd8f1194f3 kernel-pfkey: Prefer policies with reqid over those without 2016-04-09 16:51:01 +02:00
Tobias Brunner 0ff8ce9452 kernel-pfkey: Only install templates for regular IPsec policies with reqid 2016-04-09 16:51:01 +02:00
Tobias Brunner 83312ee5e4 kernel-netlink: Prefer policies with reqid over those without
This allows two CHILD_SAs with reversed subnets to install two FWD
policies each.  Since the outbound policy won't have a reqid set we will
end up with the two inbound FWD policies installed in the kernel, with
the correct templates to allow decrypted traffic.
2016-04-09 16:51:00 +02:00
Tobias Brunner f7e9e6a3fd kernel-netlink: Only associate templates with inbound FWD policies
We can't set a template on the outbound FWD policy (or we'd have to make
it optional).  Because if the traffic does not come from another (matching)
IPsec tunnel it would get dropped due to the template mismatch.
2016-04-09 16:51:00 +02:00
Tobias Brunner c4387e991a kernel-netlink: Associate routes with IN policies instead of FWD policies
This allows us to install more than one FWD policy.  We already do this
in the kernel-pfkey plugin (there the original reason was that not all
kernels support FWD policies).
2016-04-09 16:50:59 +02:00
Tobias Brunner 89da06ace9 kernel: Use structs to pass information to the kernel-ipsec interface 2016-04-09 16:50:59 +02:00
Cameron McCord be41d5cba2 vici: Fix documentation of some dictionary keys of two request messages
Closes strongswan/strongswan#40.
2016-03-31 11:26:44 +02:00
Andreas Steffen b12c53ce77 Use standard unsigned integer types 2016-03-24 18:52:48 +01:00
Shota Fukumori b210369314 updown: Get value for PLUTO_MARK_{IN,OUT} from CHILD_SA
Or the invoked script will get a broken value when `mark=%unique` is
used in a configuration.

Closes strongswan/strongswan#37.
2016-03-23 14:45:04 +01:00
Tobias Brunner b39be996cc connmark: Explicitly include xt_mark.h for older kernels
Fixes #1365.
2016-03-23 14:40:29 +01:00
Thomas Egerer 90a7a68488 ha: Delete cache entry inside the locked mutex
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2016-03-23 10:34:24 +01:00
Tobias Brunner 0ed9430d10 kernel-netlink: Fix lookup of next hops for destinations with prefix
References #1347.
2016-03-21 12:14:59 +01:00
Tobias Brunner 20df9d315c vici: Don't hold write lock while running or undoing start actions
Running or undoing start actions might require enumerating IKE_SAs,
which in turn might have to enumerate peer configs concurrently, which
requires acquiring a read lock.  So if we keep holding the write lock while
enumerating the SAs we provoke a deadlock.

By preventing other threads from acquiring the write lock while handling
actions, and thus preventing the modification of the configs, we largely
maintain the current synchronous behavior.  This way we also don't need to
acquire additional refs for config objects as they won't get modified/removed.

Fixes #1185.
2016-03-11 08:32:18 +01:00
Andreas Steffen 35babdf43f Initialize ts variable 2016-03-11 08:29:23 +01:00
Tobias Brunner 7d22a75b12 forecast: Compare the complete rules when deleting them
Same as the change in the connmark plugin.

References #1229.
2016-03-10 17:26:38 +01:00
Tobias Brunner c659d369a0 connmark: Don't restore CONNMARK for packets that already have a mark set
This allows e.g. modified versions of xl2tpd to set the mark in
situations where two clients are using the same source port behind the
same NAT, which CONNMARK can't restore properly as only one conntrack entry
will exist with the mark set to that of the client that sent the last packet.

Fixes #1230.
2016-03-10 17:26:26 +01:00
Tobias Brunner 7c9e7eb933 connmark: Compare the complete rules when deleting them
By settings a matchmask that covers the complete rule we ensure that the
correct rule is deleted (i.e. matches and targets with potentially different
marks are also compared).

Since data after the passed pointer is actually dereferenced when
comparing we definitely have to pass an array that is at least as long as
the ipt_entry.

Fixes #1229.
2016-03-10 17:26:09 +01:00
Andreas Steffen 3f1de98678 Support of IP address ranges in traffic selectors 2016-03-10 13:59:37 +01:00
Tobias Brunner 7e854f4d51 attr: Only enumerate attributes matching the IKE version of the current IKE_SA
Numerically configured attributes are currently sent for both versions.
2016-03-10 11:57:39 +01:00
Tobias Brunner 98a3ba8a5a attr: Add p-cscf keyword for P-CSCF server addresses 2016-03-10 11:57:38 +01:00
Tobias Brunner 276acafa2d p-cscf: Make sending requests configurable and disable it by default 2016-03-10 11:57:38 +01:00
Tobias Brunner e8262251e1 p-cscf: Only send requests if virtual IPs of the same family are requested 2016-03-10 11:57:38 +01:00
Tobias Brunner 3d91d013cc p-cscf: Add attribute handler for P-CSCF server addresses 2016-03-10 11:57:38 +01:00
Tobias Brunner 12ac5fac1a p-cscf: Add plugin stub 2016-03-10 11:57:38 +01:00
Tobias Brunner 101abed566 vici: Replace child configs atomically
This also leaves unmodified configs as they are.
2016-03-08 10:21:58 +01:00
Tobias Brunner 229cdf6bc8 vici: Order auth rounds by optional `round` parameter instead of by position in the request 2016-03-08 10:04:55 +01:00
Tobias Brunner 67e28a3afa smp: Correctly return IKE SPIs stored in network order 2016-03-04 18:43:26 +01:00
Tobias Brunner e32504352d vici: Correctly return IKE SPIs stored in network order 2016-03-04 18:43:26 +01:00
Tobias Brunner db00982dad stroke: Correctly print IKE SPIs stored in network order 2016-03-04 18:43:26 +01:00
Tobias Brunner 1ecec95dff vici: Add support for pubkey constraints with EAP-TLS
This is a feature currently supported by stroke.
2016-03-04 16:19:54 +01:00
Tobias Brunner 3c23a75120 auth-cfg: Make IKE signature schemes configurable
This also restores the charon.signature_authentication_constraints
functionality, that is, if no explicit IKE signature schemes are
configured we apply all regular signature constraints as IKE constraints.
2016-03-04 16:19:54 +01:00
Tobias Brunner c13eb73719 vici: Don't redirect all SAs if no selectors are given
This avoid confusion and redirecting all SAs can now easily be done
explicitly (e.g. peer_ip=0.0.0.0/0).
2016-03-04 16:03:00 +01:00
Tobias Brunner 27074f3155 vici: Match subnets and ranges against peer IP in redirect command 2016-03-04 16:03:00 +01:00
Tobias Brunner bef4518de7 vici: Match identity with wildcards against remote ID in redirect command 2016-03-04 16:02:59 +01:00
Tobias Brunner 43b46b26ea vici: Add redirect command
This allows redirecting IKE_SAs by multiple different selectors, if none
are given all SAs are redirected.
2016-03-04 16:02:59 +01:00
Andreas Steffen ad82c95f0a Set PLUTO port variables to 0 in the case of no port restrictions 2016-03-04 12:52:35 +01:00
Andreas Steffen 0d7202c7c5 Port range support in updown script 2016-03-04 09:52:34 +01:00
Andreas Steffen 6abae81f86 Implemented port ranges in kernel_netlink interface 2016-03-04 09:52:34 +01:00
Tobias Brunner 28649f6d91 libhydra: Remove empty unused library 2016-03-03 17:36:11 +01:00
Tobias Brunner 8394ea2a42 libhydra: Move kernel interface to libcharon
This moves hydra->kernel_interface to charon->kernel.
2016-03-03 17:36:11 +01:00
Tobias Brunner dec9e1957f libhydra: Move all kernel plugins to libcharon 2016-03-03 17:36:11 +01:00