Browse Source

ims_scscf: Add more logging to ipsec_create()

Currently there are scenarios where ipsec_create() fails with no more
information in the logs. This should make debugging issues a bit easier.

Co-authored-by: Alexander Couzens <[email protected]>
(cherry picked from commit 353b788bb3c78a4c0e8c390decdc420322b4927c)
Lennart Rosam 9 months ago
parent
commit
b359bd6c7a
1 changed files with 11 additions and 3 deletions
  1. 11 3
      src/modules/ims_ipsec_pcscf/cmd.c

+ 11 - 3
src/modules/ims_ipsec_pcscf/cmd.c

@@ -809,6 +809,7 @@ int ipsec_create(struct sip_msg *m, udomain_t *d, int _cflags)
 	pcontact_t *pcontact = NULL;
 	struct pcontact_info ci;
 	int ret = IPSEC_CMD_FAIL; // FAIL by default
+	int fun_ret_c; // Used to store return codes of some functions
 	tm_cell_t *t = NULL;
 	sip_msg_t *req = NULL;
 	security_t *req_sec_params = NULL;
@@ -893,10 +894,13 @@ int ipsec_create(struct sip_msg *m, udomain_t *d, int _cflags)
 	}
 
 	if(update_contact_ipsec_params(s, m, old_s) != 0) {
+		LM_ERR("Could not update ipsec params in contact.\n");
 		goto cleanup;
 	}
 
-	if(create_ipsec_tunnel(&req->rcv.src_ip, s) != 0) {
+	fun_ret_c = create_ipsec_tunnel(&req->rcv.src_ip, s);
+	if(fun_ret_c != 0) {
+		LM_ERR("IPSEC tunnel creation failed.\n");
 		goto cleanup;
 	}
 
@@ -917,11 +921,15 @@ int ipsec_create(struct sip_msg *m, udomain_t *d, int _cflags)
 		goto cleanup;
 	}
 
-	if(add_supported_secagree_header(m) != 0) {
+	fun_ret_c = add_supported_secagree_header(m);
+	if(fun_ret_c != 0) {
+		LM_ERR("Could not add secagree header. Failed with code: %d\n", fun_ret_c);
 		goto cleanup;
 	}
 
-	if(add_security_server_header(m, s) != 0) {
+	fun_ret_c = add_security_server_header(m, s);
+	if(fun_ret_c != 0) {
+		LM_ERR("Could not add security server header. Code: %d\n", fun_ret_c);
 		goto cleanup;
 	}