Browse code

rr: add enable_double_rr_always option

Andrey Utkin authored on 20/07/2015 14:46:36
Showing 3 changed files
... ...
@@ -175,6 +175,25 @@ modparam("rr", "enable_double_rr", 0)
175 175
 ...
176 176
 </programlisting>
177 177
       </example>
178
+      <para>Some useragents (e. g. Linphone) incorrectly use UDP transport for
179
+      subsequent requests in dialog, despite being configured to use another
180
+      SIP transport protocol. This can be worked around by setting Record-Route
181
+      header with explicit transport attribute. But enable_double_rr enabled in
182
+      default mode omits transport attribute from being added to header if it
183
+      detects that both sender and receiver use same protocol (e. g. TCP or
184
+      TLS), and this results in UDP being used by such broken clients. Set
185
+      enable_double_rr to value 2 to always have two RR headers with transport
186
+      attributes expicitly set.</para>
187
+
188
+      <example>
189
+        <title>Set <varname>enable_double_rr</varname> to 2 to always have two explicit RR headers</title>
190
+
191
+        <programlisting format="linespecific">
192
+...
193
+modparam("rr", "enable_double_rr", 2)
194
+...
195
+</programlisting>
196
+      </example>
178 197
     </section>
179 198
 
180 199
     <section>
... ...
@@ -283,7 +283,7 @@ static inline int build_rr(struct lump* _l, struct lump* _l2, str* user,
283 283
 	if (_l ==0 )
284 284
 		goto lump_err;
285 285
 	if (enable_double_rr) {
286
-		if (!(_l = insert_cond_lump_after(_l, COND_IF_DIFF_REALMS, 0)))
286
+		if (!(_l = insert_cond_lump_after(_l, enable_double_rr == 2 ? COND_TRUE : COND_IF_DIFF_REALMS, 0)))
287 287
 			goto lump_err;
288 288
 		if (!(_l = insert_new_lump_after(_l, r2, RR_R2_LEN, 0)))
289 289
 			goto lump_err;
... ...
@@ -429,8 +429,8 @@ int record_route(struct sip_msg* _m, str *params)
429 429
 			ret = -5;
430 430
 			goto error;
431 431
 		}
432
-		l = insert_cond_lump_after(l, COND_IF_DIFF_REALMS, 0);
433
-		l2 = insert_cond_lump_before(l2, COND_IF_DIFF_REALMS, 0);
432
+		l = insert_cond_lump_after(l, enable_double_rr == 2 ? COND_TRUE : COND_IF_DIFF_REALMS, 0);
433
+		l2 = insert_cond_lump_before(l2, enable_double_rr == 2 ? COND_TRUE : COND_IF_DIFF_REALMS, 0);
434 434
 		if (!l || !l2) {
435 435
 			LM_ERR("failed to insert conditional lump\n");
436 436
 			ret = -6;
... ...
@@ -706,14 +706,14 @@ static inline int build_advertised_rr(struct lump* _l, struct lump* _l2, str *_d
706 706
 		goto lump_err;
707 707
 	}
708 708
 	hdr = NULL;
709
-	if (!(_l = insert_cond_lump_after(_l, COND_IF_DIFF_PROTO, 0)))
709
+	if (!(_l = insert_cond_lump_after(_l, enable_double_rr == 2 ? COND_TRUE : COND_IF_DIFF_PROTO, 0)))
710 710
 		goto lump_err;
711 711
 	if (!(_l = insert_new_lump_after(_l, trans, RR_TRANS_LEN, 0)))
712 712
 		goto lump_err;
713 713
 	if (!(_l = insert_subst_lump_after(_l, _inbound?SUBST_RCV_PROTO:SUBST_SND_PROTO, 0)))
714 714
 		goto lump_err;
715 715
 	if (enable_double_rr) {
716
-		if (!(_l = insert_cond_lump_after(_l, COND_IF_DIFF_REALMS, 0)))
716
+		if (!(_l = insert_cond_lump_after(_l, enable_double_rr == 2 ? COND_TRUE : COND_IF_DIFF_REALMS, 0)))
717 717
 			goto lump_err;
718 718
 		if (!(_l = insert_new_lump_after(_l, r2, RR_R2_LEN, 0)))
719 719
 			goto lump_err;
... ...
@@ -790,8 +790,8 @@ int record_route_advertised_address(struct sip_msg* _m, str* _data)
790 790
 			ret = -3;
791 791
 			goto error;
792 792
 		}
793
-		l = insert_cond_lump_after(l, COND_IF_DIFF_PROTO, 0);
794
-		l2 = insert_cond_lump_before(l2, COND_IF_DIFF_PROTO, 0);
793
+		l = insert_cond_lump_after(l, enable_double_rr == 2 ? COND_TRUE : COND_IF_DIFF_PROTO, 0);
794
+		l2 = insert_cond_lump_before(l2, enable_double_rr == 2 ? COND_TRUE : COND_IF_DIFF_PROTO, 0);
795 795
 		if (!l || !l2) {
796 796
 			LM_ERR("failed to insert conditional lump\n");
797 797
 			ret = -4;
... ...
@@ -1663,6 +1663,7 @@ read_error:
1663 1663
 	return ret;
1664 1664
 con_error:
1665 1665
 	con->state=S_CONN_BAD;
1666
+	LM_WARN("%s:%d %s releasing\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
1666 1667
 	release_tcpconn(con, CONN_ERROR, tcpmain_sock);
1667 1668
 	return ret;
1668 1669
 error: