The line-breaks got mangled from the copy and paste, sorry for that. Let me know if you
like to get the files as attachment.
Cheers,
Henning
-----Original Message-----
From: Henning Westerholt
Sent: Thursday, August 11, 2022 3:31 PM
To: miconda(a)gmail.com; Kamailio (SER) - Development Mailing List
<sr-dev(a)lists.kamailio.org>
Subject: RE: [sr-dev] git:master:d6b1c20d: tm: restore X/AVP values from initial
transaction in DNS failover processing
Hi Daniel,
Thanks for the feedback. I have done a lot of tests on my setup, but of course it’s a
complicated module.
The relevant function part is called when the DNS failover is executed, to my
understanding like this:
1. INVITE is sent to proxy (auth challenge etc..) 2. proxy is sending to DNS domain 3. DNS
domain is resolved to two A records, first IP is chosen 4. proxy sends INVITE to first IP
5. IP does not reply, tm timeout is triggered 6. X/AVP context gets lost, probably due to
cleanup from core (this will cleanup internal X/AVP list) 7. add_uac_dns_fallback function
is executed, restore X/AVP list from transaction 8. INVITE is sent to second IP 9. Call is
established 10. Cleanup is done again to delete internal X/AVP list
See below for an example call log with added local debugging before the fix. TM timeout is
5s.
[...]
Cheers,
Henning
--
Henning Westerholt –
https://skalatan.de/blog/ Kamailio services –
https://gilawa.com
-----Original Message-----
From: Daniel-Constantin Mierla <miconda(a)gmail.com>
Sent: Thursday, August 11, 2022 10:47 AM
To: Kamailio (SER) - Development Mailing List <sr-dev(a)lists.kamailio.org>rg>; Henning
Westerholt <hw(a)gilawa.com>
Subject: Re: [sr-dev] git:master:d6b1c20d: tm: restore X/AVP values from initial
transaction in DNS failover processing
Hello,
I haven't looked in the code to try to figure out the execution paths to this function
and where ends up afterwards, so more for safety: have you checked that there are no other
X/AVPs set at that moment, or if they are they are restored later?
Usually when setting x/avps lists, the old ones have to be restored in order to be sure it
does not end up in memory leaks (or the old ones have to be cleaned up).
Cheers,
Daniel
On 09.08.22 16:16, Henning Westerholt wrote:
Module: kamailio
Branch: master
Commit: d6b1c20d3ad94d9136cf247e67b7fc0d32b18d3b
URL:
https://github.com/kamailio/kamailio/commit/d6b1c20d3ad94d9136cf247e67
b7fc0d32b18d3b
Author: Henning Westerholt <hw(a)gilawa.com>
Committer: Henning Westerholt <hw(a)gilawa.com>
Date: 2022-08-09T14:11:59Z
tm: restore X/AVP values from initial transaction in DNS failover
processing
- restore X/AVP values from initial transaction in DNS failover
processing
- the X/AVP context gets lost, so we need to re-create it from the
transaction
- otherwise modules that depends on the X/AVPs, e.g. topology hiding
will not work
- tested with one load-balancer and two proxy servers
---
Modified: src/modules/tm/t_fwd.c
---
Diff:
https://github.com/kamailio/kamailio/commit/d6b1c20d3ad94d9136cf247e67
b7fc0d32b18d3b.diff
Patch:
https://github.com/kamailio/kamailio/commit/d6b1c20d3ad94d9136cf247e67
b7fc0d32b18d3b.patch
---
diff --git a/src/modules/tm/t_fwd.c b/src/modules/tm/t_fwd.c index
fbcf1b3e02..6b26f28f6a 100644
--- a/src/modules/tm/t_fwd.c
+++ b/src/modules/tm/t_fwd.c
@@ -1042,6 +1042,8 @@ int add_uac_dns_fallback(struct cell *t, struct sip_msg* msg,
t->uac[t->nr_of_outgoings].on_branch_failure = old_uac->on_branch_failure;
/* copy branch flags */
t->uac[t->nr_of_outgoings].branch_flags = old_uac->branch_flags;
+ /* restore X/AVP values from initial transaction */
+ tm_xdata_swap(t, 0, 0);
if (cfg_get(tm, tm_cfg, reparse_on_dns_failover)){
/* Reuse the old buffer and only replace the via header.
_______________________________________________
Kamailio (SER) - Development Mailing List sr-dev(a)lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
--
Daniel-Constantin Mierla --
www.asipto.com www.twitter.com/miconda --
www.linkedin.com/in/miconda