[Serusers] New feature for the tm module [sticky proxy]

Maxim Sobolev sobomax at FreeBSD.org
Tue Feb 4 00:35:08 CET 2003


Folks,

We are currently trying to implement owerflow routing with sip and b2bua.
Our network setup looks like the following (two GWs here is for simplicity,
actually there would be dozens of them):

						---------
					     /--|PSTN GW|-\
----  -----------------  -------   /~~~~~~\/    ---------   \ /~~~~~~~~\
|UA|--|PROXY/REGISTRAR|--|B2BUA|--<IP CLOUD>                 <PSTN CLOUD>
----  -----------------  -------   \______/\    ---------   / \________/
					     \--|PSTN GW|-/
						---------

Since potentially each destination in the PSTN could be reached through
more than one GW we would like to use that for adding some more robustness
to the system, beause from time to time some of gateways might be unavailable
for one reason of another (network outage, maintenance, overload etc.).
t_on_negative() looks like a pretty suitable feature for the job modulo
that we need to add some scheme for distinguishing real failures, such as
"number is busy", from transient ones.

The problem here is that b2bua is unable to do prefix-based routing, while
we can't put b2bua between the UA and PROXY because for accounting reasons
we should be able to get from b2bua IP number of the gateway the call was
forwarded to. Therefore, we do gateway selection based on prefix in ser
(using rewritehostport) and then just forward request to the b2bua using
t_relay_to(). To catch failures and perform retries we use t_on_negative()
and number of reply_route[] blocks and it is where the problem lies -
after appending a new branch ser forwards the request to the host:port
specified in the uri directly, but not through the b2bua.

Attached patch adds a new variable sticky_relay_to, which if set to non-zero
value instructs ser to record proxy address to which transaction was
originally forwarded with t_relay_to(). On failure ser forwards request to
that address if another branch was appended in reply_route[].

I think that it is generally useful feature and it would be nice to see
it integrated into the next release.

Thanks!

-Maxim
-------------- next part --------------
--- modules/tm/README	2003/02/03 22:43:54	1.1
+++ modules/tm/README	2003/02/03 22:48:29
@@ -107,6 +107,14 @@
 			turned it off for a transaction (like acc does to avoid
 			unaccounted transactions due to expired timer)
 
+Name:		sticky_relay_to
+Type:		int (boolean)
+Default:	0 (FALSE)
+Desc:		if set, in conjunction with t_on_negative() and t_relay_to()
+			it causes all branches appended in reply_route[]
+			block(s) to be forwarded to the same proxy as original
+			request.
+
 Exported Functions:
 -------------------
 
--- modules/tm/t_funcs.c	2003/02/03 14:08:42	1.1
+++ modules/tm/t_funcs.c	2003/02/03 22:43:35
@@ -41,6 +41,7 @@
 #include "config.h"
 #include "t_stats.h"
 
+int sticky_relay_to = 0;
 
 /* ----------------------------------------------------- */
 
@@ -257,6 +258,11 @@
 	*/
 	t=get_t();
 	t->local=replicate;
+	if (proxy != NULL && sticky_relay_to != 0) {
+		t->sticky_proxy = 1;
+		t->proxy = *proxy;
+		t->proxy.next = NULL;
+	}
 
 	/* INVITE processing might take long, partcularly because of DNS
 	   look-ups -- let upstream know we're working on it */
--- modules/tm/t_funcs.h	2003/02/03 22:41:32	1.1
+++ modules/tm/t_funcs.h	2003/02/03 22:41:56
@@ -59,6 +59,7 @@
 struct cell;
 
 extern int noisy_ctimer;
+extern int sticky_relay_to;
 
 
 /* send a private buffer: utilize a retransmission structure
--- modules/tm/h_table.h.orig	Mon Nov 11 23:34:54 2002
+++ modules/tm/h_table.h	Mon Feb  3 16:08:30 2003
@@ -225,6 +227,10 @@
 #endif
 	/* has the transaction been scheduled to die? */
 	enum kill_reason kr;
+
+	/* "Sticky" proxy */
+	int sticky_proxy;
+	struct proxy_l proxy;
 }cell_type;
 
 
--- modules/tm/t_reply.c.orig	Tue Oct 22 00:24:43 2002
+++ modules/tm/t_reply.c	Mon Feb  3 16:20:00 2003
@@ -223,8 +236,10 @@
 		/* look if the callback introduced new branches ... */
 		init_branch_iterator();
 		if (next_branch(&dummy)) {
+			struct proxy_l *proxy = Trans->sticky_proxy ?
+			    &Trans->proxy : NULL;
 			if (t_forward_nonack(Trans, Trans->uas.request, 
-						(struct proxy_l *) 0 ) <0) {
+						proxy ) <0) {
 				/* error ... behave as if we did not try to
 				   add a new branch */
 				*should_store=0;
--- modules/tm/tm.c.orig	Tue Oct 22 00:24:43 2002
+++ modules/tm/tm.c	Tue Feb  4 00:41:07 2003
@@ -195,7 +200,8 @@
 		"retr_timer1p3",
 		"retr_timer2",
 		"noisy_ctimer",
-		"uac_from"
+		"uac_from",
+		"sticky_relay_to"
 	},
 	(modparam_t[]) { /* variable types */
 		INT_PARAM, /* fr_timer */
@@ -208,6 +214,7 @@
 		INT_PARAM, /* retr_timer2 */
 		INT_PARAM, /* noisy_ctimer */
 		STR_PARAM, /* uac_from */
+		INT_PARAM, /* sticky_relay_to */
 	},
 	(void *[]) { /* variable pointers */
 		&(timer_id2timeout[FR_TIMER_LIST]),
@@ -219,9 +226,10 @@
 		&(timer_id2timeout[RT_T1_TO_3]),
 		&(timer_id2timeout[RT_T2]),
 		&noisy_ctimer,
-		&uac_from
+		&uac_from,
+		&sticky_relay_to
 	},
-	11,      /* Number of module paramers */
+	12,      /* Number of module paramers */
 
 	mod_init, /* module initialization function */
 	(response_function) t_on_reply,


More information about the sr-users mailing list