Commit Graph
19436 Commits
Author SHA1 Message Date
Tobias Brunner d4575da53c child-cfg: Add flag to enable per-CPU SAs 2025-05-28 16:35:26 +02:00
Tobias Brunner 749814a75f notify-payload: Add notify types for per-resource CHILD_SAs 2025-05-28 16:35:26 +02:00
Tobias Brunner 8f6e3c164a testing: Include the kernel build number 2025-05-28 16:35:26 +02:00
Tobias Brunner b6a4cfc705 Merge branch 'acquires-seq'
This uses the sequence number from acquires when installing the SA. This
allows handling narrowing properly by changing the reqid and still
removing the temporary state in the kernel.  It also changes that
traffic selectors are reused during rekeying/recreation/reauthentication,
so narrowed selectors won't return to the wider configured TS because
there won't be any TS from triggering packets to narrow again.
2025-05-28 16:30:56 +02:00
Tobias Brunner 8cb5918b0c testing: Add ikev2/net2net-route-narrow scenario 2025-05-28 16:01:00 +02:00
Tobias Brunner 6c7c539eaf child-create: Consider previous TS when checking for duplicates 2025-05-28 16:01:00 +02:00
Tobias Brunner 58d6778adb child-sa: Add helper to check if a list of TS match negotiated TS 2025-05-28 16:01:00 +02:00
Tobias Brunner e7fc7a4ecc child-create: Maintain traffic selectors during rekeying/reauthentication
If we don't do this, narrowed SAs would default to the wide configured
traffic selectors and the peer won't know if/how to narrow.
2025-05-28 16:01:00 +02:00
Tobias Brunner 9205458355 child-create: Use more generic method to pass information from previous SA
Besides the previous key exchange method, this will allow us to also
reuse the previous traffic selectors.  Some data is still passed in
separate methods as some are set even when there is no previous SA and
others are not set in all cases.

