Commit graph

43 commits

Author SHA1 Message Date
Joel Low
f2d209e4ff strongswan: trigger reload when interfaces are specified
Fixes #20848

Add interface triggers if interfaces to listen to are specified in
`/etc/config/ipsec`. This fixes the "running with no instances" scenario
after rebooting a router.

Signed-off-by: Joel Low <joel@joelsplace.sg>
2023-12-18 10:17:09 +08:00
Tiago Gaspar
a7c7265e1b
strongswan: swanctl: add support for replay window
Add support for replay window configuration in UCI.

Signed-off-by: Tiago Gaspar <tiagogaspar8@gmail.com>
2023-11-17 09:25:36 +00:00
Philip Prindeville
7f8aea6d86 strongswan: make parsing more consistent
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2023-06-15 18:33:08 -06:00
Philip Prindeville
5f3840c765 strongswan: local_gateway unused in swanctl.init
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2023-04-22 18:20:38 -06:00
Glen Huang
d347448ffb strongswan: add support for remote cacerts
Signed-off-by: Glen Huang <me@glenhuang.com>
2023-04-10 17:16:07 +08:00
Glen Huang
08a0f7bb94 strongswan: add support for pools section
Signed-off-by: Glen Huang <me@glenhuang.com>
2023-04-10 17:16:07 +08:00
Philip Prindeville
216b6b61a8 strongswan: simplify indentation
Allow passing multiple config lines with the same indent level.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2023-03-26 13:53:59 -06:00
Philip Prindeville
03eab9b63b strongswan: Fix indent for hw_offload, interface, priority
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2023-03-26 13:53:05 -06:00
Philip Prindeville
796443267f strongswan: Fix PSK's when using multiple connections
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2022-11-08 20:07:48 -07:00
Joel Low
5c8af06c94 strongswan: support child rekey by bytes and packets
This adds support for the child SA to be rekeyed through the byte/packet
threshold. The default is blank (which disables the byte/packet thresholds).

Signed-off-by: Joel Low <joel@joelsplace.sg>
2022-05-09 19:27:17 +08:00
Philip Prindeville
d279a64df8 strongswan: add priority option
Also from Vincent Wiemann <vincent.wiemann@ironai.com>.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:45:43 -06:00
Philip Prindeville
6c79715676 strongswan: add ipcomp support
Also from Vincent Wiemann <vincent.wiemann@ironai.com>.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:34:45 -06:00
Philip Prindeville
11ff072672 strongswan: add interface option for children
This option sets the interface of the policy.

Also from Vincent Wiemann <vincent.wiemann@ironai.com>.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:31:31 -06:00
Philip Prindeville
0231e043b7 strongswan: add support for hw_offload
Also from Vincent Wiemann <vincent.wiemann@ironai.com>.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:31:31 -06:00
Philip Prindeville
0fe23b0e4a strongswan: miscellaneous cleanup of config file, etc
Use list's where appropriate for multi-value config variables.

Forbid absolute/relative paths for certificate and key files.

Get rid of last remnants of left/right naming.

Factor invariant code paths.

Drop redundant secrets.rsa.filename section.

Thanks to Vincent Wiemann <vincent.wiemann@ironai.com> for calling
out many of these improvements.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:31:31 -06:00
Philip Prindeville
09dcf7486d strongswan: rename config functions
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:31:31 -06:00
Vincent Wiemann
59732ba018 strongswan: fix PSK config generation
There were closing curly braces missing and it was checking for empty
strings while it should have been checking for non-empty strings.

Signed-off-by: Vincent Wiemann <vincent.wiemann@ironai.com>
2021-06-18 04:42:01 +02:00
Philip Prindeville
cac7608211 strongswan: use correct directory for CA's
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-17 18:53:08 -06:00
Philip Prindeville
2ccd2665cb strongswan: fix sharing of ipsec section variables
Variables set in config_ipsec() need to be shared with do_postamble()
function, so change scoping to parent (prepare_env()).

