Browse code

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).

Andrei Pelinescu-Onciul authored on 19/02/2010 14:35:57
Showing 1 changed files
... ...
@@ -1844,7 +1844,6 @@ int reply_received( struct sip_msg  *p_msg )
1844 1844
 #endif
1845 1845
 #ifdef USE_DST_BLACKLIST
1846 1846
 	int blst_503_timeout;
1847
-	struct dest_info src;
1848 1847
 	struct hdr_field* hf;
1849 1848
 #endif
1850 1849
 #ifdef TMCB_ONSEND
... ...
@@ -1972,6 +1971,10 @@ int reply_received( struct sip_msg  *p_msg )
1972 1972
 			switch_rb_retr_to_t2(&uac->request);
1973 1973
 		}
1974 1974
 	}
1975
+	/* pre-set the ignore BLST_503 flag in the message, if the
1976
+	   corresponding branch had it set on send */
1977
+	p_msg->fwd_send_flags.blst_imask|=
1978
+		uac->request.dst.send_flags.blst_imask & BLST_503;
1975 1979
 	/* processing of on_reply block */
1976 1980
 	if (t->on_reply) {
1977 1981
 		set_route_type(ONREPLY_ROUTE);
... ...
@@ -2008,10 +2011,13 @@ int reply_received( struct sip_msg  *p_msg )
2008 2008
 	}
2009 2009
 #ifdef USE_DST_BLACKLIST
2010 2010
 		/* add temporary to the blacklist the source of a 503 reply */
2011
-		if (cfg_get(tm, tm_cfg, tm_blst_503)
2012
-			&& cfg_get(core, core_cfg, use_dst_blacklist)
2013
-			&& (msg_status==503)
2014
-		){
2011
+		if (	(msg_status==503) &&
2012
+				cfg_get(tm, tm_cfg, tm_blst_503) &&
2013
+				/* check if the request sent on the branch had the the
2014
+				   blst 503 ignore flags set or it was set in the onreply_r*/
2015
+				should_blacklist_su(BLST_503, &p_msg->fwd_send_flags,
2016
+										p_msg->rcv.proto, &p_msg->rcv.src_su)
2017
+			){
2015 2018
 			blst_503_timeout=cfg_get(tm, tm_cfg, tm_blst_503_default);
2016 2019
 			if ((parse_headers(p_msg, HDR_RETRY_AFTER_F, 0)==0) && 
2017 2020
 				(p_msg->parsed_flag & HDR_RETRY_AFTER_F)){
... ...
@@ -2027,12 +2033,9 @@ int reply_received( struct sip_msg  *p_msg )
2027 2027
 					}
2028 2028
 			}
2029 2029
 			if (blst_503_timeout){
2030
-				src.send_sock=0;
2031
-				src.to=p_msg->rcv.src_su;
2032
-				src.id=p_msg->rcv.proto_reserved1;
2033
-				src.proto=p_msg->rcv.proto;
2034
-				dst_blacklist_add_to(BLST_503, &src,  p_msg, 
2035
-									S_TO_TICKS(blst_503_timeout));
2030
+				dst_blacklist_force_su_to(BLST_503, p_msg->rcv.proto,
2031
+											&p_msg->rcv.src_su, p_msg,
2032
+											S_TO_TICKS(blst_503_timeout));
2036 2033
 			}
2037 2034
 		}
2038 2035
 #endif /* USE_DST_BLACKLIST */