Ver código fonte

- statefull replies are sent out exactly on the same interface on which the
request was received;
- note that the previous version was broken since get_send_socket(request)
was called to determin the outgoing interface for relies; this was leading
to sending back replies on the forced interfaced set for request forwarding!

Bogdan-Andrei Iancu 20 anos atrás
pai
commit
ddaf2976d0
2 arquivos alterados com 22 adições e 10 exclusões
  1. 8 6
      modules/tm/t_lookup.c
  2. 14 4
      modules/tm/t_reply.c

+ 8 - 6
modules/tm/t_lookup.c

@@ -77,6 +77,8 @@
  * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  * 2004-02-13: t->is_invite and t->local replaced with flags (bogdan)
  * 2004-10-10: use of mhomed disabled for replies (jiri)
+ * 2005-02-01: use the incoming request interface for sending the replies
+ *             - changes in init_rb() (bogdan)
  */
 
 #include "defs.h"
@@ -907,7 +909,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch )
 
 int init_rb( struct retr_buf *rb, struct sip_msg *msg)
 {
-	struct socket_info* send_sock;
+	/*struct socket_info* send_sock;*/
 	struct via_body* via;
 	int proto;
 	int backup_mhomed;
@@ -933,17 +935,17 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg)
 	*/
 	backup_mhomed=mhomed;
 	mhomed=0;
-	send_sock=get_send_socket(msg, &rb->dst.to, proto);
 	mhomed=backup_mhomed;
+	/* use for sending replies the incoming interface of the request -bogdan */
+	/*send_sock=get_send_socket(msg, &rb->dst.to, proto);
 	if (send_sock==0) {
 		LOG(L_ERR, "ERROR: init_rb: cannot fwd to af %d, proto %d "
 			"no socket\n", rb->dst.to.s.sa_family, proto);
 		ser_error=E_BAD_VIA;
 		return 0;
-	}
-	rb->dst.send_sock=send_sock;
-	
-    return 1;
+	}*/
+	rb->dst.send_sock=msg->rcv.bind_address;
+	return 1;
 }
 
 

+ 14 - 4
modules/tm/t_reply.c

@@ -62,6 +62,8 @@
  *  2004-02-18  fifo_t_reply imported from vm module (bogdan)
  *  2004-08-23  avp list is available from failure/on_reply routes (bogdan)
  *  2004-10-01  added a new param.: restart_fr_on_each_reply (andrei)
+ *  2005-03-01  force for statefull replies the incoming interface of 
+ *              the request (bogdan)
  */
 
 
@@ -408,13 +410,17 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
 	/* first check if we managed to resolve topmost Via -- if
 	   not yet, don't try to retransmit
 	*/
+	/*
+	   response.dst.send_sock is valid all the time now, as it's taken
+	   from original request -bogdan
 	if (!trans->uas.response.dst.send_sock) {
 		LOG(L_ERR, "ERROR: _reply_light: no resolved dst to send reply to\n");
 	} else {
-		SEND_PR_BUFFER( rb, buf, len );
-		DBG("DEBUG: reply sent out. buf=%p: %.9s..., shmem=%p: %.9s\n", 
-			buf, buf, rb->buffer, rb->buffer );
-	}
+	*/
+	assert(trans->uas.response.dst.send_sock);
+	SEND_PR_BUFFER( rb, buf, len );
+	DBG("DEBUG: reply sent out. buf=%p: %.9s..., shmem=%p: %.9s\n", 
+		buf, buf, rb->buffer, rb->buffer );
 	pkg_free( buf ) ;
 	DBG("DEBUG: _reply_light: finished\n");
 	return 1;
@@ -847,11 +853,15 @@ int t_retransmit_reply( struct cell *t )
 	/* first check if we managed to resolve topmost Via -- if
 	   not yet, don't try to retransmit
 	*/
+	/* response.dst.send_sock is valid all the time now, as it's taken
+	   from original request -bogdan
 	if (!t->uas.response.dst.send_sock) {
 		LOG(L_WARN, "WARNING: t_retransmit_reply: "
 			"no resolved dst to retransmit\n");
 		return -1;
 	}
+	*/
+	assert(t->uas.response.dst.send_sock);
 
 	/* we need to lock the transaction as messages from
 	   upstream may change it continuously