Also, remove unused settings like "remote_sourceip", "reqid", and
"packet_marker".

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-17 09:46:55 -06:00
Philip Prindeville
a783986cbc strongswan: start charon directly from swanctl
ipsec uses starter, and reads /etc/ipsec.conf (which then includes
/var/ipsec/ipsec.conf, etc). This is overly complicated, and can
be problematic if you're using both swanctl and ipsec for migration.

Running charon directly from procd via the init.d script avoid
all of this.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-02 00:23:54 -06:00
Philip Prindeville
ba79998e52 strongswan: swanctl init script doesn't load connections
Fixes issue #15446

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-05-05 11:58:34 -06:00
Philip Prindeville
9217aa859f strongswan: change name of config base directory
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-15 17:57:48 -06:00
Philip Prindeville
a3f625954a strongswan: add certificate generation utility
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-15 13:10:08 -06:00
Philip Prindeville
505db629de strongswan: add deprecation warning to ipsec script
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-14 12:27:07 -06:00
Philip Prindeville
ff33f4ccd3 strongswan: handle chacha20poly1305 as AEAD
chacha20policy1305 is also an AEAD cipher, and hence does not
permit a hash algorithm.

Fixes issue #15397.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-13 12:46:07 -06:00
Philip Prindeville
c95fd69973 strongswan: fail on serious configuration errors
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-13 12:46:07 -06:00
Philip Prindeville
210640d606 strongswan: drop subshell when possible
A subshell caused by $(...) can't persistently modify globals as a
side-effect.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-13 12:45:57 -06:00
Philip Prindeville
f9d91f1f47 strongswan: migrate to swanctl configs
Derived from the ipsec initd script, with the following changes:

(1) various code improvements, corrections (get rid of left/right
    updown scripts, since there's only one), etc;
(2) add reauth and fragmentation parameters;
(3) add x.509 certificate-based authentication;

and other minor changes.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-04 11:58:51 -06:00
Philip Prindeville
baa38a1420 strongswan: remove synthesized ipsec conf files
If you shutdown ipsec service, and it doesn't clean up
/var/ipsec/ipsec.conf, then when you start swanctl service it
might see an incompatible file on startup.  Remedy is to
remove unneeded files when shutting down the service.  They
can always be regenerated when the service starts again.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-01 15:06:00 -06:00
Philip Prindeville
643df01275 strongswan: make the include's in the .conf files persistent
Having scripts diddle user written config files seems potentially
dangerous.  Plus there's really no downside to including some
empty files.  Best to just make the includes be permanent.

Additional feature suggested by Luiz: if a -opkg version of the
config file was created unnecessarily, remove it as part of the
upgrade process since changes won't be happening to that file
as an artifact of the service starting.  The include lines are
now permanent, which means that (1) additional configuration
synthesized by UCI won't be anywhere that opkg (or sysupgrade,
for that matter) cares about since it won't be persistent, and
(2) if changes are being made, then they're being done by a
person with an editor and they really should be distinguished.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-03-26 14:29:32 -06:00
Philip Prindeville
ec72d3a9e4 strongswan: fix local_gateway discovery
This has been observed by myself and @luizluca: ip route get is
appending uid0 to the output, as seen from:

root@OpenWrt2:~# ip route get 1.1.1.1
1.1.1.1 via 174.27.160.1 dev eth3 src 174.27.182.184 uid 0
    cache
root@OpenWrt2:~#

so the fix is an anchored match, discarding all else. Also, using
ip -o means never having to do multiline matches...

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-02-16 13:32:26 -07:00
Philip Prindeville
9ddc502872 strongswan: avoid duplicate logging
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-02-05 22:10:29 -07:00
Michael C. Bazarewsky
51214e191f strongswan: add left and mark configuration to UCI
This commit allows for UCI configuration of the "left=" and the
"mark=" values in a StrongSwan IPSec connection.  This improves
VTI support and allows certain stricter connection scenarios.

