[sr-dev] git:andrei/blst_send_flags: tm: blacklist on 503 reply fixed for send flags

Andrei Pelinescu-Onciul andrei at iptel.org
Fri Feb 19 16:27:47 CET 2010


Module: sip-router
Branch: andrei/blst_send_flags
Commit: 0f2375f9216fd7f431e91d02f4ccc5dc9e4e5730
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0f2375f9216fd7f431e91d02f4ccc5dc9e4e5730

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Fri Feb 19 15:35:57 2010 +0100

tm: blacklist on 503 reply fixed for send flags

Blacklisting the source of a 503 reply now obeys also the
blacklist ignore masks (both global and per message).
The ignore 503 blacklist flag can be set (and it will be obeyed)
in any route (be it main route, on branch, on send or the on_reply
route). E.g.: using blst_set_ignore(32) in the onsend_route for a
specific destination would cause the ignore 503 flag to be
inherited by the 503 reply (this is the only blacklist flag that
it's inherited this way).

---

 modules/tm/t_reply.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index 0b16fae..4e53584 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -1844,7 +1844,6 @@ int reply_received( struct sip_msg  *p_msg )
 #endif
 #ifdef USE_DST_BLACKLIST
 	int blst_503_timeout;
-	struct dest_info src;
 	struct hdr_field* hf;
 #endif
 #ifdef TMCB_ONSEND
@@ -1972,6 +1971,10 @@ int reply_received( struct sip_msg  *p_msg )
 			switch_rb_retr_to_t2(&uac->request);
 		}
 	}
+	/* pre-set the ignore BLST_503 flag in the message, if the
+	   corresponding branch had it set on send */
+	p_msg->fwd_send_flags.blst_imask|=
+		uac->request.dst.send_flags.blst_imask & BLST_503;
 	/* processing of on_reply block */
 	if (t->on_reply) {
 		set_route_type(ONREPLY_ROUTE);
@@ -2008,10 +2011,13 @@ int reply_received( struct sip_msg  *p_msg )
 	}
 #ifdef USE_DST_BLACKLIST
 		/* add temporary to the blacklist the source of a 503 reply */
-		if (cfg_get(tm, tm_cfg, tm_blst_503)
-			&& cfg_get(core, core_cfg, use_dst_blacklist)
-			&& (msg_status==503)
-		){
+		if (	(msg_status==503) &&
+				cfg_get(tm, tm_cfg, tm_blst_503) &&
+				/* check if the request sent on the branch had the the
+				   blst 503 ignore flags set or it was set in the onreply_r*/
+				should_blacklist_su(BLST_503, &p_msg->fwd_send_flags,
+										p_msg->rcv.proto, &p_msg->rcv.src_su)
+			){
 			blst_503_timeout=cfg_get(tm, tm_cfg, tm_blst_503_default);
 			if ((parse_headers(p_msg, HDR_RETRY_AFTER_F, 0)==0) && 
 				(p_msg->parsed_flag & HDR_RETRY_AFTER_F)){
@@ -2027,12 +2033,9 @@ int reply_received( struct sip_msg  *p_msg )
 					}
 			}
 			if (blst_503_timeout){
-				src.send_sock=0;
-				src.to=p_msg->rcv.src_su;
-				src.id=p_msg->rcv.proto_reserved1;
-				src.proto=p_msg->rcv.proto;
-				dst_blacklist_add_to(BLST_503, &src,  p_msg, 
-									S_TO_TICKS(blst_503_timeout));
+				dst_blacklist_force_su_to(BLST_503, p_msg->rcv.proto,
+											&p_msg->rcv.src_su, p_msg,
+											S_TO_TICKS(blst_503_timeout));
 			}
 		}
 #endif /* USE_DST_BLACKLIST */




More information about the sr-dev mailing list