Compare commits
2 Commits
00883c0a68
...
c1acb2cc40
| Author | SHA1 | Date | |
|---|---|---|---|
| c1acb2cc40 | |||
| e51251d0e8 |
@@ -1,4 +1,4 @@
|
||||
From 1baf500104e963e0d0d410c95e7dcec899173b77 Mon Sep 17 00:00:00 2001
|
||||
From 8ca99fb0a9d0027d08937bc2b198dc74bd5bb7a2 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zoran=20Peri=C4=8Di=C4=87?= <zpericic@netst.org>
|
||||
Date: Tue, 9 Jul 2024 19:07:57 +0200
|
||||
Subject: [PATCH 1/4] charon: add optional source and remote overrides for
|
||||
@@ -11,17 +11,17 @@ to initiate wildcard connection for known address via vici.
|
||||
In addition this allows simpler implementation of trap-any patches
|
||||
and is a prerequisite for dmvpn support.
|
||||
---
|
||||
src/libcharon/control/controller.c | 34 ++++++++++++++++--
|
||||
src/libcharon/control/controller.h | 28 +++++++++++++++
|
||||
src/libcharon/plugins/vici/vici_control.c | 41 +++++++++++++++++----
|
||||
src/libcharon/sa/ike_sa_manager.c | 34 +++++++++++++++++-
|
||||
src/libcharon/sa/ike_sa_manager.h | 25 ++++++++++++-
|
||||
src/libcharon/sa/trap_manager.c | 44 +++++++++--------------
|
||||
src/libcharon/control/controller.c | 36 +++++++++++++++++-
|
||||
src/libcharon/control/controller.h | 28 ++++++++++++++
|
||||
src/libcharon/plugins/vici/vici_control.c | 41 ++++++++++++++++----
|
||||
src/libcharon/sa/ike_sa_manager.c | 34 ++++++++++++++++-
|
||||
src/libcharon/sa/ike_sa_manager.h | 25 +++++++++++-
|
||||
src/libcharon/sa/trap_manager.c | 46 +++++++++--------------
|
||||
src/swanctl/commands/initiate.c | 19 +++++++++-
|
||||
7 files changed, 186 insertions(+), 39 deletions(-)
|
||||
7 files changed, 189 insertions(+), 40 deletions(-)
|
||||
|
||||
diff --git a/src/libcharon/control/controller.c b/src/libcharon/control/controller.c
|
||||
index 027f48e93..26501768d 100644
|
||||
index 4e778ed63d..2b8a75e2c1 100644
|
||||
--- a/src/libcharon/control/controller.c
|
||||
+++ b/src/libcharon/control/controller.c
|
||||
@@ -1,4 +1,6 @@
|
||||
@@ -48,31 +48,32 @@ index 027f48e93..26501768d 100644
|
||||
/**
|
||||
* unique ID, used for various methods
|
||||
*/
|
||||
@@ -417,10 +429,16 @@ METHOD(job_t, initiate_execute, job_requeue_t,
|
||||
@@ -418,9 +430,17 @@ METHOD(job_t, initiate_execute, job_requeue_t,
|
||||
{
|
||||
ike_sa_t *ike_sa;
|
||||
interface_listener_t *listener = &job->listener;
|
||||
peer_cfg_t *peer_cfg = listener->peer_cfg;
|
||||
+ peer_cfg_t *peer_cfg = listener->peer_cfg;
|
||||
+ host_t *my_host = listener->my_host;
|
||||
+ host_t *other_host = listener->other_host;
|
||||
|
||||
- ike_sa = charon->ike_sa_manager->checkout_by_config(charon->ike_sa_manager,
|
||||
- peer_cfg);
|
||||
+
|
||||
+ ike_sa = charon->ike_sa_manager->checkout_by_config2(charon->ike_sa_manager,
|
||||
+ peer_cfg, my_host, other_host);
|
||||
peer_cfg->destroy(peer_cfg);
|
||||
+ peer_cfg->destroy(peer_cfg);
|
||||
+
|
||||
+ if (my_host) my_host->destroy(my_host);
|
||||
+ if (other_host) other_host->destroy(other_host);
|
||||
+
|
||||
|
||||
- ike_sa = charon->ike_sa_manager->checkout_by_config(charon->ike_sa_manager,
|
||||
- listener->peer_cfg);
|
||||
if (!ike_sa)
|
||||
{
|
||||
DESTROY_IF(listener->child_cfg);
|
||||
@@ -501,6 +519,15 @@ METHOD(controller_t, initiate, status_t,
|
||||
listener->status = FAILED;
|
||||
@@ -502,6 +522,15 @@ METHOD(controller_t, initiate, status_t,
|
||||
private_controller_t *this, peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
|
||||
controller_cb_t callback, void *param, level_t max_level, u_int timeout,
|
||||
bool limits)
|
||||
+{
|
||||
+ return this->public.initiate2(this, peer_cfg, child_cfg, NULL, NULL, callback, param, max_level, timeout, limits);
|
||||
+ return this->public.initiate2(&this->public, peer_cfg, child_cfg, NULL, NULL, callback, param, max_level, timeout, limits);
|
||||
+}
|
||||
+
|
||||
+METHOD(controller_t, initiate2, status_t,
|
||||
@@ -83,7 +84,7 @@ index 027f48e93..26501768d 100644
|
||||
{
|
||||
interface_job_t *job;
|
||||
status_t status;
|
||||
@@ -523,6 +550,8 @@ METHOD(controller_t, initiate, status_t,
|
||||
@@ -524,6 +553,8 @@ METHOD(controller_t, initiate, status_t,
|
||||
.status = FAILED,
|
||||
.child_cfg = child_cfg,
|
||||
.peer_cfg = peer_cfg,
|
||||
@@ -92,7 +93,7 @@ index 027f48e93..26501768d 100644
|
||||
.lock = spinlock_create(),
|
||||
.options.limits = limits,
|
||||
},
|
||||
@@ -770,6 +799,7 @@ controller_t *controller_create(void)
|
||||
@@ -771,6 +802,7 @@ controller_t *controller_create(void)
|
||||
.public = {
|
||||
.create_ike_sa_enumerator = _create_ike_sa_enumerator,
|
||||
.initiate = _initiate,
|
||||
@@ -101,7 +102,7 @@ index 027f48e93..26501768d 100644
|
||||
.terminate_child = _terminate_child,
|
||||
.destroy = _destroy,
|
||||
diff --git a/src/libcharon/control/controller.h b/src/libcharon/control/controller.h
|
||||
index 36a1d4631..f5c60e2e7 100644
|
||||
index 36a1d46317..f5c60e2e72 100644
|
||||
--- a/src/libcharon/control/controller.h
|
||||
+++ b/src/libcharon/control/controller.h
|
||||
@@ -98,6 +98,34 @@ struct controller_t {
|
||||
@@ -140,7 +141,7 @@ index 36a1d4631..f5c60e2e7 100644
|
||||
* Terminate an IKE_SA and all of its CHILD_SAs.
|
||||
*
|
||||
diff --git a/src/libcharon/plugins/vici/vici_control.c b/src/libcharon/plugins/vici/vici_control.c
|
||||
index 1c236d249..932d0cb5a 100644
|
||||
index 1c236d2491..932d0cb5a8 100644
|
||||
--- a/src/libcharon/plugins/vici/vici_control.c
|
||||
+++ b/src/libcharon/plugins/vici/vici_control.c
|
||||
@@ -1,4 +1,6 @@
|
||||
@@ -229,22 +230,23 @@ index 1c236d249..932d0cb5a 100644
|
||||
|
||||
/**
|
||||
diff --git a/src/libcharon/sa/ike_sa_manager.c b/src/libcharon/sa/ike_sa_manager.c
|
||||
index 7763ae844..59852f253 100644
|
||||
index c128cc0787..bf4e125c84 100644
|
||||
--- a/src/libcharon/sa/ike_sa_manager.c
|
||||
+++ b/src/libcharon/sa/ike_sa_manager.c
|
||||
@@ -1,4 +1,6 @@
|
||||
@@ -1,5 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2024 Tobias Brunner
|
||||
+ * Copyright (C) 2023 Zoran Peričić <zpericic@netst.org>
|
||||
+ * Copyright (C) 2014 Timo Teräs <timo.teras@iki.fi>
|
||||
* Copyright (C) 2008-2022 Tobias Brunner
|
||||
* Copyright (C) 2005-2011 Martin Willi
|
||||
* Copyright (C) 2005 Jan Hutter
|
||||
@@ -1499,6 +1501,13 @@ typedef struct {
|
||||
*
|
||||
@@ -1500,6 +1502,13 @@ typedef struct {
|
||||
|
||||
METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
|
||||
private_ike_sa_manager_t *this, peer_cfg_t *peer_cfg)
|
||||
+{
|
||||
+ return this->public.checkout_by_config2(this, peer_cfg, NULL, NULL);
|
||||
+ return this->public.checkout_by_config2(&this->public, peer_cfg, NULL, NULL);
|
||||
+}
|
||||
+
|
||||
+METHOD(ike_sa_manager_t, checkout_by_config2, ike_sa_t*,
|
||||
@@ -253,7 +255,7 @@ index 7763ae844..59852f253 100644
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry;
|
||||
@@ -1509,7 +1518,16 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
|
||||
@@ -1510,7 +1519,16 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
|
||||
u_int segment;
|
||||
int i;
|
||||
|
||||
@@ -271,7 +273,7 @@ index 7763ae844..59852f253 100644
|
||||
|
||||
if (!this->reuse_ikesa && peer_cfg->get_ike_version(peer_cfg) != IKEV1)
|
||||
{ /* IKE_SA reuse disabled by config (not possible for IKEv1) */
|
||||
@@ -1567,6 +1585,15 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
|
||||
@@ -1569,6 +1587,15 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -287,7 +289,7 @@ index 7763ae844..59852f253 100644
|
||||
current_peer = entry->ike_sa->get_peer_cfg(entry->ike_sa);
|
||||
if (current_peer && current_peer->equals(current_peer, peer_cfg))
|
||||
{
|
||||
@@ -1593,6 +1620,10 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
|
||||
@@ -1595,6 +1622,10 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
|
||||
{
|
||||
ike_sa->set_peer_cfg(ike_sa, peer_cfg);
|
||||
checkout_new(this, ike_sa);
|
||||
@@ -298,16 +300,16 @@ index 7763ae844..59852f253 100644
|
||||
}
|
||||
}
|
||||
charon->bus->set_sa(charon->bus, ike_sa);
|
||||
@@ -2558,6 +2589,7 @@ ike_sa_manager_t *ike_sa_manager_create()
|
||||
@@ -2560,6 +2591,7 @@ ike_sa_manager_t *ike_sa_manager_create()
|
||||
.checkout = _checkout,
|
||||
.checkout_by_message = _checkout_by_message,
|
||||
.checkout_by_config = _checkout_by_config,
|
||||
+ .checkout_by_config2 = _checkout_by_config,
|
||||
+ .checkout_by_config2 = _checkout_by_config2,
|
||||
.checkout_by_id = _checkout_by_id,
|
||||
.checkout_by_name = _checkout_by_name,
|
||||
.new_initiator_spi = _new_initiator_spi,
|
||||
diff --git a/src/libcharon/sa/ike_sa_manager.h b/src/libcharon/sa/ike_sa_manager.h
|
||||
index 004cc2216..d001f5a80 100644
|
||||
index 004cc22168..d001f5a802 100644
|
||||
--- a/src/libcharon/sa/ike_sa_manager.h
|
||||
+++ b/src/libcharon/sa/ike_sa_manager.h
|
||||
@@ -123,7 +123,8 @@ struct ike_sa_manager_t {
|
||||
@@ -350,19 +352,22 @@ index 004cc2216..d001f5a80 100644
|
||||
* Reset initiator SPI.
|
||||
*
|
||||
diff --git a/src/libcharon/sa/trap_manager.c b/src/libcharon/sa/trap_manager.c
|
||||
index 1b85c66a5..bbc480c0c 100644
|
||||
index 17953010a1..c316eea213 100644
|
||||
--- a/src/libcharon/sa/trap_manager.c
|
||||
+++ b/src/libcharon/sa/trap_manager.c
|
||||
@@ -523,7 +523,7 @@ METHOD(trap_manager_t, acquire, void,
|
||||
@@ -532,9 +532,9 @@ METHOD(trap_manager_t, acquire, void,
|
||||
peer_cfg_t *peer;
|
||||
child_cfg_t *child;
|
||||
ike_sa_t *ike_sa;
|
||||
- host_t *host;
|
||||
+ host_t *host, *my_host = NULL, *other_host = NULL;
|
||||
uint32_t allocated_reqid;
|
||||
bool wildcard, ignore = FALSE;
|
||||
- host_t *host = NULL;
|
||||
+ host_t *host = NULL, *my_host = NULL, *other_host = NULL;
|
||||
uint32_t allocated_reqid, seq = 0;
|
||||
- bool wildcard;
|
||||
+ bool wildcard, ignore = FALSE;
|
||||
|
||||
@@ -603,36 +603,26 @@ METHOD(trap_manager_t, acquire, void,
|
||||
this->lock->read_lock(this->lock);
|
||||
enumerator = this->traps->create_enumerator(this->traps);
|
||||
@@ -609,36 +609,26 @@ METHOD(trap_manager_t, acquire, void,
|
||||
this->lock->unlock(this->lock);
|
||||
|
||||
if (wildcard)
|
||||
@@ -416,7 +421,7 @@ index 1b85c66a5..bbc480c0c 100644
|
||||
|
||||
if (ike_sa)
|
||||
diff --git a/src/swanctl/commands/initiate.c b/src/swanctl/commands/initiate.c
|
||||
index e0fffb907..c0fc8c595 100644
|
||||
index e0fffb907d..c0fc8c5952 100644
|
||||
--- a/src/swanctl/commands/initiate.c
|
||||
+++ b/src/swanctl/commands/initiate.c
|
||||
@@ -1,4 +1,5 @@
|
||||
@@ -472,5 +477,5 @@ index e0fffb907..c0fc8c595 100644
|
||||
{"raw", 'r', 0, "dump raw response message"},
|
||||
{"pretty", 'P', 0, "dump raw response message in pretty print"},
|
||||
--
|
||||
2.45.2
|
||||
2.51.0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From ea77f7d906d5e7bbe44ba6e912dd386f25414492 Mon Sep 17 00:00:00 2001
|
||||
From 59e1a0469bbd50704f777835c0fcd7013f7841c7 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
|
||||
Date: Mon, 21 Sep 2015 13:42:05 +0300
|
||||
Subject: [PATCH 2/4] vici: send certificates for ike-sa events
|
||||
@@ -12,10 +12,10 @@ Signed-off-by: Timo Teräs <timo.teras@iki.fi>
|
||||
1 file changed, 42 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/libcharon/plugins/vici/vici_query.c b/src/libcharon/plugins/vici/vici_query.c
|
||||
index bacb7b101..19acc0789 100644
|
||||
index 43e3f44137..5e49cb8a0b 100644
|
||||
--- a/src/libcharon/plugins/vici/vici_query.c
|
||||
+++ b/src/libcharon/plugins/vici/vici_query.c
|
||||
@@ -402,7 +402,7 @@ static void list_vips(private_vici_query_t *this, vici_builder_t *b,
|
||||
@@ -433,7 +433,7 @@ static void list_vips(private_vici_query_t *this, vici_builder_t *b,
|
||||
* List details of an IKE_SA
|
||||
*/
|
||||
static void list_ike(private_vici_query_t *this, vici_builder_t *b,
|
||||
@@ -24,7 +24,7 @@ index bacb7b101..19acc0789 100644
|
||||
{
|
||||
time_t t;
|
||||
ike_sa_id_t *id;
|
||||
@@ -411,6 +411,8 @@ static void list_ike(private_vici_query_t *this, vici_builder_t *b,
|
||||
@@ -442,6 +442,8 @@ static void list_ike(private_vici_query_t *this, vici_builder_t *b,
|
||||
uint32_t if_id;
|
||||
uint16_t alg, ks;
|
||||
host_t *host;
|
||||
@@ -33,7 +33,7 @@ index bacb7b101..19acc0789 100644
|
||||
|
||||
b->add_kv(b, "uniqueid", "%u", ike_sa->get_unique_id(ike_sa));
|
||||
b->add_kv(b, "version", "%u", ike_sa->get_version(ike_sa));
|
||||
@@ -420,11 +422,43 @@ static void list_ike(private_vici_query_t *this, vici_builder_t *b,
|
||||
@@ -451,11 +453,43 @@ static void list_ike(private_vici_query_t *this, vici_builder_t *b,
|
||||
b->add_kv(b, "local-host", "%H", host);
|
||||
b->add_kv(b, "local-port", "%d", host->get_port(host));
|
||||
b->add_kv(b, "local-id", "%Y", ike_sa->get_my_id(ike_sa));
|
||||
@@ -77,7 +77,7 @@ index bacb7b101..19acc0789 100644
|
||||
|
||||
eap = ike_sa->get_other_eap_id(ike_sa);
|
||||
|
||||
@@ -556,7 +590,7 @@ CALLBACK(list_sas, vici_message_t*,
|
||||
@@ -588,7 +622,7 @@ CALLBACK(list_sas, vici_message_t*,
|
||||
b = vici_builder_create();
|
||||
b->begin_section(b, ike_sa->get_name(ike_sa));
|
||||
|
||||
@@ -86,7 +86,7 @@ index bacb7b101..19acc0789 100644
|
||||
|
||||
b->begin_section(b, "child-sas");
|
||||
csas = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||
@@ -1774,7 +1808,7 @@ METHOD(listener_t, ike_updown, bool,
|
||||
@@ -1805,7 +1839,7 @@ METHOD(listener_t, ike_updown, bool,
|
||||
}
|
||||
|
||||
b->begin_section(b, ike_sa->get_name(ike_sa));
|
||||
@@ -95,7 +95,7 @@ index bacb7b101..19acc0789 100644
|
||||
b->end_section(b);
|
||||
|
||||
this->dispatcher->raise_event(this->dispatcher,
|
||||
@@ -1799,10 +1833,10 @@ METHOD(listener_t, ike_rekey, bool,
|
||||
@@ -1830,10 +1864,10 @@ METHOD(listener_t, ike_rekey, bool,
|
||||
b = vici_builder_create();
|
||||
b->begin_section(b, old->get_name(old));
|
||||
b->begin_section(b, "old");
|
||||
@@ -108,7 +108,7 @@ index bacb7b101..19acc0789 100644
|
||||
b->end_section(b);
|
||||
b->end_section(b);
|
||||
|
||||
@@ -1833,7 +1867,7 @@ METHOD(listener_t, ike_update, bool,
|
||||
@@ -1864,7 +1898,7 @@ METHOD(listener_t, ike_update, bool,
|
||||
b->add_kv(b, "remote-port", "%d", remote->get_port(remote));
|
||||
|
||||
b->begin_section(b, ike_sa->get_name(ike_sa));
|
||||
@@ -117,7 +117,7 @@ index bacb7b101..19acc0789 100644
|
||||
b->end_section(b);
|
||||
|
||||
this->dispatcher->raise_event(this->dispatcher,
|
||||
@@ -1863,7 +1897,7 @@ METHOD(listener_t, child_updown, bool,
|
||||
@@ -1894,7 +1928,7 @@ METHOD(listener_t, child_updown, bool,
|
||||
}
|
||||
|
||||
b->begin_section(b, ike_sa->get_name(ike_sa));
|
||||
@@ -126,7 +126,7 @@ index bacb7b101..19acc0789 100644
|
||||
b->begin_section(b, "child-sas");
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s-%u", child_sa->get_name(child_sa),
|
||||
@@ -1898,7 +1932,7 @@ METHOD(listener_t, child_rekey, bool,
|
||||
@@ -1929,7 +1963,7 @@ METHOD(listener_t, child_rekey, bool,
|
||||
b = vici_builder_create();
|
||||
|
||||
b->begin_section(b, ike_sa->get_name(ike_sa));
|
||||
@@ -136,5 +136,5 @@ index bacb7b101..19acc0789 100644
|
||||
|
||||
b->begin_section(b, old->get_name(old));
|
||||
--
|
||||
2.45.2
|
||||
2.51.0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From 3f4e26a2163bf30481887795f9faad208bfc1be0 Mon Sep 17 00:00:00 2001
|
||||
From 17118385d600eeb9814af4106b690c8e2b285971 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
|
||||
Date: Mon, 21 Sep 2015 13:42:11 +0300
|
||||
Subject: [PATCH 3/4] vici: add support for individual sa state changes
|
||||
@@ -14,10 +14,10 @@ Signed-off-by: Timo Teräs <timo.teras@iki.fi>
|
||||
1 file changed, 106 insertions(+)
|
||||
|
||||
diff --git a/src/libcharon/plugins/vici/vici_query.c b/src/libcharon/plugins/vici/vici_query.c
|
||||
index 19acc0789..fa1aca953 100644
|
||||
index 5e49cb8a0b..1115161f6b 100644
|
||||
--- a/src/libcharon/plugins/vici/vici_query.c
|
||||
+++ b/src/libcharon/plugins/vici/vici_query.c
|
||||
@@ -1774,8 +1774,16 @@ static void manage_commands(private_vici_query_t *this, bool reg)
|
||||
@@ -1805,8 +1805,16 @@ static void manage_commands(private_vici_query_t *this, bool reg)
|
||||
this->dispatcher->manage_event(this->dispatcher, "ike-updown", reg);
|
||||
this->dispatcher->manage_event(this->dispatcher, "ike-rekey", reg);
|
||||
this->dispatcher->manage_event(this->dispatcher, "ike-update", reg);
|
||||
@@ -34,7 +34,7 @@ index 19acc0789..fa1aca953 100644
|
||||
manage_command(this, "list-sas", list_sas, reg);
|
||||
manage_command(this, "list-policies", list_policies, reg);
|
||||
manage_command(this, "list-conns", list_conns, reg);
|
||||
@@ -1876,6 +1884,46 @@ METHOD(listener_t, ike_update, bool,
|
||||
@@ -1907,6 +1915,46 @@ METHOD(listener_t, ike_update, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ index 19acc0789..fa1aca953 100644
|
||||
METHOD(listener_t, child_updown, bool,
|
||||
private_vici_query_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa, bool up)
|
||||
{
|
||||
@@ -1955,6 +2003,62 @@ METHOD(listener_t, child_rekey, bool,
|
||||
@@ -1986,6 +2034,62 @@ METHOD(listener_t, child_rekey, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ index 19acc0789..fa1aca953 100644
|
||||
METHOD(vici_query_t, destroy, void,
|
||||
private_vici_query_t *this)
|
||||
{
|
||||
@@ -1975,8 +2079,10 @@ vici_query_t *vici_query_create(vici_dispatcher_t *dispatcher)
|
||||
@@ -2006,8 +2110,10 @@ vici_query_t *vici_query_create(vici_dispatcher_t *dispatcher)
|
||||
.ike_updown = _ike_updown,
|
||||
.ike_rekey = _ike_rekey,
|
||||
.ike_update = _ike_update,
|
||||
@@ -156,5 +156,5 @@ index 19acc0789..fa1aca953 100644
|
||||
.destroy = _destroy,
|
||||
},
|
||||
--
|
||||
2.45.2
|
||||
2.51.0
|
||||
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
From 0ceda5a95355bb803cbcdf3eeabbcb6ec2577922 Mon Sep 17 00:00:00 2001
|
||||
From 30238c949e7c1ba2df4f8adfaefdc205f7ddb98f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zoran=20Peri=C4=8Di=C4=87?= <zoran.pericic@infomaas.com>
|
||||
Date: Sun, 21 Jan 2024 03:11:32 +0100
|
||||
Subject: [PATCH 4/4] Support GRE key in selectors.
|
||||
Subject: [PATCH 4/4] Support GRE key in selectors with kernel-netlink.
|
||||
|
||||
Implementation use two 2-byte port fields (from/to range) to store key
|
||||
similar to ICMP.
|
||||
---
|
||||
.../kernel_netlink/kernel_netlink_ipsec.c | 20 ++++++++++++
|
||||
.../plugins/load_tester/load_tester_config.c | 22 ++++++++++++-
|
||||
src/libcharon/plugins/stroke/stroke_config.c | 22 ++++++++++++-
|
||||
src/libcharon/plugins/vici/vici_config.c | 32 ++++++++++++++++++-
|
||||
.../selectors/traffic_selector.c | 20 ++++++++++++
|
||||
.../selectors/traffic_selector.h | 12 +++++++
|
||||
src/starter/confread.c | 24 +++++++++++++-
|
||||
src/swanctl/swanctl.opt | 3 ++
|
||||
8 files changed, 151 insertions(+), 4 deletions(-)
|
||||
.../kernel_netlink/kernel_netlink_ipsec.c | 19 +++++++++++++
|
||||
.../plugins/load_tester/load_tester_config.c | 22 ++++++++++++++-
|
||||
src/libcharon/plugins/stroke/stroke_config.c | 22 ++++++++++++++-
|
||||
src/libcharon/plugins/vici/vici_config.c | 27 ++++++++++++++++++-
|
||||
.../selectors/traffic_selector.c | 20 ++++++++++++++
|
||||
.../selectors/traffic_selector.h | 12 +++++++++
|
||||
src/starter/confread.c | 24 ++++++++++++++++-
|
||||
src/swanctl/swanctl.opt | 3 +++
|
||||
8 files changed, 145 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c b/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c
|
||||
index db0b2ac37..e4e7d9ecb 100644
|
||||
index d951aa0737..dd279c24aa 100644
|
||||
--- a/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c
|
||||
+++ b/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c
|
||||
@@ -864,6 +864,7 @@ static struct xfrm_selector ts2selector(traffic_selector_t *src,
|
||||
@@ -893,6 +893,7 @@ static struct xfrm_selector ts2selector(traffic_selector_t *src,
|
||||
{
|
||||
struct xfrm_selector sel;
|
||||
uint16_t port;
|
||||
@@ -26,7 +28,7 @@ index db0b2ac37..e4e7d9ecb 100644
|
||||
|
||||
memset(&sel, 0, sizeof(sel));
|
||||
sel.family = (src->get_type(src) == TS_IPV4_ADDR_RANGE) ? AF_INET : AF_INET6;
|
||||
@@ -884,6 +885,25 @@ static struct xfrm_selector ts2selector(traffic_selector_t *src,
|
||||
@@ -913,6 +914,24 @@ static struct xfrm_selector ts2selector(traffic_selector_t *src,
|
||||
sel.dport = htons(traffic_selector_icmp_code(port));
|
||||
sel.dport_mask = sel.dport ? ~0 : 0;
|
||||
}
|
||||
@@ -37,7 +39,6 @@ index db0b2ac37..e4e7d9ecb 100644
|
||||
+ gre_key = htons(traffic_selector_gre_key(dst->get_from_port(dst), dst->get_to_port(dst)));
|
||||
+ if ( gre_key != 0 )
|
||||
+ {
|
||||
+ DBG2(DBG_KNL, "Policy GRE key: %d (%d-%d) %d", gre_key, dst->get_from_port(dst), dst->get_to_port(dst), traffic_selector_gre_key(dst->get_from_port(dst), dst->get_to_port(dst)));
|
||||
+ sel.sport = gre_key >> 16;
|
||||
+ sel.sport_mask = ~0;
|
||||
+ sel.dport = gre_key & 0xffff;
|
||||
@@ -53,10 +54,10 @@ index db0b2ac37..e4e7d9ecb 100644
|
||||
sel.user = 0;
|
||||
|
||||
diff --git a/src/libcharon/plugins/load_tester/load_tester_config.c b/src/libcharon/plugins/load_tester/load_tester_config.c
|
||||
index 58e1cd98a..ac67875d8 100644
|
||||
index 2a440aa630..bc9a1e40b9 100644
|
||||
--- a/src/libcharon/plugins/load_tester/load_tester_config.c
|
||||
+++ b/src/libcharon/plugins/load_tester/load_tester_config.c
|
||||
@@ -498,7 +498,27 @@ static bool parse_protoport(char *token, uint16_t *from_port,
|
||||
@@ -507,7 +507,27 @@ static bool parse_protoport(char *token, uint16_t *from_port,
|
||||
*protocol = (uint8_t)p;
|
||||
}
|
||||
}
|
||||
@@ -70,15 +71,15 @@ index 58e1cd98a..ac67875d8 100644
|
||||
+ {
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ end->from_port = (p >> 16) & 0xffff;
|
||||
+ end->to_port = p & 0xffff;
|
||||
+ *from_port = (p >> 16) & 0xffff;
|
||||
+ *to_port = p & 0xffff;
|
||||
+ if (*endptr)
|
||||
+ {
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ } else {
|
||||
+ end->from_port = 0;
|
||||
+ end->to_port = 0;
|
||||
+ *from_port = 0;
|
||||
+ *to_port = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ else if (streq(port, "%any"))
|
||||
@@ -86,10 +87,10 @@ index 58e1cd98a..ac67875d8 100644
|
||||
*from_port = 0;
|
||||
*to_port = 0xffff;
|
||||
diff --git a/src/libcharon/plugins/stroke/stroke_config.c b/src/libcharon/plugins/stroke/stroke_config.c
|
||||
index 55db379ff..b4340b8d1 100644
|
||||
index b6e700fa9c..017e6b4766 100644
|
||||
--- a/src/libcharon/plugins/stroke/stroke_config.c
|
||||
+++ b/src/libcharon/plugins/stroke/stroke_config.c
|
||||
@@ -927,7 +927,27 @@ static bool parse_protoport(char *token, uint16_t *from_port,
|
||||
@@ -926,7 +926,27 @@ static bool parse_protoport(char *token, uint16_t *from_port,
|
||||
*protocol = (uint8_t)p;
|
||||
}
|
||||
}
|
||||
@@ -119,10 +120,10 @@ index 55db379ff..b4340b8d1 100644
|
||||
*from_port = 0;
|
||||
*to_port = 0xffff;
|
||||
diff --git a/src/libcharon/plugins/vici/vici_config.c b/src/libcharon/plugins/vici/vici_config.c
|
||||
index c858e9945..c72c97f76 100644
|
||||
index 6ea239f0a1..96c2d1276e 100644
|
||||
--- a/src/libcharon/plugins/vici/vici_config.c
|
||||
+++ b/src/libcharon/plugins/vici/vici_config.c
|
||||
@@ -715,7 +715,31 @@ CALLBACK(parse_ts, bool,
|
||||
@@ -749,7 +749,27 @@ CALLBACK(parse_ts, bool,
|
||||
proto = (uint8_t)p;
|
||||
}
|
||||
}
|
||||
@@ -131,19 +132,15 @@ index c858e9945..c72c97f76 100644
|
||||
+ {
|
||||
+ if (*port && !streq(port, "any"))
|
||||
+ {
|
||||
+ DBG2(DBG_CFG, " GRE key %s", port);
|
||||
+ p = strtol(port, &end, 0);
|
||||
+ if (p < 0 || p > 0xffffffff)
|
||||
+ {
|
||||
+ DBG2(DBG_CFG, " Invalid GRE key %s", port);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ from = (p >> 16) & 0xffff;
|
||||
+ to = p & 0xffff;
|
||||
+ DBG2(DBG_CFG, " Parsed GRE key %d-%d(%d)", from, to, p);
|
||||
+ if (*end)
|
||||
+ {
|
||||
+ DBG2(DBG_CFG, " Invalid GRE key %s", port);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ } else {
|
||||
@@ -155,7 +152,7 @@ index c858e9945..c72c97f76 100644
|
||||
{
|
||||
from = 0xffff;
|
||||
to = 0;
|
||||
@@ -752,8 +776,14 @@ CALLBACK(parse_ts, bool,
|
||||
@@ -786,6 +806,11 @@ CALLBACK(parse_ts, bool,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,12 +163,9 @@ index c858e9945..c72c97f76 100644
|
||||
+ }
|
||||
if (streq(buf, "dynamic"))
|
||||
{
|
||||
+ DBG2(DBG_CFG, " Create dynamic selector GRE key proto=%d, from_port=%d, to_port=%d", proto, from, to);
|
||||
ts = traffic_selector_create_dynamic(proto, from, to);
|
||||
}
|
||||
else if (strchr(buf, '-'))
|
||||
diff --git a/src/libstrongswan/selectors/traffic_selector.c b/src/libstrongswan/selectors/traffic_selector.c
|
||||
index fe61e3768..09757ec36 100644
|
||||
index 4022c45c13..ae07e02995 100644
|
||||
--- a/src/libstrongswan/selectors/traffic_selector.c
|
||||
+++ b/src/libstrongswan/selectors/traffic_selector.c
|
||||
@@ -205,6 +205,18 @@ static int print_icmp(printf_hook_data_t *data, uint16_t port)
|
||||
@@ -216,7 +210,7 @@ index fe61e3768..09757ec36 100644
|
||||
{
|
||||
written += print_in_hook(data, "OPAQUE");
|
||||
diff --git a/src/libstrongswan/selectors/traffic_selector.h b/src/libstrongswan/selectors/traffic_selector.h
|
||||
index 367b4fff9..b7010e4a7 100644
|
||||
index 367b4fff94..b7010e4a73 100644
|
||||
--- a/src/libstrongswan/selectors/traffic_selector.h
|
||||
+++ b/src/libstrongswan/selectors/traffic_selector.h
|
||||
@@ -272,6 +272,18 @@ static inline uint8_t traffic_selector_icmp_code(uint16_t port)
|
||||
@@ -239,7 +233,7 @@ index 367b4fff9..b7010e4a7 100644
|
||||
* Compare two traffic selectors, usable as sort function
|
||||
*
|
||||
diff --git a/src/starter/confread.c b/src/starter/confread.c
|
||||
index 5065bc369..039b6f402 100644
|
||||
index 5065bc369f..039b6f402b 100644
|
||||
--- a/src/starter/confread.c
|
||||
+++ b/src/starter/confread.c
|
||||
@@ -325,7 +325,29 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
|
||||
@@ -274,12 +268,12 @@ index 5065bc369..039b6f402 100644
|
||||
end->from_port = 0;
|
||||
end->to_port = 0xffff;
|
||||
diff --git a/src/swanctl/swanctl.opt b/src/swanctl/swanctl.opt
|
||||
index d9fd949ed..1d63dadb8 100644
|
||||
index 8336735fff..be185bc056 100644
|
||||
--- a/src/swanctl/swanctl.opt
|
||||
+++ b/src/swanctl/swanctl.opt
|
||||
@@ -765,6 +765,9 @@ connections.<conn>.children.<child>.local_ts = dynamic
|
||||
value _opaque_ for RFC 4301 OPAQUE selectors. Port ranges may be specified
|
||||
as well, none of the kernel backends currently support port ranges, though.
|
||||
@@ -805,6 +805,9 @@ connections.<conn>.children.<child>.local_ts = dynamic
|
||||
equal to 256, with the type in the most significant 8 bits and the code in
|
||||
the least significant 8 bits.
|
||||
|
||||
+ If protocol is restricted to GRE, port restriction specifies GRE key
|
||||
+ in 32 bit numeric form eg. dynamic[gre/100].
|
||||
@@ -288,5 +282,5 @@ index d9fd949ed..1d63dadb8 100644
|
||||
the Cisco Unity extension plugin is used. This is due to a limitation of the
|
||||
IKEv1 protocol, which only allows a single pair of selectors per CHILD_SA.
|
||||
--
|
||||
2.45.2
|
||||
2.51.0
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
Name: strongswan
|
||||
Version: 6.0.2
|
||||
Release: %autorelease
|
||||
Release: 4%{?dist}
|
||||
Summary: An OpenSource IPsec-based VPN and TNC solution
|
||||
# Automatically converted from old format: GPLv2+ - review is highly recommended.
|
||||
License: GPL-2.0-or-later
|
||||
@@ -33,7 +33,7 @@ Patch3: strongswan-6.0.2-no-md5-b3011e8e.patch
|
||||
Patch10: 0001-charon-add-optional-source-and-remote-overrides-for-.patch
|
||||
Patch11: 0002-vici-send-certificates-for-ike-sa-events.patch
|
||||
Patch12: 0003-vici-add-support-for-individual-sa-state-changes.patch
|
||||
Patch13: 0004-Support-GRE-key-in-selectors.patch
|
||||
Patch13: 0004-Support-GRE-key-in-selectors-with-kernel-netlink.patch
|
||||
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: automake
|
||||
|
||||
Reference in New Issue
Block a user