Browse code

Fixing improper blacklisting of destinations because of non-INVITE timeouts. Two new module parameters are introduced:

- blst_methods_add:
bitmap of method types that can trigger blacklisting
(only INVITE by default)

- blst_methods_lookup:
bitmap of method types that are looked up in the blacklist
(everything except BYE by default)

closes SER-331

Miklos Tirpak authored on 14/11/2007 15:30:21
Showing 6 changed files
... ...
@@ -370,4 +370,61 @@ modparam("tm", "blst_503_max_timeout", 604800)
370 370
 	</example>
371 371
     </section>
372 372
 
373
+    <section id="blst_methods_add">
374
+	<title><varname>blst_methods_add</varname> (unsigned integer)</title>
375
+	<para>
376
+		Bitmap of method types that trigger blacklisting on
377
+		transaction timeouts. (This setting has no
378
+		effect on blacklisting because of send failures.)
379
+	</para>
380
+	<para>
381
+		The following values are associated to the request methods:
382
+		INVITE=1, CANCEL=2, ACK=4 (not retransmitted, thus, never
383
+		times-out), BYE=8, INFO=16, REGISTER=32, SUBSCRIBE=64,
384
+		NOTIFY=126, OTHER=256 (all the unknown types).
385
+		Check parser/msg_parser.h for farther details.
386
+	</para>
387
+	<para>
388
+		Change the value carefully, because requests not having
389
+		provisional response (everything but INVITE) can easily
390
+		cause the next hop to be inserted into the blacklist
391
+		by mistake. For exmaple the next hop is a proxy, it is alive,
392
+		but waiting for the response of the UAS, and has higher
393
+		fr_timer value.
394
+	</para>
395
+	<para>
396
+		The default value is 1, only INVITEs trigger blacklisting
397
+	</para>
398
+	<example>
399
+	    <title>Set <varname>blst_methods_add</varname> parameter</title>
400
+	    <programlisting>
401
+...
402
+# INVITEs and REGISTERs trigger blacklisting
403
+modparam("tm", "blst_methods_add", 33)
404
+...
405
+	    </programlisting>
406
+	</example>
407
+    </section>
408
+
409
+    <section id="blst_methods_lookup">
410
+	<title><varname>blst_methods_lookup</varname> (unsigned integer)</title>
411
+	<para>
412
+		Bitmap of method types that are looked-up in the blacklist
413
+		before statefull forwarding.
414
+		See also <varname>blst_methods_add</varname>
415
+	</para>
416
+	<para>
417
+		The default value is 4294967287, every method type except BYE.
418
+		(We try to deliver BYEs no matter what)
419
+	</para>
420
+	<example>
421
+	    <title>Set <varname>blst_methods_lookup</varname> parameter</title>
422
+	    <programlisting>
423
+...
424
+# lookup only INVITEs
425
+modparam("tm", "blst_methods_lookup", 1)
426
+...
427
+	    </programlisting>
428
+	</example>
429
+    </section>
373 430
 </section>
... ...
@@ -690,7 +690,10 @@ int t_send_branch( struct cell *t, int branch, struct sip_msg* p_msg ,
690 690
 		return -1; /* drop, try next branch */
691 691
 	}
692 692
 #ifdef USE_DST_BLACKLIST
693
-	if (use_dst_blacklist){
693
+	if (use_dst_blacklist
694
+		&& p_msg
695
+		&& (p_msg->REQ_METHOD & tm_blst_methods_lookup)
696
+	){
694 697
 		if (dst_is_blacklisted(&uac->request.dst, p_msg)){
695 698
 			su2ip_addr(&ip, &uac->request.dst.to);
696 699
 			DBG("t_send_branch: blacklisted destination: %s:%d (%d)\n",
... ...
@@ -145,6 +145,10 @@ int tm_blst_503_min=0; /* in s */
145 145
 /* maximum 503 blacklist time */
146 146
 int tm_blst_503_max=3600; /* in s */
147 147
 
148
+/* backlist only INVITE timeouts by default */
149
+unsigned int tm_blst_methods_add=METHOD_INVITE;
150
+/* look-up the blacklist for every method except BYE by default */
151
+unsigned int tm_blst_methods_lookup=~METHOD_BYE;
148 152
 
149 153
 /* are we processing original or shmemed request ? */
150 154
 enum route_mode rmode=MODE_REQUEST;
... ...
@@ -44,6 +44,8 @@ extern int tm_blst_503;
44 44
 extern int tm_blst_503_default;  /* in s */
45 45
 extern int tm_blst_503_min;      /* in s */
46 46
 extern int tm_blst_503_max;      /* in s */
47
+extern unsigned int tm_blst_methods_add;
48
+extern unsigned int tm_blst_methods_lookup;
47 49
 
48 50
 /* reply processing status */
49 51
 enum rps {
... ...
@@ -455,9 +455,13 @@ inline static void final_response_handler(	struct retr_buf* r_buf,
455 455
 			(t->uac[r_buf->branch].last_received==0)){
456 456
 		/* no reply received */
457 457
 #ifdef USE_DST_BLACKLIST
458
-		if (use_dst_blacklist)
458
+		if (use_dst_blacklist
459
+        		&& r_buf->my_T
460
+			&& r_buf->my_T->uas.request
461
+			&& (r_buf->my_T->uas.request->REQ_METHOD & tm_blst_methods_add)
462
+		)
459 463
 			dst_blacklist_add( BLST_ERR_TIMEOUT, &r_buf->dst,
460
-				(r_buf->my_T)?r_buf->my_T->uas.request:NULL);
464
+						r_buf->my_T->uas.request);
461 465
 #endif
462 466
 #ifdef USE_DNS_FAILOVER
463 467
 		/* if this is an invite, the destination resolves to more ips, and
... ...
@@ -364,6 +364,8 @@ static param_export_t params[]={
364 364
 	{"blst_503_def_timeout",PARAM_INT, &tm_blst_503_default                  },
365 365
 	{"blst_503_min_timeout",PARAM_INT, &tm_blst_503_min                      },
366 366
 	{"blst_503_max_timeout",PARAM_INT, &tm_blst_503_max                      },
367
+	{"blst_methods_add",    PARAM_INT, &tm_blst_methods_add                  },
368
+	{"blst_methods_lookup", PARAM_INT, &tm_blst_methods_lookup               },
367 369
 	{0,0,0}
368 370
 };
369 371