The interface for queue_child() now optionally takes the previous
Child SA to handle both recreations and initiations from scratch.
2025-05-28 11:06:19 +02:00
Tobias Brunner ad1ad2159f child-cfg: Use traffic selector list 2025-05-28 11:06:19 +02:00
Tobias Brunner 4b468126ca traffic-selector-list: Add helper class to manage a collection of TS
Provides functions to optionally resolve dynamic TS and to narrow
them based on a list of supplied TS.
2025-05-28 11:06:19 +02:00
Tobias Brunner 79815b4e67 trap-manager: Set seq. no. for CHILD_SAs not initiated by an acquire
This fixes cases where `start_action = trap|start` is used and an acquire
is triggered while the SA is initiated (granted if narrowing is expected,
that's not a recommended configuration as the responder can only use
the first config when there is no packet TS).  The resulting second
create-child task will potentially get dropped by the duplicate check,
so the temporary state won't get removed and traffic is blocked until
that expires, neither can acquires get triggered for traffic that doesn't
match the initial SA's policies.
2025-05-28 10:11:53 +02:00
Tobias Brunner ac0c73a412 child-create: Trigger CHILD_INSTALLING event after setting traffic selectors
This was the case before bce0c5fd74 ("child-create: Update CHILD_SA IP
addresses before installation") and allows listeners to consider the
traffic selectors of the SA that's about to get installed.
2025-05-28 10:11:53 +02:00
Tobias Brunner 5bb6f636ad child-create: Use helper to compare packet TS against CHILD_SAs 2025-05-28 10:11:53 +02:00
Tobias Brunner 769d9a12aa child-sa: Add helper to check if two TS match negotiated TS 2025-05-28 10:11:53 +02:00
Tobias Brunner 65b810e9b0 acquire-job: Use helpers to manage acquire data 2025-05-28 10:11:53 +02:00
Tobias Brunner c563b0d930 kernel-listener: Add helpers to clone/destroy acquire data 2025-05-28 10:11:53 +02:00
Tobias Brunner 6ae29af18b child-create: Consider triggering TS when checking for duplicate 2025-05-28 10:11:53 +02:00
Tobias Brunner 6e274271af vici: Include reqid when listing trap policies 2025-05-28 10:11:53 +02:00
Tobias Brunner 5624f7ffaa kernel-pfkey: Don't use TS from acquire in tunnel mode
The addresses are actually the endpoints of the SA, not information on
the matched packet (except that the RFC says to set the ports and
protocol of the packet in the source address, which the Linux kernel
doesn't do).  So these are useless, unless transport mode is used, where
the addresses are needed for the wildcard trap policy use case.

The RFC mentions a PROXY address (a single one, not two), that could
apparently be something like the source address in tunnel mode.
However, the description of how this is used in the RFC is quite weird
and neither Linux nor FreeBSD send such an attribute in SADB_ACQUIRE.
2025-05-28 10:11:53 +02:00
Tobias Brunner b024b7e9a6 kernel-netlink: Add support for acquire sequence numbers
Note that while PF_KEYv2 also uses sequence numbers to identify acquires,
which we currently don't use correctly by the way, it does not include
information about the packet that triggered an acquire.  What we receive
in src and dst, and currently forward as traffic selectors, are actually
the designated endpoints of the SA. So especially in tunnel mode this is
useless to do narrowing on the responder (these addresses might not even
match the configured TS).
2025-05-28 10:01:19 +02:00
Tobias Brunner 46c338a78f kernel-interface: Change reqid if seq. nos. are supported and narrowing occurred
With the sequence numbers we don't have to maintain the reqid to delete
the temporary state.

One exception is with labels.  There we currently only install trap
policies with the generic label.  SAs created from those don't have
policies installed, so we have to reuse the reqid of the trap even if
narrowing occurs.

And as before, we reuse the reqid without checking traffic selectors if
sequence numbers are not supported.

Note that if a CHILD_SA is manually initiated (i.e. has no sequence
number assigned) right before an acquire is triggered, there are several
possible outcomes depending on whether narrowing occurs.  If there is no
narrowing, the same reqid is assigned and the kernel will remove the
temporary SA when the SA is installed (no seq => reqid match).
Afterwards, the queued duplicate CHILD_SA is destroyed and the acquire
state in the trap manager gets removed.  If there is narrowing, a new
reqid is allocated, so the installation of the SA will not remove the
temporary state.  However, due to the narrowing, the duplicate check
fails and when the duplicate is installed (with sequence number), the
temporary state is deleted (as is the state in the trap manager).
2025-05-28 10:01:19 +02:00
Tobias Brunner c5b2a8eaa3 child-cfg: Use separate method to get configured traffic selectors
Optionally with "dynamic" traffic selectors resolved.  A new method
is added for those cases where we actually want to select potentially
narrowed traffic selectors using a supplied list.  The latter now also
always logs details, while the former does not.
2025-05-28 10:01:19 +02:00
Tobias Brunner 84da416082 trap-manager: Use sequence numbers to identify acquires
Either use the sequence number from the kernel (and potentially update
it if the acquire was retriggered), or generate our own sequence
numbers, which simplifies matching acquires to established/destroyed
CHILD_SAs.
2025-05-28 10:01:19 +02:00
Tobias Brunner 82c82cbbd6 ike: Support optional acquire sequence numbers when creating CHILD_SAs 2025-05-28 10:01:19 +02:00
Tobias Brunner 0c9bac73d9 child-sa: Store and propagate optional acquire sequence number 2025-05-28 10:01:19 +02:00
Tobias Brunner 3e6d7db5e3 kernel-interface: Add members for optional acquire sequence number 2025-05-28 10:01:19 +02:00
Tobias Brunner 301887b865 Merge branch 'regex-ids'
Adds support for POSIX regular expressions in configured identities,
which makes matching remote identities more flexible.
2025-05-28 09:58:46 +02:00
Tobias Brunner 981c82ab50 vici: Add support for POSIX regular expressions in identity fields 2025-05-28 09:58:17 +02:00
Tobias Brunner 10c2985cdd conf: Escape " and \ in man page output 2025-05-28 09:58:17 +02:00
Tobias Brunner 7de05b918c identification: Add support for POSIX regular expressions
When cross-compiling for Windows on Ubuntu, we don't have POSIX regular
expressions available (there does not seem to be any alternative libraries
either), but since the tests are not executed that's OK.  On AppVeyor,
MSYS2 has libgnurx installed, which works fine but requires explicit
linking with `-lregex`.

This is loosely based on a patch by Thomas Egerer.
2025-05-28 09:58:17 +02:00
Tobias Brunner 2b1f0e8c6e debug: Use separate log group for watcher_t
This component produces a lot of messages that make debugging job
handling difficult.
2025-05-27 17:41:02 +02:00
Tobias Brunner 4703ef00ce github: Use AWS-LC 1.52.0 for tests 2025-05-27 17:38:32 +02:00
Tobias Brunner 29986dd1e5 wolfssl: Remove unused drbg_t instance when building without testable KE 2025-05-27 17:38:32 +02:00
Tobias Brunner e3fa72b81a ml: Remove unused drbg_t instance when building without testable KE 2025-05-27 17:38:32 +02:00
Tobias Brunner 07a9926464 botan: Remove unused drbg_t instance when building without testable KE 2025-05-27 17:38:32 +02:00
Tobias Brunner 37ec770758 pki: Reduce indentation in usage output and print command description
Also print error message at the end of the output.
2025-05-27 17:38:32 +02:00
Tobias Brunner 5f4988eb7c swanctl: Reduce indentation in usage output and print command descriptions
Also print error message at the end of the output.
2025-05-27 17:38:24 +02:00
Tobias Brunner 9a9d0a0bf7 swanctl: Document maximum log level of messages received by --log 2025-05-22 14:24:43 +02:00
Tobias Brunner 362fa94ef5 vici: Document that the log event only receives messages on level 0 and 1 2025-05-22 14:05:51 +02:00
Tobias Brunner 688b9e27d5 Merge branch 'initiate-cancel'
Allow proper shutdown if a deadlock is caused by too many concurrent
blocking initiation requests.

References strongswan/strongswan#2776
2025-05-19 17:21:57 +02:00
Tobias Brunner f8e5e38b12 vici: Make threads handling requests get canceled explicitly
Threads initiating SAs can get stuck on the semaphore in
wait_for_listener() during shutdown if the corresponding job is never
executed.  A particular case when this can happen is if more initiations
are triggered than worker threads are available.  This causes a (known)
deadlock as no workers are free anymore to process jobs (for inbound
messages or timeouts etc.), including the one to initiate an SA.
This change at least allows a proper shutdown.
2025-05-19 17:20:59 +02:00
Tobias Brunner 8d3855ba31 vici: Don't pass stack variable to thread cleanup handler
The variable seems to get overwritten during cleanup, causing a
segmentation fault because either the pointer and/or the length is
invalid.
2025-05-19 17:19:20 +02:00
Tobias Brunner 367e782054 controller: Avoid memory leak if initiate job is never executed
This can happen if the daemon is terminated while an initiation is
pending.
2025-05-19 17:19:20 +02:00
Tobias Brunner 94cc07cab4 uci: Remove obsolete and broken plugin
The plugin was apparently broken for years because it uses functions that
don't exist anymore.  It was quite limited anyway, so it was never really
used in OpenWrt to begin with (instead they generate configs in a custom
init script).
2025-05-19 17:17:45 +02:00
Tobias Brunner 2b3a5172d8 configure: Add missing dependency of lib-prefix.m4
Fixes: 7ec0101250 ("Include lib-prefix.m4 directly and remove gettext dependency")
2025-05-13 18:45:45 +02:00
Tobias Brunner e8e5e2d441 configure: Simplify inclusion of M4 macros 2025-05-13 18:45:45 +02:00
Gerardo Ravago 99fda969b4 openssl: Fix AWS-LC build
The `crypt` functions defined here conflict with the `crypt` function
defined in `unistd.h` and trigger compilation errors when building
against the latest version of AWS-LC, which introduced a new transitive
include of `unistd.h` via `bio.h`.

This simply renames the function to avoid the error.

Closes strongswan/strongswan#2786
2025-05-13 17:16:07 +02:00
Tobias Brunner 7ec0101250 Include lib-prefix.m4 directly and remove gettext dependency
A recent gettext release (0.25 via Homebrew) installs the M4 macros in a
different location (<prefix>/share/gettext/m4 instead of
<prefix>/share/aclocal). According to the commit messages to avoid "bad
interactions between autoreconf and autopoint".  Since we only depend
on gettext for that macro and this move makes it complicated, we can also
just integrate the macro from gnulib directly (which gettext 0.18+ relies
on anyway).
2025-05-13 17:15:23 +02:00
Tobias Brunner 198d112745 github: Use AWS-LC 1.51.2 for tests 2025-05-13 17:15:15 +02:00