Module: kamailio
Branch: master
Commit: e728b7b8ec58cbd4c322fac076ef24572e895d0a
URL: 
https://github.com/kamailio/kamailio/commit/e728b7b8ec58cbd4c322fac076ef24572e895d0a

Author: herlesupreeth <[email protected]>
Committer: Victor Seva <[email protected]>
Date: 2026-01-26T18:30:36+01:00

ims_ipsec_pcscf: reuse IPSec tunnel params only if Ck and Ik stays the same

---

Modified: src/modules/ims_ipsec_pcscf/cmd.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/e728b7b8ec58cbd4c322fac076ef24572e895d0a.diff
Patch: 
https://github.com/kamailio/kamailio/commit/e728b7b8ec58cbd4c322fac076ef24572e895d0a.patch

---

diff --git a/src/modules/ims_ipsec_pcscf/cmd.c 
b/src/modules/ims_ipsec_pcscf/cmd.c
index d0a74ecf56f..9b926943fe2 100644
--- a/src/modules/ims_ipsec_pcscf/cmd.c
+++ b/src/modules/ims_ipsec_pcscf/cmd.c
@@ -475,8 +475,10 @@ static int update_contact_ipsec_params(
        memcpy(s->ik.s, ik.s, ik.len);
        s->ik.len = ik.len;
 
-       // Generate SPI
-       if(s_old) {
+       // Reuse only if both CK and IK match.
+       if(s_old && s_old->ck.s != NULL && s_old->ik.s != NULL
+                       && strcmp(s_old->ck.s, s->ck.s) == 0
+                       && strcmp(s_old->ik.s, s->ik.s) == 0) {
                if(s_old->spi_pc && s_old->spi_ps && s_old->port_pc && 
s_old->port_ps) {
                        LM_INFO("Reusing IPSEC tunnel\n");
                        s->spi_pc = s_old->spi_pc;

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to