Browse Source

change: to-tags no more compared in ACK lookups -- that eliminates
an unlikely race conditions (reading transactional to-tag on ACK
lookup whereas writing a new to tag from 200/OK) and helps UACs
who screw up to-tags

Jiri Kuthan 23 years ago
parent
commit
2c4c8a7c2b
5 changed files with 29 additions and 17 deletions
  1. 15 17
      modules/tm/README
  2. 2 0
      modules/tm/h_table.c
  3. 2 0
      modules/tm/h_table.h
  4. 4 0
      modules/tm/t_lookup.c
  5. 6 0
      modules/tm/t_reply.c

+ 15 - 17
modules/tm/README

@@ -256,31 +256,29 @@ Note the the request write must be atomic, otherwise the request
 might get intermixes with writes from other writers.
 You can easily use it via Unix command-line tools, see the following
 example:
----
-[jiri@bat jiri]$ cat > /tmp/fifo
-:t_uac:xxx
-MESSAGE
-sip:[email protected]
-header:value
-foo:bar
-bznk:hjhjk
-p_header: p_value
 
-body body body
-yet body
-end of body
+cat test/transaction.fifo > /tmp/ser_fifo
+--
 
+Defines
+-------
+- TOTAG enables matching of acknowledgemnts including to-tags;
+  it is disabled by default for two reasons:
+  a) it eliminates an unlikely race condition in which
+     transaction's to-tag is being rewritten by a 200 OK
+     whereas an ACK is being looked up by to-tag
+  b) it makes UACs happy who set wrong to-tags
 
+  It should not make a difference, as there may be only one
+  negative reply sent upstream and 200/ACKs are not matched
+  as they consititute another transaction. It will make no
+  difference at all when the new magic cookie matching is
+  enabled.
 
----
-or use an example file and call cat test/transaction.fifo > /tmp/fifo
 
 
 Known Issues
 -----------
-- need to revisit profiling again
-- review whether there is not potential for to-tag
-  rewriting and ACK matching
 - we don't have authentication merging on forking
 - branch tid is not used yet
 - local ACK/CANCELs copy'n'pastes Route and ignores deleted

+ 2 - 0
modules/tm/h_table.c

@@ -90,8 +90,10 @@ void free_cell( struct cell* dead_cell )
 		sip_msg_free_unsafe( dead_cell->uas.request );
 	if ( dead_cell->uas.response.buffer )
 		shm_free_unsafe( dead_cell->uas.response.buffer );
+#ifdef TOTAG
 	if (dead_cell->uas.to_tag.s)
 		shm_free_unsafe(dead_cell->uas.to_tag.s);
+#endif
 
 	/* completion callback */
 	if (dead_cell->cbp) shm_free_unsafe(dead_cell->cbp);

+ 2 - 0
modules/tm/h_table.h

@@ -106,7 +106,9 @@ typedef struct ua_server
 	struct sip_msg   *request;
 	struct retr_buf  response;
 	unsigned int     status;
+#ifdef TOTAG
 	str              to_tag;
+#endif
 	unsigned int     isACKed;
 }ua_server_type;
 

+ 4 - 0
modules/tm/t_lookup.c

@@ -191,9 +191,11 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
 			/* To only the uri and ... */
 			if (get_to(t_msg)->uri.len!=get_to(p_msg)->uri.len)
 				continue;
+#ifdef TOTAG
 			/* ... its to-tag compared to reply's tag */
 			if (p_cell->uas.to_tag.len!=get_to(p_msg)->tag_value.len)
 				continue;
+#endif
 
 			/* we first skip r-uri and Via and proceed with
 			   content of other header-fields */
@@ -205,12 +207,14 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
 			if (!EQ_STR(from)) continue;
 			if (memcmp(get_to(t_msg)->uri.s, get_to(p_msg)->uri.s,
 				get_to(t_msg)->uri.len)!=0) continue;
+#ifdef TOTAG
 			if (
 #ifdef _BUG
 				p_cell->uas.to_tag.len!=0 /* to-tags empty */ || 
 #endif
 				memcmp(p_cell->uas.to_tag.s, get_to(p_msg)->tag_value.s,
 				p_cell->uas.to_tag.len)!=0) continue;
+#endif
 	
 			/* ok, now only r-uri or via can mismatch; they must match
 			   for non-2xx; if it is a 2xx, we don't try to match

+ 6 - 0
modules/tm/t_reply.c

@@ -486,7 +486,9 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 	unsigned int res_len;
 	int relayed_code;
 	struct sip_msg *relayed_msg;
+#ifdef TOTAG
 	str	to_tag;
+#endif
 	enum rps reply_status;
 	/* retransmission structure of outbound reply and request */
 	struct retr_buf *uas_rb;
@@ -569,6 +571,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 		}
 		uas_rb->buffer_len = res_len;
 		memcpy( uas_rb->buffer, buf, res_len );
+#ifdef TOTAG
 		/* to tag now */
 		if (relayed_code>=300 && t->is_invite) {
 			if (relayed_msg!=FAKED_REPLY) {
@@ -587,6 +590,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 				t->uas.to_tag.len=0;
 			}
 		}
+#endif
 
 		/* update the status ... */
 		t->uas.status = relayed_code;
@@ -607,9 +611,11 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 	/* success */
 	return reply_status;
 
+#ifdef TOTAG
 error04:
 	shm_free( uas_rb->buffer );
 	uas_rb->buffer=0;
+#endif
 error03:
 	pkg_free( buf );
 error02: