Commit Graph

119 Commits

Author SHA1 Message Date
Josh Soref b3ab7a48cc Spelling fixes
* accumulating
* acquire
* alignment
* appropriate
* argument
* assign
* attribute
* authenticate
* authentication
* authenticator
* authority
* auxiliary
* brackets
* callback
* camellia
* can't
* cancelability
* certificate
* choinyambuu
* chunk
* collector
* collision
* communicating
* compares
* compatibility
* compressed
* confidentiality
* configuration
* connection
* consistency
* constraint
* construction
* constructor
* database
* decapsulated
* declaration
* decrypt
* derivative
* destination
* destroyed
* details
* devised
* dynamic
* ecapsulation
* encoded
* encoding
* encrypted
* enforcing
* enumerator
* establishment
* excluded
* exclusively
* exited
* expecting
* expire
* extension
* filter
* firewall
* foundation
* fulfillment
* gateways
* hashing
* hashtable
* heartbeats
* identifier
* identifiers
* identities
* identity
* implementers
* indicating
* initialize
* initiate
* initiation
* initiator
* inner
* instantiate
* legitimate
* libraries
* libstrongswan
* logger
* malloc
* manager
* manually
* measurement
* mechanism
* message
* network
* nonexistent
* object
* occurrence
* optional
* outgoing
* packages
* packets
* padding
* particular
* passphrase
* payload
* periodically
* policies
* possible
* previously
* priority
* proposal
* protocol
* provide
* provider
* pseudo
* pseudonym
* public
* qualifier
* quantum
* quintuplets
* reached
* reading
* recommendation to
* recommendation
* recursive
* reestablish
* referencing
* registered
* rekeying
* reliable
* replacing
* representing
* represents
* request
* request
* resolver
* result
* resulting
* resynchronization
* retriable
* revocation
* right
* rollback
* rule
* rules
* runtime
* scenario
* scheduled
* security
* segment
* service
* setting
* signature
* specific
* specified
* speed
* started
* steffen
* strongswan
* subjectaltname
* supported
* threadsafe
* traffic
* tremendously
* treshold
* unique
* uniqueness
* unknown
* until
* upper
* using
* validator
* verification
* version
* version
* warrior

Closes strongswan/strongswan#164.
2020-02-11 18:23:07 +01:00
Tobias Brunner a2cb2c9cc8 proposal: Add selection flags to clone() method
This avoids having to call strip_dh() in child_cfg_t::get_proposals().
It also inverts the ALLOW_PRIVATE flag (i.e. makes it SKIP_PRIVATE) so
nothing has to be supplied to clone complete proposals.
2019-10-24 17:43:21 +02:00
Tobias Brunner fafa76984d child-sa: Pass default interface ID inherited from IKE_SA
Also pass optional arguments as struct.
2019-04-04 09:36:38 +02:00
Tobias Brunner 9347f72494 ipsec-types: Move allocation of unique interface IDs to helper function 2019-04-04 09:31:38 +02:00
Tobias Brunner a6014d99b7 child-sa: Configure interface ID on SAs and policies 2019-04-03 12:00:08 +02:00
Tobias Brunner f99bd2a5a6 kernel-interface: Consider interface ID when allocating reqids 2019-04-03 12:00:08 +02:00
Carl Smith 8e31d65730 child-sa: Remove temporary DROP policy using same parameters as when added
A temporary DROP policy is added to avoid traffic leak
while the SA is being updated. It is added with
manual_prio set but when the temporary policy is removed
it is removed with manual_prio parameter set to 0.
The call to del_policies_outbound does not match the original
policy and we end up with an ever increasing refcount.

If we try to manually remove the policy, it is not removed
due to the positive refcount. Then new SA requests fail with
"unable to install policy out for reqid 1618,
the same policy for reqid 1528 exists"

Fixes: 35ef1b032d ("child-sa: Install drop policies while updating IPsec SAs and policies")
Closes strongswan/strongswan#129.
2019-03-04 09:38:35 +01:00
Tobias Brunner db82c0f594 Fixed some typos, courtesy of codespell 2018-12-18 11:14:19 +01:00
Martin Willi 902dc29f7a child-sa: Use SA matching mark as SA set mark if the latter is %same
For inbound processing, it can be rather useful to apply the mark to the
packet in the SA, so the associated policy with that mark implicitly matches.
When using %unique as match mark, we don't know the mark beforehand, so
we most likely want to set the mark we match against.
2018-08-31 12:26:40 +02:00
Tobias Brunner f59450fde6 child-sa: Configure in-/outbound mark the SA should set 2018-08-31 12:26:40 +02:00
Tobias Brunner c993eaf9d1 kernel: Add option to control DS field behavior 2018-08-29 11:36:04 +02:00
Tobias Brunner dc8b015d78 kernel: Add options to control DF and ECN header bits/fields via XFRM
The options control whether the DF and ECN header bits/fields are copied
from the unencrypted packets to the encrypted packets in tunnel mode (DF only
for IPv4), and for ECN whether the same is done for inbound packets.

