TT#43152 ACC not created for call-fork with reject scenario

Those are the commits taken from upstream version to fix the issue:
 - f21554c6befaddbc82016d5d498e11ab3720c404
 - 5b223a2e8a92f351b8eab756f5256fda7645ff21
 - 1aad02edc6b9ffb104900cbc624f0853166ae926
 - 35dec4c20d78f49ba242229c877894d70c94705c

Change-Id: I538cf7141ad4311520ec9a6ceded71b99fb93626
changes/91/23391/3
Marco Capetta 8 years ago
parent 61127c588d
commit 57d75b2ed0

@ -41,6 +41,10 @@ upstream/0002-tm-force-free-cell-if-transaction-is-unlinkled.patch
upstream/0003-tm-backup-and-restore-T-and-T_branch-in-t_continue.patch
upstream/0004-topos-keep-original-contact-in-3xx-responses-sent-ou.patch
upstream/0005-topos_redis-execute-end-dialog-function-only-for-BYE.patch
upstream/0006-acc-more-debug-message.patch
upstream/0007-tm-update-uas-rb-activ_type.patch
upstream/0008-tm-activ_type-field-renamed-to-rbtype.patch
upstream/0009-tm-set-uas-rb-type-along-with-the-buffer.patch
sipwise/extend_stats.patch
sipwise/avpops_avp_subst_pvar.patch
sipwise/tt37692.patch

