libipsec: Reject policies for anything but ESP tunnel mode

This is only relevant for trap policies as similar SAs are already
rejected when negotiated.
This commit is contained in:
Tobias Brunner
2026-04-02 08:34:20 +02:00
parent 2a63343968
commit a3c5fad1ff
2 changed files with 22 additions and 0 deletions
+17
View File
@@ -202,6 +202,23 @@ ipsec_policy_t *ipsec_policy_create(host_t *src, host_t *dst,
{
private_ipsec_policy_t *this;
if (!sa->esp.use)
{
DBG1(DBG_ESP, " IPsec policy: protocol not supported");
return NULL;
}
if (sa->ipcomp.transform != IPCOMP_NONE)
{
DBG1(DBG_ESP, " IPsec policy: compression not supported");
return NULL;
}
if (sa->mode != MODE_TUNNEL)
{
DBG1(DBG_ESP, " IPsec policy: unsupported mode");
return NULL;
}
INIT(this,
.public = {
.match = _match,
+5
View File
@@ -158,6 +158,11 @@ METHOD(ipsec_policy_mgr_t, add_policy, status_t,
policy = ipsec_policy_create(src, dst, src_ts, dst_ts, direction, type, sa,
mark, priority);
if (!policy)
{
DBG1(DBG_ESP, "failed to create policy");
return FAILED;
}
entry = policy_entry_create(policy);
this->lock->write_lock(this->lock);