Note: This implementation only works with Linux/Netlink/XFRM.

Based on a patch by Markus Sattler.
2018-08-29 11:36:04 +02:00
Tobias Brunner 84cdfbc9bc child-cfg: Allow suppressing log messages when selecting traffic selectors
Although being already logged on level 2, these messages are usually just
confusing if they pop up randomly in the log when e.g. querying the configs
or installing traps.  So after this the log messages will only be logged when
actually proposing or selecting traffic selectors during IKE.
2018-06-28 18:46:42 +02:00
Tobias Brunner 16898026a5 child-sa: Add new state to track deleted but not yet destroyed CHILD_SAs
This allows us to easily identify SAs we keep around after a rekeying to
process delayed packets.
2018-04-09 17:13:41 +02:00
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 529ffc2fe3 child-sa: Don't update outbound policies if they are not installed
After a rekeying we keep the inbound SA and policies installed for a
while, but the outbound SA and policies are already removed.  Attempting
to update them could get the refcount in the kernel interface out of sync
as the additional policy won't be removed when the CHILD_SA object is
eventually destroyed.
2018-02-22 11:38:43 +01:00
Tobias Brunner ca79bd54ff child-sa: Don't try to update outbound SA if it is not installed anymore 2018-02-22 11:38:38 +01:00
Tobias Brunner c9998e5fea child-sa: No need to find reqid of existing trap policy
When initiating a trap policy we explicitly pass the reqid along.  I guess
the lookup was useful to get the same reqid if a trapped CHILD_SA is manually
initiated.  However, we now get the same reqid anyway if there is no
narrowing.  And if the traffic selectors do get narrowed the reqid will be
different but that shouldn't be a problem as that doesn't cause an issue with
any temporary SAs in the kernel (this is why we pass the reqid to the
triggered CHILD_SA, otherwise, no new acquire would get triggered for
traffic that doesn't match the wider trap policy).
2018-02-22 11:31:05 +01:00
Tobias Brunner 35ef1b032d child-sa: Install drop policies while updating IPsec SAs and policies
If we have to remove and reinstall SAs for address updates (as with the
Linux kernel) there is a short time where there is no SA installed.  If
we keep the policies installed they (or any traps) might cause acquires
and temporary kernel states that could prevent the updated SA from
getting installed again.

This replaces the previous workaround to avoid plaintext traffic leaks
during policy updates, which used low-priority drop policies.
2018-02-09 15:53:30 +01:00
Tobias Brunner ea43f8ffe5 child-cfg: Optionally set mark on inbound SA 2017-11-02 09:59:38 +01: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 859dae255c child-sa: Suppress CHILD_SA state changes if there is no change 2017-08-07 14:22:13 +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 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 95a63bf281 Migrate all enumerators to venumerate() interface change 2017-05-26 13:56:44 +02:00
Tobias Brunner 7637633bb9 child-cfg: Optionally use 96-bit truncation for HMAC-SHA-256
The correct truncation is 128-bit but some implementations insist on
using 96-bit truncation.  With strongSwan this can be negotiated using
an algorithm identifier from a private range.  But this doesn't work
with third-party implementations.  This adds an option to use 96-bit
truncation even if the official identifier is used.
2017-05-26 11:22:27 +02:00
Tobias Brunner 0cbf75eb94 child-sa: Remove state to track installation of half the SA again 2017-05-23 18:46:49 +02:00
Tobias Brunner afbea8ce3c child-sa: Expose state of the outbound SA 2017-05-23 18:46:48 +02:00
Tobias Brunner c5fed4cdee child-sa: Add method to remove the outbound SA and policies 2017-05-23 18:46:46 +02:00
Tobias Brunner 4ba07a8652 child-sa: Keep track whether the outbound SA has been installed or not 2017-05-23 18:46:06 +02:00
Tobias Brunner f84757f2e6 child-sa: Add log message for CHILD_SA state changes 2017-05-23 18:46:06 +02:00
Tobias Brunner cad13450be child-sa: Add method to associate rekeyed CHILD_SAs with their replacement 2017-05-23 18:46:06 +02:00
Tobias Brunner 8a3a389e3d child-sa: Add methods that allow partial installation of CHILD_SA
Using install() for the inbound SA and register_outbound() for the
outbound SA followed by install_policies(), will delay the installation of
the outbound SA as well as the installation of the outbound policies
in the kernel until install_outbound() is called later.
2017-05-23 18:46:03 +02:00
Tobias Brunner 83186d3cf7 child-sa: Add new state to track installation of only the inbound SA 2017-05-23 18:41:31 +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 29ef4cf5f4 child-sa: Split in- and outbound policy de-/installation
Only install outbound fallback policies.
2017-05-23 18:41:30 +02:00
Tobias Brunner aeee0bcc30 child-sa: Optionally enable hardware offload for CHILD_SAs 2017-05-23 16:55:21 +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 1003cf2330 Fixed some typos, courtesy of codespell 2017-03-23 18:29:18 +01:00
Eyal Birger 067fd2c69c child-sa: Do not install mark on inbound kernel SA
The SA ID (src, dst, proto, spi) is unique on ingress.

As such, explicit inbound marking is not needed to match an SA.

On the other hand, requiring inbound SAs to use marks forces the
installation of a mechanism for marking traffic (e.g. iptables) based
on some criteria.

Defining the criteria becomes complicated, for example when required to
support multiple SAs from the same src, especially when traffic is UDP
encapsulated.

This commit removes the assignment of the child_sa mark_in to the inbound SA.

Policies can be arbitrated by existing means - e.g, via netfilter policy
matching or using VTI interfaces - without the need to classify the flows prior
to state matching.

Since the reqid allocator regards the mark value, there is no risk of matching
the wrong policy.

And as explicit marking was required for route-based VPN to work before this
change, it should not cause regressions in existing setups.

Closes strongswan/strongswan#59.
2017-02-14 18:34:15 +01:00
Thomas Egerer 1042b9194f child-sa: Use single return statement in update_usebytes()
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2016-11-18 11:58:14 +01:00
Tobias Brunner ad1b53454e child-sa: Only install outbound FWD policies if explicitly configured
They are only required if drop policies would otherwise prevent
forwarding traffic.  This reduces the number of policies and avoids
conflicts e.g. with SPD hash thresholds.
2016-09-28 17:56:44 +02:00
Tobias Brunner b2abd01048 child-sa: Use non-static variable to store generated unique mark
If two CHILD_SAs with mark=%unique are created concurrently they could
otherwise end up with either the same mark or different marks in both
directions.
2016-06-06 14:17:11 +02:00
Tobias Brunner 979f465113 child-sa: Install "outbound" FWD policy with lower priority
This provides a fix if symmetrically overlapping policies are
installed as e.g. the case in the ikev2/ip-two-pools-db scenario:

  carol 10.3.0.1/32 ----- 10.3.0.0/16, 10.4.0.0/16 moon
  alice 10.4.0.1/32 ----- 10.3.0.0/16, 10.4.0.0/16 moon

Among others, the following FWD policies are installed on moon:

  src 10.3.0.1/32 dst 10.4.0.0/16
    ...
    tmpl ...

  src 10.4.0.0/16 dst 10.3.0.1/32
    ...

  src 10.4.0.1/32 dst 10.3.0.0/16
    ...
    tmpl ...

  src 10.3.0.0/16 dst 10.4.0.1/32
    ...

Because the network prefixes are the same for all of these they all have the
same priority.  Due to that it depends on the install order which policy gets
used.  For instance, a packet from 10.3.0.1 to 10.4.0.1 will match the
first as well as the last policy.  However, when handling the inbound
packet we have to use the first one as the packet will otherwise be
dropped due to a template mismatch.  And we can't install templates with
the "outbound" FWD policies as that would prevent using different
IPsec modes or e.g. IPComp on only one of multiple SAs.

Instead we install the "outbound" FWD policies with a lower priority
than the "inbound" FWD policies so the latter are preferred.  But we use
a higher priority than default drop policies would use (in case they'd
be defined with the same subnets).
2016-05-06 20:27:18 +02:00
Andreas Steffen b1df631212 vici list-conns sends reauthentication and rekeying time information 2016-05-04 18:13:52 +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 9c12635252 child-sa: Install "outbound" FWD policy
If there is a DROP shunt that matches outbound forwarded traffic it
would get dropped as the FWD policy we install only matches decrypted
inbound traffic.  That's because the Linux kernel first checks the FWD
policies before looking up the OUT policy and SA to encrypt the packets.
2016-04-09 16:51:00 +02:00
Tobias Brunner 89da06ace9 kernel: Use structs to pass information to the kernel-ipsec interface 2016-04-09 16:50:59 +02:00