... | ... |
@@ -76,6 +76,7 @@ struct cfg_group_tm default_tm_cfg = { |
76 | 76 |
500, /* default_code */ |
77 | 77 |
1, /* reparse_invite */ |
78 | 78 |
|
79 |
+ 0, /* tm_dns_failover_branch_failure -- if 1 in case 503 will be executed branch_failure route*/ |
|
79 | 80 |
0, /* tm_blst_503 -- if 1 blocklist 503 sources, using tm_blst_503_min, |
80 | 81 |
* tm_blst_503_max, tm_blst_503_default and the Retry-After header |
81 | 82 |
* in the 503 reply */ |
... | ... |
@@ -167,6 +168,8 @@ cfg_def_t tm_cfg_def[] = { |
167 | 168 |
"if set to 1, the CANCEL and negative ACK requests are " |
168 | 169 |
"constructed from the INVITE message which was sent out " |
169 | 170 |
"instead of building them from the received request"}, |
171 |
+ {"dns_failover_branch_failure", CFG_VAR_INT | CFG_ATOMIC, 0, 1, 0, 0, |
|
172 |
+ "if set to 1, branch_failure route will be executed in case 503 reply"}, |
|
170 | 173 |
{"blst_503", CFG_VAR_INT | CFG_ATOMIC, 0, 1, 0, 0, |
171 | 174 |
"if set to 1, blocklist 503 SIP response sources"}, |
172 | 175 |
{"blst_503_def_timeout", CFG_VAR_INT | CFG_ATOMIC, 0, 0, 0, 0, |
... | ... |
@@ -2495,30 +2495,30 @@ int reply_received( struct sip_msg *p_msg ) |
2495 | 2495 |
p_msg->fwd_send_flags.blst_imask|= |
2496 | 2496 |
uac->request.dst.send_flags.blst_imask & BLST_503; |
2497 | 2497 |
#ifdef USE_DNS_FAILOVER |
2498 |
- /* if this is a 503 reply, and the destination resolves to more ips, |
|
2499 |
- * add another branch/uac. |
|
2500 |
- * This code is out of LOCK_REPLIES() to minimize the time the |
|
2501 |
- * reply lock is held (the lock won't be held while sending the |
|
2502 |
- * message)*/ |
|
2503 |
- |
|
2504 |
- |
|
2505 |
- failover_continue = (failover_reply_codes_str.s!=NULL && failover_reply_codes_str.len>0 && |
|
2506 |
- t_failover_check_reply_code(msg_status)); |
|
2507 |
- |
|
2508 |
- if (cfg_get(core, core_cfg, use_dns_failover) && (msg_status==503 || failover_continue)) { |
|
2509 |
- branch_ret=add_uac_dns_fallback(t, t->uas.request, |
|
2510 |
- uac, !replies_locked); |
|
2511 |
- prev_branch=-1; |
|
2512 |
- while((branch_ret>=0) &&(branch_ret!=prev_branch)){ |
|
2513 |
- prev_branch=branch_ret; |
|
2514 |
- branch_ret=t_send_branch(t, branch_ret, t->uas.request , 0, 1); |
|
2515 |
- } |
|
2498 |
+ /* if this is a 503 reply, and the destination resolves to more ips, |
|
2499 |
+ * add another branch/uac. |
|
2500 |
+ * This code is out of LOCK_REPLIES() to minimize the time the |
|
2501 |
+ * reply lock is held (the lock won't be held while sending the |
|
2502 |
+ * message)*/ |
|
2503 |
+ |
|
2504 |
+ |
|
2505 |
+ failover_continue = (failover_reply_codes_str.s!=NULL && failover_reply_codes_str.len>0 && |
|
2506 |
+ t_failover_check_reply_code(msg_status)); |
|
2507 |
+ |
|
2508 |
+ if (cfg_get(core, core_cfg, use_dns_failover) && (msg_status==503 || failover_continue)) { |
|
2509 |
+ branch_ret=add_uac_dns_fallback(t, t->uas.request, |
|
2510 |
+ uac, !replies_locked); |
|
2511 |
+ prev_branch=-1; |
|
2512 |
+ while((branch_ret>=0) &&(branch_ret!=prev_branch)){ |
|
2513 |
+ prev_branch=branch_ret; |
|
2514 |
+ branch_ret=t_send_branch(t, branch_ret, t->uas.request , 0, 1); |
|
2516 | 2515 |
} |
2516 |
+ } |
|
2517 | 2517 |
#endif |
2518 | 2518 |
/* processing of on_reply block */ |
2519 | 2519 |
if ((onreply_route || sr_event_enabled(SREV_SIP_REPLY_OUT)) |
2520 | 2520 |
#ifdef USE_DNS_FAILOVER |
2521 |
- && (branch_ret<0) |
|
2521 |
+ && (cfg_get(tm, tm_cfg, tm_dns_failover_branch_failure) ? (branch_ret<0) : 1 ) |
|
2522 | 2522 |
#endif |
2523 | 2523 |
) { |
2524 | 2524 |
set_route_type(TM_ONREPLY_ROUTE); |
... | ... |
@@ -467,6 +467,8 @@ static param_export_t params[]={ |
467 | 467 |
{"default_reason", PARAM_STRING, &default_tm_cfg.default_reason }, |
468 | 468 |
{"reparse_invite", PARAM_INT, &default_tm_cfg.reparse_invite }, |
469 | 469 |
{"ac_extra_hdrs", PARAM_STR, &default_tm_cfg.ac_extra_hdrs }, |
470 |
+ {"dns_failover_branch_failure", PARAM_INT, |
|
471 |
+ &default_tm_cfg.tm_dns_failover_branch_failure}, |
|
470 | 472 |
{"blst_503", PARAM_INT, &default_tm_cfg.tm_blst_503 }, |
471 | 473 |
{"blst_503_def_timeout",PARAM_INT, &default_tm_cfg.tm_blst_503_default }, |
472 | 474 |
{"blst_503_min_timeout",PARAM_INT, &default_tm_cfg.tm_blst_503_min }, |