[sr-dev] git:master:90dfc421: tm: new parameter reply_relay_mode

Daniel-Constantin Mierla miconda at gmail.com
Mon Jan 25 12:43:10 CET 2021


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-01-25T12:34:33+01:00

tm: new parameter reply_relay_mode

- control the behaviour introduced by 18410da0
- if set to 0, the behaviour is like before the commit referenced above,
tm is attemptime to send suspended 200ok after another final response
that was forwarded while 200ok was suspended
- default is 1 (behave as the patch changed the forwarding policy, not
to overwrite the response buffer)

---

Modified: src/modules/tm/t_reply.c
Modified: src/modules/tm/tm.c

---

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

---

diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c
index dcf4537f08..c8dd0c91ce 100644
--- a/src/modules/tm/t_reply.c
+++ b/src/modules/tm/t_reply.c
@@ -109,6 +109,10 @@ extern int tm_remap_503_500;
 /* send path and flags in 3xx class reply */
 int tm_rich_redirect = 0;
 
+/* control if reply should be relayed
+ * when transaction reply status is RPS_PUSHED_AFTER_COMPLETION */
+extern int tm_reply_relay_mode;
+
 /* how to deal with winning branch reply selection in failure_route
  * can be overwritten per transaction with t_drop_replies(...)
  * Values:
@@ -2042,7 +2046,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 			goto error02;
 		}
 
-		if (reply_status != RPS_PUSHED_AFTER_COMPLETION) {
+		if (tm_reply_relay_mode == 0
+				|| reply_status != RPS_PUSHED_AFTER_COMPLETION) {
 			/* attempt to copy the message to UAS's shmem:
 			 * - copy to-tag for ACK matching as well
 			 *   -  allocate little a bit more for provisional as
@@ -2102,7 +2107,9 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 		}
 		if (likely(uas_rb->dst.send_sock)) {
 			if (onsend_route_enabled(SIP_REPLY) && p_msg
-						&& (p_msg != FAKED_REPLY) && (reply_status != RPS_PUSHED_AFTER_COMPLETION)) {
+						&& (p_msg != FAKED_REPLY)
+						&& (tm_reply_relay_mode == 0
+							|| reply_status != RPS_PUSHED_AFTER_COMPLETION)) {
 				if (run_onsend(p_msg, &uas_rb->dst, buf, res_len)==0){
 					su2ip_addr(&ip, &(uas_rb->dst.to));
 					LM_ERR("reply to %s:%d(%d) dropped"
@@ -2118,7 +2125,9 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 			if (SEND_PR_BUFFER( uas_rb, buf, res_len ) >= 0){
 				LM_DBG("reply buffer sent out\n");
 				if (unlikely(!totag_retr
-							&& has_tran_tmcbs(t, TMCB_RESPONSE_OUT) && (reply_status != RPS_PUSHED_AFTER_COMPLETION))){
+							&& has_tran_tmcbs(t, TMCB_RESPONSE_OUT)
+							&& (tm_reply_relay_mode == 0
+								|| reply_status != RPS_PUSHED_AFTER_COMPLETION))){
 					LOCK_REPLIES( t );
 					if(relayed_code==uas_rb->rbtype) {
 						run_trans_callbacks_with_buf( TMCB_RESPONSE_OUT, uas_rb,
@@ -2130,7 +2139,9 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 					}
 					UNLOCK_REPLIES( t );
 				}
-				if (unlikely(has_tran_tmcbs(t, TMCB_RESPONSE_SENT) && (reply_status != RPS_PUSHED_AFTER_COMPLETION))){
+				if (unlikely(has_tran_tmcbs(t, TMCB_RESPONSE_SENT)
+							&& (tm_reply_relay_mode == 0
+								|| reply_status != RPS_PUSHED_AFTER_COMPLETION))){
 					INIT_TMCB_ONSEND_PARAMS(onsend_params, t->uas.request,
 									relayed_msg, uas_rb, &uas_rb->dst, buf,
 									res_len,
diff --git a/src/modules/tm/tm.c b/src/modules/tm/tm.c
index 7a423ae5b8..2393ce67a9 100644
--- a/src/modules/tm/tm.c
+++ b/src/modules/tm/tm.c
@@ -222,6 +222,10 @@ str on_sl_reply_name = {NULL, 0};
 int tm_remap_503_500 = 1;
 str _tm_event_callback_lres_sent = {NULL, 0};
 
+/* control if reply should be relayed
+ * when transaction reply status is RPS_PUSHED_AFTER_COMPLETION */
+int tm_reply_relay_mode = 1;
+
 unsigned long tm_exec_time_check = 0; /* microseconds */
 int tm_exec_time_check_param = 5000; /* milliseconds */
 
@@ -480,6 +484,7 @@ static param_export_t params[]={
 	{"rich_redirect" ,      PARAM_INT, &tm_rich_redirect                     },
 	{"event_callback_lres_sent", PARAM_STR, &_tm_event_callback_lres_sent    },
 	{"exec_time_check" ,    PARAM_INT, &tm_exec_time_check_param             },
+	{"reply_relay_mode",    PARAM_INT, &tm_reply_relay_mode                  },
 	{0,0,0}
 };
 




More information about the sr-dev mailing list