* remove syn_branch parameter and functionality from core and tm module for
calculating the Via branch parameter
* reported from Richard Brady, rnbrady at gmail dot com to sr-dev
* kamailio is not standard compliant with this setting enabled (RFC 3261,
17.2.3 and 16.11) for stateless forwarding of replies
* the performance reason that motivated this functionality are today not
valid anymore, even embedded systems have more than enough power to
calculate MD5 and other modules uses more expensive operations anyway
* adapt a bunch of example and test configuration that used this parameter,
it has been also removed from the core cookbook wiki
... | ... |
@@ -393,7 +393,6 @@ CHILDREN children |
393 | 393 |
SOCKET_WORKERS socket_workers |
394 | 394 |
CHECK_VIA check_via |
395 | 395 |
PHONE2TEL phone2tel |
396 |
-SYN_BRANCH syn_branch |
|
397 | 396 |
MEMLOG "memlog"|"mem_log" |
398 | 397 |
MEMDBG "memdbg"|"mem_dbg" |
399 | 398 |
MEMSUM "mem_summary" |
... | ... |
@@ -792,7 +791,6 @@ IMPORTFILE "import_file" |
792 | 792 |
<INITIAL>{SOCKET_WORKERS} { count(); yylval.strval=yytext; return SOCKET_WORKERS; } |
793 | 793 |
<INITIAL>{CHECK_VIA} { count(); yylval.strval=yytext; return CHECK_VIA; } |
794 | 794 |
<INITIAL>{PHONE2TEL} { count(); yylval.strval=yytext; return PHONE2TEL; } |
795 |
-<INITIAL>{SYN_BRANCH} { count(); yylval.strval=yytext; return SYN_BRANCH; } |
|
796 | 795 |
<INITIAL>{MEMLOG} { count(); yylval.strval=yytext; return MEMLOG; } |
797 | 796 |
<INITIAL>{MEMDBG} { count(); yylval.strval=yytext; return MEMDBG; } |
798 | 797 |
<INITIAL>{MEMSUM} { count(); yylval.strval=yytext; return MEMSUM; } |
... | ... |
@@ -440,7 +440,6 @@ extern char *finame; |
440 | 440 |
%token SOCKET_WORKERS |
441 | 441 |
%token CHECK_VIA |
442 | 442 |
%token PHONE2TEL |
443 |
-%token SYN_BRANCH |
|
444 | 443 |
%token MEMLOG |
445 | 444 |
%token MEMDBG |
446 | 445 |
%token MEMSUM |
... | ... |
@@ -958,8 +957,6 @@ assign_stm: |
958 | 958 |
| CHECK_VIA EQUAL error { yyerror("boolean value expected"); } |
959 | 959 |
| PHONE2TEL EQUAL NUMBER { phone2tel=$3; } |
960 | 960 |
| PHONE2TEL EQUAL error { yyerror("boolean value expected"); } |
961 |
- | SYN_BRANCH EQUAL NUMBER { syn_branch=$3; } |
|
962 |
- | SYN_BRANCH EQUAL error { yyerror("boolean value expected"); } |
|
963 | 961 |
| MEMLOG EQUAL intno { default_core_cfg.memlog=$3; } |
964 | 962 |
| MEMLOG EQUAL error { yyerror("int value expected"); } |
965 | 963 |
| MEMDBG EQUAL intno { default_core_cfg.memdbg=$3; } |
... | ... |
@@ -535,31 +535,23 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port, |
535 | 535 |
} |
536 | 536 |
}/* dst */ |
537 | 537 |
send_info->send_flags=msg->fwd_send_flags; |
538 |
- /* calculate branch for outbound request; if syn_branch is turned off, |
|
538 |
+ /* calculate branch for outbound request; |
|
539 | 539 |
calculate is from transaction key, i.e., as an md5 of From/To/CallID/ |
540 | 540 |
CSeq exactly the same way as TM does; good for reboot -- than messages |
541 | 541 |
belonging to transaction lost due to reboot will still be forwarded |
542 | 542 |
with the same branch parameter and will be match-able downstream |
543 |
- |
|
544 |
- if it is turned on, we don't care about reboot; we simply put a simple |
|
545 |
- value in there; better for performance |
|
546 | 543 |
*/ |
547 |
- if (syn_branch ) { |
|
548 |
- memcpy(msg->add_to_branch_s, "z9hG4bKcydzigwkX", 16); |
|
549 |
- msg->add_to_branch_len=16; |
|
550 |
- } else { |
|
551 |
- if (!char_msg_val( msg, md5 )) { /* parses transaction key */ |
|
552 |
- LOG(L_ERR, "ERROR: forward_request: char_msg_val failed\n"); |
|
553 |
- ret=E_UNSPEC; |
|
554 |
- goto error; |
|
555 |
- } |
|
556 |
- msg->hash_index=hash( msg->callid->body, get_cseq(msg)->number); |
|
557 |
- if (!branch_builder( msg->hash_index, 0, md5, 0 /* 0-th branch */, |
|
558 |
- msg->add_to_branch_s, &msg->add_to_branch_len )) { |
|
559 |
- LOG(L_ERR, "ERROR: forward_request: branch_builder failed\n"); |
|
560 |
- ret=E_UNSPEC; |
|
561 |
- goto error; |
|
562 |
- } |
|
544 |
+ if (!char_msg_val( msg, md5 )) { /* parses transaction key */ |
|
545 |
+ LOG(L_ERR, "ERROR: forward_request: char_msg_val failed\n"); |
|
546 |
+ ret=E_UNSPEC; |
|
547 |
+ goto error; |
|
548 |
+ } |
|
549 |
+ msg->hash_index=hash( msg->callid->body, get_cseq(msg)->number); |
|
550 |
+ if (!branch_builder( msg->hash_index, 0, md5, 0 /* 0-th branch */, |
|
551 |
+ msg->add_to_branch_s, &msg->add_to_branch_len )) { |
|
552 |
+ LOG(L_ERR, "ERROR: forward_request: branch_builder failed\n"); |
|
553 |
+ ret=E_UNSPEC; |
|
554 |
+ goto error; |
|
563 | 555 |
} |
564 | 556 |
/* try to send the message until success or all the ips are exhausted |
565 | 557 |
* (if dns lookup is performed && the dns cache used ) */ |
... | ... |
@@ -383,8 +383,6 @@ int config_check = 0; |
383 | 383 |
int check_via = 0; |
384 | 384 |
/* translate user=phone URIs to TEL URIs */ |
385 | 385 |
int phone2tel = 1; |
386 |
-/* shall use stateful synonym branches? faster but not reboot-safe */ |
|
387 |
-int syn_branch = 1; |
|
388 | 386 |
/* debugging level for timer debugging */ |
389 | 387 |
int timerlog = L_WARN; |
390 | 388 |
/* should replies include extensive warnings? by default no, |
... | ... |
@@ -256,27 +256,25 @@ static inline void init_synonym_id( struct cell *t ) |
256 | 256 |
char *c; |
257 | 257 |
unsigned int myrand; |
258 | 258 |
|
259 |
- if (!syn_branch) { |
|
260 |
- p_msg=t->uas.request; |
|
261 |
- if (p_msg) { |
|
262 |
- /* char value of a proxied transaction is |
|
263 |
- calculated out of header-fields forming |
|
264 |
- transaction key |
|
265 |
- */ |
|
266 |
- char_msg_val( p_msg, t->md5 ); |
|
267 |
- } else { |
|
268 |
- /* char value for a UAC transaction is created |
|
269 |
- randomly -- UAC is an originating stateful element |
|
270 |
- which cannot be refreshed, so the value can be |
|
271 |
- anything |
|
272 |
- */ |
|
273 |
- /* HACK : not long enough */ |
|
274 |
- myrand=rand(); |
|
275 |
- c=t->md5; |
|
276 |
- size=MD5_LEN; |
|
277 |
- memset(c, '0', size ); |
|
278 |
- int2reverse_hex( &c, &size, myrand ); |
|
279 |
- } |
|
259 |
+ p_msg=t->uas.request; |
|
260 |
+ if (p_msg) { |
|
261 |
+ /* char value of a proxied transaction is |
|
262 |
+ calculated out of header-fields forming |
|
263 |
+ transaction key |
|
264 |
+ */ |
|
265 |
+ char_msg_val( p_msg, t->md5 ); |
|
266 |
+ } else { |
|
267 |
+ /* char value for a UAC transaction is created |
|
268 |
+ randomly -- UAC is an originating stateful element |
|
269 |
+ which cannot be refreshed, so the value can be |
|
270 |
+ anything |
|
271 |
+ */ |
|
272 |
+ /* HACK : not long enough */ |
|
273 |
+ myrand=rand(); |
|
274 |
+ c=t->md5; |
|
275 |
+ size=MD5_LEN; |
|
276 |
+ memset(c, '0', size ); |
|
277 |
+ int2reverse_hex( &c, &size, myrand ); |
|
280 | 278 |
} |
281 | 279 |
} |
282 | 280 |
|
... | ... |
@@ -309,10 +307,9 @@ struct cell* build_cell( struct sip_msg* p_msg ) |
309 | 309 |
sr_xavp_t** xold; |
310 | 310 |
#endif |
311 | 311 |
|
312 |
- /* allocs a new cell */ |
|
313 |
- /* if syn_branch==0 add space for md5 (MD5_LEN -sizeof(struct cell.md5)) */ |
|
312 |
+ /* allocs a new cell, add space for md5 (MD5_LEN - sizeof(struct cell.md5)) */ |
|
314 | 313 |
new_cell = (struct cell*)shm_malloc( sizeof( struct cell )+ |
315 |
- ((MD5_LEN-sizeof(((struct cell*)0)->md5))&((syn_branch!=0)-1)) ); |
|
314 |
+ MD5_LEN-sizeof(((struct cell*)0)->md5) ); |
|
316 | 315 |
if ( !new_cell ) { |
317 | 316 |
ser_error=E_OUT_OF_MEM; |
318 | 317 |
return NULL; |
... | ... |
@@ -455,8 +455,8 @@ typedef struct cell |
455 | 455 |
/* The route to take for each downstream branch separately */ |
456 | 456 |
unsigned short on_branch; |
457 | 457 |
|
458 |
- /* place holder for MD5checksum (meaningful only if syn_branch=0) */ |
|
459 |
- char md5[0]; /* if syn_branch==0 then MD5_LEN bytes are extra alloc'ed*/ |
|
458 |
+ /* place holder for MD5checksum, MD5_LEN bytes are extra alloc'ed */ |
|
459 |
+ char md5[0]; |
|
460 | 460 |
|
461 | 461 |
} tm_cell_t; |
462 | 462 |
|
... | ... |
@@ -13,15 +13,8 @@ |
13 | 13 |
* reply and both of them are constructed by different software. |
14 | 14 |
* |
15 | 15 |
* As for reply matching, we match based on branch value -- that is |
16 |
- * faster too. There are two versions .. with SYNONYMs #define |
|
17 |
- * enabled, the branch includes ordinal number of a transaction |
|
18 |
- * in a synonym list in hash table and is somewhat faster but |
|
19 |
- * not reboot-resilient. SYNONYMs turned off are little slower |
|
20 |
- * but work across reboots as well. |
|
21 |
- * |
|
22 |
- * The branch parameter is formed as follows: |
|
23 |
- * SYNONYMS on: hash.synonym.branch |
|
24 |
- * SYNONYMS off: hash.md5.branch |
|
16 |
+ * faster too. |
|
17 |
+ * The branch parameter is formed as follows: hash.md5.branch |
|
25 | 18 |
* |
26 | 19 |
* -jiri |
27 | 20 |
* |
... | ... |
@@ -892,16 +885,12 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch ) |
892 | 892 |
|
893 | 893 |
char *loopi; |
894 | 894 |
int loopl; |
895 |
- char *syni; |
|
896 |
- int synl; |
|
897 | 895 |
|
898 | 896 |
short is_cancel; |
899 | 897 |
|
900 | 898 |
/* make compiler warnings happy */ |
901 | 899 |
loopi=0; |
902 | 900 |
loopl=0; |
903 |
- syni=0; |
|
904 |
- synl=0; |
|
905 | 901 |
|
906 | 902 |
/* split the branch into pieces: loop_detection_check(ignored), |
907 | 903 |
hash_table_id, synonym_id, branch_id */ |
... | ... |
@@ -928,25 +917,14 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch ) |
928 | 928 |
hashi=p; |
929 | 929 |
p=n+1;scan_space--; |
930 | 930 |
|
931 |
- if (!syn_branch) { |
|
932 |
- /* md5 value */ |
|
933 |
- n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR ); |
|
934 |
- loopl = n-p; |
|
935 |
- scan_space-= loopl; |
|
936 |
- if (n==p || scan_space<2 || *n!=BRANCH_SEPARATOR) |
|
937 |
- goto nomatch2; |
|
938 |
- loopi=p; |
|
939 |
- p=n+1; scan_space--; |
|
940 |
- } else { |
|
941 |
- /* synonym id */ |
|
942 |
- n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR); |
|
943 |
- synl=n-p; |
|
944 |
- scan_space-=synl; |
|
945 |
- if (!synl || scan_space<2 || *n!=BRANCH_SEPARATOR) |
|
946 |
- goto nomatch2; |
|
947 |
- syni=p; |
|
948 |
- p=n+1;scan_space--; |
|
949 |
- } |
|
931 |
+ /* md5 value */ |
|
932 |
+ n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR ); |
|
933 |
+ loopl = n-p; |
|
934 |
+ scan_space-= loopl; |
|
935 |
+ if (n==p || scan_space<2 || *n!=BRANCH_SEPARATOR) |
|
936 |
+ goto nomatch2; |
|
937 |
+ loopi=p; |
|
938 |
+ p=n+1; scan_space--; |
|
950 | 939 |
|
951 | 940 |
/* branch id - should exceed the scan_space */ |
952 | 941 |
n=eat_token_end( p, p+scan_space ); |
... | ... |
@@ -959,8 +937,7 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch ) |
959 | 959 |
||hash_index>=TABLE_ENTRIES |
960 | 960 |
|| reverse_hex2int(branchi, branchl, &branch_id)<0 |
961 | 961 |
||branch_id>=MAX_BRANCHES |
962 |
- || (syn_branch ? (reverse_hex2int(syni, synl, &entry_label))<0 |
|
963 |
- : loopl!=MD5_LEN )) |
|
962 |
+ || loopl!=MD5_LEN) |
|
964 | 963 |
) { |
965 | 964 |
DBG("DEBUG: t_reply_matching: poor reply labels %d label %d " |
966 | 965 |
"branch %d\n", hash_index, entry_label, branch_id ); |
... | ... |
@@ -983,14 +960,8 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch ) |
983 | 983 |
/* all the transactions from the entry are compared */ |
984 | 984 |
clist_foreach(hash_bucket, p_cell, next_c){ |
985 | 985 |
prefetch_loc_r(p_cell->next_c, 1); |
986 |
- /* first look if branch matches */ |
|
987 |
- if (likely(syn_branch)) { |
|
988 |
- if (p_cell->label != entry_label) |
|
989 |
- continue; |
|
990 |
- } else { |
|
991 |
- if ( memcmp(p_cell->md5, loopi,MD5_LEN)!=0) |
|
986 |
+ if ( memcmp(p_cell->md5, loopi,MD5_LEN)!=0) |
|
992 | 987 |
continue; |
993 |
- } |
|
994 | 988 |
|
995 | 989 |
/* sanity check ... too high branch ? */ |
996 | 990 |
if (unlikely(branch_id>=p_cell->nr_of_outgoings)) |
... | ... |
@@ -1612,11 +1612,7 @@ char* build_uac_req(str* method, str* headers, str* body, dlg_t* dialog, int bra |
1612 | 1612 |
int t_calc_branch(struct cell *t, |
1613 | 1613 |
int b, char *branch, int *branch_len) |
1614 | 1614 |
{ |
1615 |
- return syn_branch ? |
|
1616 |
- branch_builder( t->hash_index, |
|
1617 |
- t->label, 0, |
|
1618 |
- b, branch, branch_len ) |
|
1619 |
- : branch_builder( t->hash_index, |
|
1615 |
+ return branch_builder( t->hash_index, |
|
1620 | 1616 |
0, t->md5, |
1621 | 1617 |
b, branch, branch_len ); |
1622 | 1618 |
} |