@ -0,0 +1,68 @@
From f21554c6befaddbc82016d5d498e11ab3720c404 Mon Sep 17 00:00:00 2001
From: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon, 10 Sep 2018 09:18:27 +0200
Subject: [PATCH] acc: more debug message when checking if acc should be done
---
src/modules/acc/acc_logic.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/src/modules/acc/acc_logic.c b/src/modules/acc/acc_logic.c
index d41108d3bc..e0443ce906 100644
--- a/src/modules/acc/acc_logic.c
+++ b/src/modules/acc/acc_logic.c
@@ -411,27 +411,40 @@ static inline int should_acc_reply(struct sip_msg *req, struct sip_msg *rpl,
{
unsigned int i;
+ LM_DBG("probing acc state - code: %d flags: 0x%x\n", code,
+ (req)?req->flags:0);
/* negative transactions reported otherwise only if explicitly
* demanded */
-
if (code >= 300) {
- if (!is_failed_acc_on(req)) return 0;
+ if (!is_failed_acc_on(req)) {
+ LM_DBG("failed acc is off\n");
+ return 0;
+ }
i = 0;
while (failed_filter[i] != 0) {
- if (failed_filter[i] == code) return 0;
+ if (failed_filter[i] == code) {
+ LM_DBG("acc code in filter: %d\n", code);
+ return 0;
+ }
i++;
}
+ LM_DBG("failed acc is on\n");
return 1;
}
- if ( !is_acc_on(req) )
+ if ( !is_acc_on(req) ) {
+ LM_DBG("acc is off\n");
return 0;
+ }
if ( code<200 && !(early_media &&
parse_headers(rpl,HDR_CONTENTLENGTH_F, 0) == 0 &&
- rpl->content_length && get_content_length(rpl) > 0))
+ rpl->content_length && get_content_length(rpl) > 0)) {
+ LM_DBG("early media acc is off\n");
return 0;
+ }
+ LM_DBG("acc is on\n");
return 1; /* seed is through, we will account this reply */
}
@@ -461,6 +474,7 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
int flags_to_reset = 0;
int br = -1;
+ LM_DBG("preparing to report the record\n");
/* get winning branch index, if set */
if (t->relayed_reply_branch>=0) {
br = t->relayed_reply_branch;

@ -0,0 +1,65 @@
From 5b223a2e8a92f351b8eab756f5256fda7645ff21 Mon Sep 17 00:00:00 2001
From: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon, 10 Sep 2018 15:03:44 +0200
Subject: [PATCH] tm: update uas rb activ_type when overwriting realyed_code
- otherwise could end up skipping the execution for TMCB_RESPONSE_OUT tm
callback, affecting acc, ...
---
src/modules/tm/t_reply.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c
index 271932c90c..14f244ef7d 100644
--- a/src/modules/tm/t_reply.c
+++ b/src/modules/tm/t_reply.c
@@ -1777,6 +1777,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
buf=0;
relayed_msg=0;
relayed_code=0;
+
totag_retr=0;
/* remember, what was sent upstream to know whether we are
@@ -1785,8 +1786,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
/* *** store and relay message as needed *** */
reply_status = t_should_relay_response(t, msg_status, branch,
&save_clone, &relay, cancel_data, p_msg );
- LM_DBG("branch=%d, save=%d, relay=%d icode=%d\n",
- branch, save_clone, relay, t->uac[branch].icode);
+ LM_DBG("branch=%d, save=%d, relay=%d icode=%d msg status=%u\n",
+ branch, save_clone, relay, t->uac[branch].icode, msg_status);
/* store the message if needed */
if (save_clone) /* save for later use, typically branch picking */
@@ -1815,8 +1816,9 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
if(t->flags & T_CANCELED) {
/* transaction canceled - send 487 */
relayed_code = 487;
+ uas_rb->activ_type = 487;
} else {
- relayed_code = branch==relay
+ relayed_code = (branch==relay)
? msg_status : t->uac[relay].last_received;
}
/* use to_tag from the original request, or if not present,
@@ -1869,6 +1871,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
buf=build_res_buf_from_sip_req(500, &reason,
to_tag, t->uas.request, &res_len, &bm);
relayed_code=500;
+ uas_rb->activ_type = 500;
}else if (cfg_get(tm, tm_cfg, tm_aggregate_auth) &&
(relayed_code==401 || relayed_code==407) &&
(auth_reply_count(t, p_msg)>1)){
@@ -1984,6 +1987,10 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
if(relayed_code==uas_rb->activ_type) {
run_trans_callbacks_with_buf( TMCB_RESPONSE_OUT, uas_rb,
t->uas.request, relayed_msg, TMCB_NONE_F);
+ } else {
+ LM_DBG("skip tm callback %d - relay code %d active %d\n",
+ TMCB_RESPONSE_OUT, relayed_code,
+ uas_rb->activ_type);
}
UNLOCK_REPLIES( t );
}

@ -0,0 +1,206 @@
From 1aad02edc6b9ffb104900cbc624f0853166ae926 Mon Sep 17 00:00:00 2001
From: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon, 10 Sep 2018 17:15:30 +0200
Subject: [PATCH] tm: activ_type field renamed to rbtype in struct retr_buf
- better matching the purpose and do not use a typo word
- field t_active changed from char to short for better mem align
---
src/modules/tm/h_table.h | 9 +++++----
src/modules/tm/t_cancel.c | 2 +-
src/modules/tm/t_hooks.c | 2 +-
src/modules/tm/t_reply.c | 12 ++++++------
src/modules/tm/timer.c | 8 ++++----
src/modules/tm/timer.h | 8 ++++----
src/modules/tm/uac.c | 2 +-
7 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/src/modules/tm/h_table.h b/src/modules/tm/h_table.h
index a60fb9c754..7aca7ed92c 100644
--- a/src/modules/tm/h_table.h
+++ b/src/modules/tm/h_table.h
@@ -147,11 +147,12 @@ enum kill_reason
typedef struct retr_buf
{
- short activ_type;
- /* set to status code if the buffer is a reply,
- * 0 if request or -1 if local CANCEL */
+ /* rbtype is set to status code if the buffer is a reply,
+ * 0 (TYPE_REQUEST) if request, -1 if local CANCEL (TYPE_LOCAL_CANCEL),
+ * -2 if local ACK (TYPE_LOCAL_ACK) */
+ short rbtype;
volatile unsigned short flags; /* DISABLED, T2 */
- volatile unsigned char t_active; /* timer active */
+ volatile unsigned short t_active; /* timer active */
unsigned short branch; /* no more than 64k branches */
int buffer_len;
char *buffer;
diff --git a/src/modules/tm/t_cancel.c b/src/modules/tm/t_cancel.c
index c0635844ef..49751c9958 100644
--- a/src/modules/tm/t_cancel.c
+++ b/src/modules/tm/t_cancel.c
@@ -316,7 +316,7 @@ int cancel_branch( struct cell *t, int branch,
crb->branch = branch;
/* label it as cancel so that FR timer can better know how to
deal with it */
- crb->activ_type = TYPE_LOCAL_CANCEL;
+ crb->rbtype = TYPE_LOCAL_CANCEL;
/* be extra carefully and check for bugs (the below if could be replaced
* by an atomic_set((void*)&crb->buffer, cancel) */
if (unlikely(atomic_cmpxchg_long((void*)&crb->buffer, (long)BUSY_BUFFER,
diff --git a/src/modules/tm/t_hooks.c b/src/modules/tm/t_hooks.c
index 4543c31924..bc3a83b26e 100644
--- a/src/modules/tm/t_hooks.c
+++ b/src/modules/tm/t_hooks.c
@@ -300,7 +300,7 @@ void run_trans_callbacks_with_buf(int type, struct retr_buf* rbuf,
((trans->tmcb_hl.reg_types)&type)==0 )
return;
INIT_TMCB_ONSEND_PARAMS(params, req, repl, rbuf, &rbuf->dst, rbuf->buffer,
- rbuf->buffer_len, flags, rbuf->branch, rbuf->activ_type);
+ rbuf->buffer_len, flags, rbuf->branch, rbuf->rbtype);
/* req, rpl */
run_trans_callbacks_internal(&trans->tmcb_hl, type, trans, &params);
}
diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c
index 14f244ef7d..62e844a55a 100644
--- a/src/modules/tm/t_reply.c
+++ b/src/modules/tm/t_reply.c
@@ -483,7 +483,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
}
rb = & trans->uas.response;
- rb->activ_type=code;
+ rb->rbtype=code;
trans->uas.status = code;
buf_len = rb->buffer ? len : len + REPLY_OVERBUFFER_LEN;
@@ -1799,7 +1799,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
uas_rb = & t->uas.response;
if (relay >= 0 ) {
/* initialize sockets for outbound reply */
- uas_rb->activ_type=msg_status;
+ uas_rb->rbtype=msg_status;
/* only messages known to be relayed immediately will be
* be called on; we do not evoke this callback on messages
* stored in shmem -- they are fixed and one cannot change them
@@ -1816,7 +1816,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
if(t->flags & T_CANCELED) {
/* transaction canceled - send 487 */
relayed_code = 487;
- uas_rb->activ_type = 487;
+ uas_rb->rbtype = 487;
} else {
relayed_code = (branch==relay)
? msg_status : t->uac[relay].last_received;
@@ -1871,7 +1871,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
buf=build_res_buf_from_sip_req(500, &reason,
to_tag, t->uas.request, &res_len, &bm);
relayed_code=500;
- uas_rb->activ_type = 500;
+ uas_rb->rbtype = 500;
}else if (cfg_get(tm, tm_cfg, tm_aggregate_auth) &&
(relayed_code==401 || relayed_code==407) &&
(auth_reply_count(t, p_msg)>1)){
@@ -1984,13 +1984,13 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
if (unlikely(!totag_retr
&& has_tran_tmcbs(t, TMCB_RESPONSE_OUT))){
LOCK_REPLIES( t );
- if(relayed_code==uas_rb->activ_type) {
+ if(relayed_code==uas_rb->rbtype) {
run_trans_callbacks_with_buf( TMCB_RESPONSE_OUT, uas_rb,
t->uas.request, relayed_msg, TMCB_NONE_F);
} else {
LM_DBG("skip tm callback %d - relay code %d active %d\n",
TMCB_RESPONSE_OUT, relayed_code,
- uas_rb->activ_type);
+ uas_rb->rbtype);
}
UNLOCK_REPLIES( t );
}
diff --git a/src/modules/tm/timer.c b/src/modules/tm/timer.c
index b5e4325929..fcc38823d3 100644
--- a/src/modules/tm/timer.c
+++ b/src/modules/tm/timer.c
@@ -367,8 +367,8 @@ inline static ticks_t retransmission_handler(struct retr_buf *r_buf)
abort();
}
#endif
- if(r_buf->activ_type == TYPE_LOCAL_CANCEL
- || r_buf->activ_type == TYPE_REQUEST) {
+ if(r_buf->rbtype == TYPE_LOCAL_CANCEL
+ || r_buf->rbtype == TYPE_REQUEST) {
#ifdef EXTRA_DEBUG
LM_DBG("request resending (t=%p, %.9s ... )\n", r_buf->my_T,
r_buf->buffer);
@@ -415,14 +415,14 @@ inline static void final_response_handler(
}
#endif
/* FR for local cancels.... */
- if(r_buf->activ_type == TYPE_LOCAL_CANCEL) {
+ if(r_buf->rbtype == TYPE_LOCAL_CANCEL) {
#ifdef TIMER_DEBUG
LM_DBG("stop retr for local cancel\n");
#endif
return;
}
/* FR for replies (negative INVITE replies) */
- if(r_buf->activ_type > 0) {
+ if(r_buf->rbtype > 0) {
#ifdef EXTRA_DEBUG
if(t->uas.request->REQ_METHOD != METHOD_INVITE || t->uas.status < 200) {
LM_CRIT("BUG - unknown type reply buffer\n");
diff --git a/src/modules/tm/timer.h b/src/modules/tm/timer.h
index 5cb6c736a6..5f20dd3683 100644
--- a/src/modules/tm/timer.h
+++ b/src/modules/tm/timer.h
@@ -200,7 +200,7 @@ inline static int _set_fr_retr(struct retr_buf *rb, unsigned retr_ms)
#endif
/* adjust timeout to MIN(fr, maximum lifetime) if rb is a request
* (for neg. replies we are force to wait for the ACK so use fr) */
- if(unlikely((rb->activ_type == TYPE_REQUEST)
+ if(unlikely((rb->rbtype == TYPE_REQUEST)
&& ((s_ticks_t)(eol - (ticks + timeout))
< 0))) { /* fr after end of life */
timeout = (((s_ticks_t)(eol - ticks)) > 0) ? (eol - ticks)
@@ -260,7 +260,7 @@ inline static void restart_rb_fr(struct retr_buf *rb, ticks_t new_val)
now = get_ticks_raw();
t = rb->my_T;
- if(unlikely((rb->activ_type == TYPE_REQUEST)
+ if(unlikely((rb->rbtype == TYPE_REQUEST)
&& (((s_ticks_t)(t->end_of_life - (now + new_val))) < 0)))
rb->fr_expire = t->end_of_life;
else
@@ -291,7 +291,7 @@ inline static void change_fr(struct cell *t, ticks_t fr_inv, ticks_t fr)
if((t->uac[i].request.flags & F_RB_FR_INV) && fr_inv)
t->uac[i].request.fr_expire = fr_inv_expire;
else if(fr) {
- if(t->uac[i].request.activ_type == TYPE_REQUEST)
+ if(t->uac[i].request.rbtype == TYPE_REQUEST)
t->uac[i].request.fr_expire = req_fr_expire;
else
t->uac[i].request.fr_expire = fr_expire;
@@ -347,7 +347,7 @@ inline static void change_end_of_life(struct cell *t, int adj, ticks_t eol)
if(adj) {
for(i = 0; i < t->nr_of_outgoings; i++) {
if(t->uac[i].request.t_active) {
- if((t->uac[i].request.activ_type == TYPE_REQUEST)
+ if((t->uac[i].request.rbtype == TYPE_REQUEST)
&& ((s_ticks_t)(t->end_of_life
- t->uac[i].request.fr_expire)
< 0))
diff --git a/src/modules/tm/uac.c b/src/modules/tm/uac.c
index 42e25762d2..21e62c9fb7 100644
--- a/src/modules/tm/uac.c
+++ b/src/modules/tm/uac.c
@@ -765,7 +765,7 @@ struct retr_buf *local_ack_rb(sip_msg_t *rpl_2xx, struct cell *trans,
}
/* TODO: need next 2? */
- lack->activ_type = TYPE_LOCAL_ACK;
+ lack->rbtype = TYPE_LOCAL_ACK;
lack->my_T = trans;
return lack;

@ -0,0 +1,93 @@
From 35dec4c20d78f49ba242229c877894d70c94705c Mon Sep 17 00:00:00 2001
From: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon, 10 Sep 2018 19:38:34 +0200
Subject: [PATCH] tm: set uas rb type along with the buffer when relaying
replies
- ensure it is same reply code used in outgoing buffer
---
src/modules/tm/t_reply.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c
index 62e844a55a..88ec5dd629 100644
--- a/src/modules/tm/t_reply.c
+++ b/src/modules/tm/t_reply.c
@@ -1777,7 +1777,6 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
buf=0;
relayed_msg=0;
relayed_code=0;
-
totag_retr=0;
/* remember, what was sent upstream to know whether we are
@@ -1790,16 +1789,15 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
branch, save_clone, relay, t->uac[branch].icode, msg_status);
/* store the message if needed */
- if (save_clone) /* save for later use, typically branch picking */
- {
+ if (save_clone) {
+ /* save for later use, typically branch picking */
if (!store_reply( t, branch, p_msg ))
goto error01;
}
- uas_rb = & t->uas.response;
+ /* initialize for outbound reply */
+ uas_rb = &t->uas.response;
if (relay >= 0 ) {
- /* initialize sockets for outbound reply */
- uas_rb->rbtype=msg_status;
/* only messages known to be relayed immediately will be
* be called on; we do not evoke this callback on messages
* stored in shmem -- they are fixed and one cannot change them
@@ -1811,12 +1809,11 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
}
/* try building the outbound reply from either the current
* or a stored message */
- relayed_msg = branch==relay ? p_msg : t->uac[relay].reply;
+ relayed_msg = (branch==relay) ? p_msg : t->uac[relay].reply;
if (relayed_msg==FAKED_REPLY) {
if(t->flags & T_CANCELED) {
/* transaction canceled - send 487 */
relayed_code = 487;
- uas_rb->rbtype = 487;
} else {
relayed_code = (branch==relay)
? msg_status : t->uac[relay].last_received;
@@ -1871,7 +1868,6 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
buf=build_res_buf_from_sip_req(500, &reason,
to_tag, t->uas.request, &res_len, &bm);
relayed_code=500;
- uas_rb->rbtype = 500;
}else if (cfg_get(tm, tm_cfg, tm_aggregate_auth) &&
(relayed_code==401 || relayed_code==407) &&
(auth_reply_count(t, p_msg)>1)){
@@ -1926,6 +1922,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
LM_ERR("cannot alloc reply shmem\n");
goto error03;
}
+ uas_rb->rbtype = relayed_code;
uas_rb->buffer_len = res_len;
memcpy( uas_rb->buffer, buf, res_len );
if (relayed_msg==FAKED_REPLY) { /* to-tags for local replies */
@@ -1938,13 +1935,13 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
t->relayed_reply_branch = relay;
if ( unlikely(is_invite(t) && relayed_msg!=FAKED_REPLY
- && relayed_code>=200 && relayed_code < 300
- && has_tran_tmcbs( t,
- TMCB_RESPONSE_OUT|TMCB_RESPONSE_READY
- |TMCB_E2EACK_IN|TMCB_E2EACK_RETR_IN))) {
+ && relayed_code>=200 && relayed_code < 300
+ && has_tran_tmcbs( t,
+ TMCB_RESPONSE_OUT|TMCB_RESPONSE_READY
+ |TMCB_E2EACK_IN|TMCB_E2EACK_RETR_IN))) {
totag_retr=update_totag_set(t, relayed_msg);
}
- }; /* if relay ... */
+ } /* if relay ... */
UNLOCK_REPLIES( t );
Loading…
Cancel
Save