Signed-off-by: Michael C. Bazarewsky <github@bazstuff.com>
2020-08-27 16:06:34 -04:00
Paul Fertser
a8fa557cd5 strongswan: allow to specify per-connection reqid with UCI
This is useful to assign all traffic to a fw3 zone, e.g.:

/etc/config/ipsec:

config remote 'test'
	list tunnel		'dev'
...

config 'tunnel' 'dev'
	option reqid		'33'
...

/etc/config/firewall:

config zone
	option name		wan
	option extra_src	"-m policy --pol none --dir in"
	option extra_dest	"-m policy --pol none --dir out"
...

config zone
	option name		vpn
	# subnet needed for firewall3 before 22 Nov 2019, 8174814a
	list subnet		'0.0.0.0/0'
	option extra_src	"-m policy --pol ipsec --dir in --reqid 33"
	option extra_dest	"-m policy --pol ipsec --dir out --reqid 33"
...

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
2019-11-26 15:27:54 +03:00
Florian Eckert
6cd8fcabe6 strongswan: add openwrt hotplug script handling
Ipsec user script (/etc/ipsec.user) now get called indirectly by openwrt
"/sbin/hotplug-call". So other packages could also install their scripts
in "/etc/hotplug.d/ipsec".

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-07-16 11:34:57 +02:00
Hans Dedecker
74dbf6bcbe strongswan: add interface uci list
The interface config option allows users to configure logical OpenWRT
interface names in the ipsec section; it allows StrongSwan to listen
and send traffic on specified interface(s). It translates to interfaces_use
StrongSwan option which is a comma sepearted list of network devices
that should be used by charon.
Since StrongSwan can only be started when one of the specified logical
OpenWRT interface is up procd interface triggers are installed to
trigger the reload script.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-12-13 18:46:37 +01:00
Hans Dedecker
1d31d840d4 strongswan: fix reload service
Based on the ipsec running state reload_service is either reloading ipsec
or starting ipsec. However in the latter case it calls ipsec start which
bypasses the procd start_service function which means the running ipsec
instance is not managed by procd.
Fix this by calling start in case ipsec is not running; at the same time
add service_running function which is used by procd provided running
function.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-12-13 10:49:55 +01:00
Stijn Tintel
ba1ead54f0 strongswan: use -eq when testing booleans
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2017-08-07 20:19:18 +02:00
Stijn Tintel
6f00048eca strongswan: convert init script to procd
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2017-08-07 20:19:18 +02:00
Stijn Tintel
b93a53bd94 strongswan: check return value instead of output
When the strongswan service is running, `ipsec status` returns 0. Check
the return value instead of checking its output.

While at it, remove the [[ ]] bashism, use rereadall instead of
(reread)secrets, and move it inside the if statement.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2017-08-07 20:19:18 +02:00
Stijn Tintel
44ef6048e2 strongswan: remove checks for UCI config
In commit 36e073d820, some checks were
added to see if the UCI config file exists and if there are any peers
configured in it. Due to these checks, if /etc/config/ipsec exists, but
contains no enabled peers, strongswan will not be started. This is not
ideal, as a user might want to experiment with the UCI config while
keeping existing connections in /etc/ipsec.conf operational.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2017-08-07 20:19:18 +02:00
Hans Dedecker
36e073d820 strongswan: uci config support
Add support to configure strongswan via uci.

uci support is based on the following sections
-ipsec : Global config items belonging in the strongswan.conf file
-remote : Defines the remote peer(s)
-tunnel : Defines the IPSec connections in tunnel mode
-transport : Defines the IPSec connections in transport mode
-crypto_proposal : Defines the different crypto proposals

Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
Signed-off-by: Gino Peeters <peeters.gino@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-01-06 13:32:13 +01:00
Steven Barth
bd52d64fdb strongswan: import, update, adopt
Signed-off-by: Steven Barth <steven@midlink.org>
2014-08-17 10:11:02 +02:00