Created
December 2, 2019 08:25
-
-
Save razvancrainea/c138c97db24ac37e3abd074b6ddec1bb to your computer and use it in GitHub Desktop.
$rT report patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 89023bb1ff1be17e0a3d316a8f6de1e4e4e20640 | |
Author: Razvan Crainea <razvan@opensips.org> | |
Date: Wed Oct 9 12:35:33 2019 +0300 | |
properly populate route_type for certain routes | |
Reported by Ben Newlin in ticket #1846 | |
diff --git a/modules/b2b_entities/dlg.c b/modules/b2b_entities/dlg.c | |
index 17deae9da..afa2ec9dd 100644 | |
--- a/modules/b2b_entities/dlg.c | |
+++ b/modules/b2b_entities/dlg.c | |
@@ -2111,6 +2111,7 @@ void b2b_tm_cback(struct cell *t, b2b_table htable, struct tmcb_params *ps) | |
HASHHEX response; | |
str *new_hdr; | |
char status_buf[INT2STR_MAX_LEN]; | |
+ int old_route_type; | |
to_hdr_parsed.param_lst = from_hdr_parsed.param_lst = NULL; | |
@@ -2418,7 +2419,9 @@ void b2b_tm_cback(struct cell *t, b2b_table htable, struct tmcb_params *ps) | |
/* run the b2b route */ | |
if(reply_routeid > 0) { | |
msg->flags = t->uac[0].br_flags; | |
+ swap_route_type(old_route_type, ONREPLY_ROUTE); | |
run_top_route(rlist[reply_routeid].a, msg); | |
+ set_route_type(old_route_type); | |
b2b_apply_lumps(msg); | |
} | |
goto b2b_route; | |
@@ -2758,7 +2761,9 @@ done1: | |
/* run the b2b route */ | |
if(reply_routeid > 0) { | |
msg->flags = t->uac[0].br_flags; | |
+ swap_route_type(old_route_type, ONREPLY_ROUTE); | |
run_top_route(rlist[reply_routeid].a, msg); | |
+ set_route_type(old_route_type); | |
if (msg != FAKED_REPLY) b2b_apply_lumps(msg); | |
} | |
diff --git a/modules/event_route/event_route.c b/modules/event_route/event_route.c | |
index 3912ec643..02865bc7f 100644 | |
--- a/modules/event_route/event_route.c | |
+++ b/modules/event_route/event_route.c | |
@@ -359,7 +359,7 @@ static int scriptroute_raise(struct sip_msg *msg, str* ev_name, | |
str * backup_name; | |
route_send_t *buf = NULL; | |
int sync_mode; | |
- | |
+ int old_route_type; | |
if (!sock || !(sock->flags & EVI_PARAMS)) { | |
LM_ERR("no socket found\n"); | |
@@ -386,7 +386,9 @@ static int scriptroute_raise(struct sip_msg *msg, str* ev_name, | |
parameters = params; | |
event_name = ev_name; | |
+ swap_route_type(old_route_type, EVENT_ROUTE); | |
run_top_route(event_rlist[SR_SOCK_ROUTE(sock)].a, msg); | |
+ set_route_type(old_route_type); | |
/* restore previous parameters */ | |
parameters = backup_params; | |
diff --git a/modules/event_route/route_send.c b/modules/event_route/route_send.c | |
index c3fa9e803..30338ba5a 100644 | |
--- a/modules/event_route/route_send.c | |
+++ b/modules/event_route/route_send.c | |
@@ -244,6 +244,7 @@ void event_route_handler(int rank) | |
route_init_reader(); | |
route_send_t *route_s; | |
struct sip_msg* dummy_req; | |
+ int old_route_type; | |
dummy_req = (struct sip_msg*)pkg_malloc(sizeof(struct sip_msg)); | |
if (dummy_req == NULL) { | |
@@ -269,7 +270,9 @@ void event_route_handler(int rank) | |
event_name = &route_s->event; | |
parameters = &route_s->params; | |
+ swap_route_type(old_route_type, EVENT_ROUTE); | |
run_top_route(route_s->a, dummy_req); | |
+ set_route_type(old_route_type); | |
end: | |
if (route_s) | |
shm_free(route_s); | |
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c | |
index 0573cc513..5365cd5ae 100644 | |
--- a/modules/tm/t_reply.c | |
+++ b/modules/tm/t_reply.c | |
@@ -555,6 +555,7 @@ static inline int run_failure_handlers(struct cell *t) | |
struct sip_msg *shmem_msg; | |
struct ua_client *uac; | |
int on_failure; | |
+ int old_route_type; | |
shmem_msg = t->uas.request; | |
uac = &t->uac[picked_branch]; | |
@@ -594,7 +595,9 @@ static inline int run_failure_handlers(struct cell *t) | |
on_failure = t->on_negative; | |
t->on_negative=0; | |
/* run a reply_route action if some was marked */ | |
+ swap_route_type(old_route_type, FAILURE_ROUTE); | |
run_top_route(failure_rlist[on_failure].a, &faked_req); | |
+ set_route_type(old_route_type); | |
} | |
/* restore original environment and free the fake msg */ | |
@@ -1472,6 +1475,7 @@ int reply_received( struct sip_msg *p_msg ) | |
struct cell *t; | |
struct usr_avp **backup_list; | |
unsigned int has_reply_route; | |
+ int old_route_type; | |
set_t(T_UNDEFINED); | |
@@ -1537,10 +1541,13 @@ int reply_received( struct sip_msg *p_msg ) | |
/* transfer transaction flag to branch context */ | |
p_msg->flags = t->uas.request ? t->uas.request->flags : 0; | |
setb0flags( p_msg, t->uac[branch].br_flags); | |
+ | |
+ swap_route_type(old_route_type, BRANCH_ROUTE); | |
/* run block - first per branch and then global one */ | |
if ( t->uac[branch].on_reply && | |
(run_top_route(onreply_rlist[t->uac[branch].on_reply].a,p_msg) | |
&ACT_FL_DROP) && (msg_status<200) ) { | |
+ set_route_type(old_route_type); | |
if (onreply_avp_mode) { | |
UNLOCK_REPLIES( t ); | |
set_avp_list( backup_list ); | |
@@ -1548,8 +1555,10 @@ int reply_received( struct sip_msg *p_msg ) | |
LM_DBG("dropping provisional reply %d\n", msg_status); | |
goto done; | |
} | |
+ set_route_type(ONREPLY_ROUTE); | |
if ( t->on_reply && (run_top_route(onreply_rlist[t->on_reply].a,p_msg) | |
&ACT_FL_DROP) && (msg_status<200) ) { | |
+ set_route_type(old_route_type); | |
if (onreply_avp_mode) { | |
UNLOCK_REPLIES( t ); | |
set_avp_list( backup_list ); | |
@@ -1557,6 +1566,7 @@ int reply_received( struct sip_msg *p_msg ) | |
LM_DBG("dropping provisional reply %d\n", msg_status); | |
goto done; | |
} | |
+ set_route_type(old_route_type); | |
/* transfer current message context back to t */ | |
t->uac[branch].br_flags = getb0flags(p_msg); | |
if (t->uas.request) | |
diff --git a/receive.c b/receive.c | |
index b3d8f9fc0..eb2223b27 100644 | |
--- a/receive.c | |
+++ b/receive.c | |
@@ -102,7 +102,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info, | |
static context_p ctx = NULL; | |
struct sip_msg* msg; | |
struct timeval start; | |
- int rc; | |
+ int rc, old_route_type; | |
char *tmp; | |
str in_buff; | |
@@ -245,15 +245,18 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info, | |
goto end; /* drop the reply */ | |
} | |
+ swap_route_type(old_route_type, ONREPLY_ROUTE); | |
/* exec the onreply routing script */ | |
if (rc & SCB_RUN_TOP_ROUTE && onreply_rlist[DEFAULT_RT].a && | |
(run_top_route(onreply_rlist[DEFAULT_RT].a,msg) & ACT_FL_DROP) | |
&& msg->REPLY_STATUS < 200) { | |
+ set_route_type(old_route_type); | |
LM_DBG("dropping provisional reply %d\n", msg->REPLY_STATUS); | |
update_stat( drp_rpls, 1); | |
goto end; /* drop the message */ | |
} else { | |
+ set_route_type(old_route_type); | |
/* send the msg */ | |
forward_reply(msg); | |
/* TODO - TX reply stat */ | |
diff --git a/route.c b/route.c | |
index aed379c6b..ca48f5d44 100644 | |
--- a/route.c | |
+++ b/route.c | |
@@ -2125,7 +2125,7 @@ int is_script_async_func_used( char *name, int param_no) | |
int run_startup_route(void) | |
{ | |
struct sip_msg req; | |
- int ret; | |
+ int ret, old_route_type; | |
memset(&req, 0, sizeof(struct sip_msg)); | |
req.first_line.type = SIP_REQUEST; | |
@@ -2137,8 +2137,10 @@ int run_startup_route(void) | |
req.rcv.src_ip.af = AF_INET; | |
req.rcv.dst_ip.af = AF_INET; | |
+ swap_route_type(old_route_type, STARTUP_ROUTE); | |
/* run the route */ | |
ret = run_top_route( startup_rlist.a, &req); | |
+ set_route_type(old_route_type); | |
free_sip_msg( &req ); | |
return ret; | |
diff --git a/timer.c b/timer.c | |
index e5024d090..2d87c50e5 100644 | |
--- a/timer.c | |
+++ b/timer.c | |
@@ -202,6 +202,7 @@ void route_timer_f(unsigned int ticks, void* param) | |
{ | |
struct action* a = (struct action*)param; | |
static struct sip_msg* req= NULL; | |
+ int old_route_type; | |
if(a == NULL) { | |
LM_ERR("NULL action\n"); | |
@@ -227,7 +228,9 @@ void route_timer_f(unsigned int ticks, void* param) | |
req->rcv.src_ip.af = AF_INET; | |
req->rcv.dst_ip.af = AF_INET; | |
+ swap_route_type(old_route_type, TIMER_ROUTE); | |
run_top_route(a, req); | |
+ set_route_type(old_route_type); | |
/* clean whatever extra structures were added by script functions */ | |
free_sip_msg(req); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment