Explorar o código

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 %!s(int64=23) %!d(string=hai) anos
pai
achega
2c4c8a7c2b
Modificáronse 5 ficheiros con 29 adicións e 17 borrados
  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.
 might get intermixes with writes from other writers.
 You can easily use it via Unix command-line tools, see the following
 You can easily use it via Unix command-line tools, see the following
 example:
 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
 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
 - we don't have authentication merging on forking
 - branch tid is not used yet
 - branch tid is not used yet
 - local ACK/CANCELs copy'n'pastes Route and ignores deleted
 - 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 );
 		sip_msg_free_unsafe( dead_cell->uas.request );
 	if ( dead_cell->uas.response.buffer )
 	if ( dead_cell->uas.response.buffer )
 		shm_free_unsafe( dead_cell->uas.response.buffer );
 		shm_free_unsafe( dead_cell->uas.response.buffer );
+#ifdef TOTAG
 	if (dead_cell->uas.to_tag.s)
 	if (dead_cell->uas.to_tag.s)
 		shm_free_unsafe(dead_cell->uas.to_tag.s);
 		shm_free_unsafe(dead_cell->uas.to_tag.s);
+#endif
 
 
 	/* completion callback */
 	/* completion callback */
 	if (dead_cell->cbp) shm_free_unsafe(dead_cell->cbp);
 	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 sip_msg   *request;
 	struct retr_buf  response;
 	struct retr_buf  response;
 	unsigned int     status;
 	unsigned int     status;
+#ifdef TOTAG
 	str              to_tag;
 	str              to_tag;
+#endif
 	unsigned int     isACKed;
 	unsigned int     isACKed;
 }ua_server_type;
 }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 ... */
 			/* To only the uri and ... */
 			if (get_to(t_msg)->uri.len!=get_to(p_msg)->uri.len)
 			if (get_to(t_msg)->uri.len!=get_to(p_msg)->uri.len)
 				continue;
 				continue;
+#ifdef TOTAG
 			/* ... its to-tag compared to reply's tag */
 			/* ... its to-tag compared to reply's tag */
 			if (p_cell->uas.to_tag.len!=get_to(p_msg)->tag_value.len)
 			if (p_cell->uas.to_tag.len!=get_to(p_msg)->tag_value.len)
 				continue;
 				continue;
+#endif
 
 
 			/* we first skip r-uri and Via and proceed with
 			/* we first skip r-uri and Via and proceed with
 			   content of other header-fields */
 			   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 (!EQ_STR(from)) continue;
 			if (memcmp(get_to(t_msg)->uri.s, get_to(p_msg)->uri.s,
 			if (memcmp(get_to(t_msg)->uri.s, get_to(p_msg)->uri.s,
 				get_to(t_msg)->uri.len)!=0) continue;
 				get_to(t_msg)->uri.len)!=0) continue;
+#ifdef TOTAG
 			if (
 			if (
 #ifdef _BUG
 #ifdef _BUG
 				p_cell->uas.to_tag.len!=0 /* to-tags empty */ || 
 				p_cell->uas.to_tag.len!=0 /* to-tags empty */ || 
 #endif
 #endif
 				memcmp(p_cell->uas.to_tag.s, get_to(p_msg)->tag_value.s,
 				memcmp(p_cell->uas.to_tag.s, get_to(p_msg)->tag_value.s,
 				p_cell->uas.to_tag.len)!=0) continue;
 				p_cell->uas.to_tag.len)!=0) continue;
+#endif
 	
 	
 			/* ok, now only r-uri or via can mismatch; they must match
 			/* 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
 			   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;
 	unsigned int res_len;
 	int relayed_code;
 	int relayed_code;
 	struct sip_msg *relayed_msg;
 	struct sip_msg *relayed_msg;
+#ifdef TOTAG
 	str	to_tag;
 	str	to_tag;
+#endif
 	enum rps reply_status;
 	enum rps reply_status;
 	/* retransmission structure of outbound reply and request */
 	/* retransmission structure of outbound reply and request */
 	struct retr_buf *uas_rb;
 	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;
 		uas_rb->buffer_len = res_len;
 		memcpy( uas_rb->buffer, buf, res_len );
 		memcpy( uas_rb->buffer, buf, res_len );
+#ifdef TOTAG
 		/* to tag now */
 		/* to tag now */
 		if (relayed_code>=300 && t->is_invite) {
 		if (relayed_code>=300 && t->is_invite) {
 			if (relayed_msg!=FAKED_REPLY) {
 			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;
 				t->uas.to_tag.len=0;
 			}
 			}
 		}
 		}
+#endif
 
 
 		/* update the status ... */
 		/* update the status ... */
 		t->uas.status = relayed_code;
 		t->uas.status = relayed_code;
@@ -607,9 +611,11 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 	/* success */
 	/* success */
 	return reply_status;
 	return reply_status;
 
 
+#ifdef TOTAG
 error04:
 error04:
 	shm_free( uas_rb->buffer );
 	shm_free( uas_rb->buffer );
 	uas_rb->buffer=0;
 	uas_rb->buffer=0;
+#endif
 error03:
 error03:
 	pkg_free( buf );
 	pkg_free( buf );
 error02:
 error02: