Browse code

tm: new module parameter - dns_reuse_rcv_socket

- control reuse of the receive socket for additional branches added by
dns failover
- if 1, the rcv socket is used, if not it depends on mhomed - when that
is 0, the first socket is used, otherwise will be selected based on
routing table
- default is 0
- therefore beware when setting this parameter and mhomed=1
- based on discussion for FS#313

Daniel-Constantin Mierla authored on 15/06/2013 17:08:38
Showing 2 changed files
... ...
@@ -127,6 +127,7 @@
127 127
 
128 128
 
129 129
 extern int tm_failure_exec_mode;
130
+extern int tm_dns_reuse_rcv_socket;
130 131
 
131 132
 static int goto_on_branch = 0, branch_route = 0;
132 133
 
... ...
@@ -1073,14 +1074,16 @@ int add_uac_dns_fallback(struct cell *t, struct sip_msg* msg,
1073 1073
 							&old_uac->path,
1074 1074
 							 (old_uac->request.dst.send_flags.f &
1075 1075
 								SND_F_FORCE_SOCKET)?
1076
-									old_uac->request.dst.send_sock:0,
1076
+									old_uac->request.dst.send_sock:
1077
+									((tm_dns_reuse_rcv_socket)
1078
+											?msg->rcv.bind_address:0),
1077 1079
 							old_uac->request.dst.send_flags,
1078 1080
 							old_uac->request.dst.proto,
1079 1081
 							old_uac->request.buffer,
1080 1082
 							old_uac->request.buffer_len,
1081 1083
 							&old_uac->instance, &old_uac->ruid,
1082 1084
 							&old_uac->location_ua);
1083
-			}else
1085
+			} else {
1084 1086
 				/* add_uac will use dns_h => next_hop will be ignored.
1085 1087
 				 * Unfortunately we can't reuse the old buffer, the branch id
1086 1088
 				 *  must be changed and the send_socket might be different =>
... ...
@@ -1088,11 +1091,14 @@ int add_uac_dns_fallback(struct cell *t, struct sip_msg* msg,
1088 1088
 				ret=add_uac(t,  msg, &old_uac->uri, 0, &old_uac->path, 0,
1089 1089
 							 (old_uac->request.dst.send_flags.f &
1090 1090
 								SND_F_FORCE_SOCKET)?
1091
-									old_uac->request.dst.send_sock:0,
1091
+									old_uac->request.dst.send_sock:
1092
+									((tm_dns_reuse_rcv_socket)
1093
+											?msg->rcv.bind_address:0),
1092 1094
 							old_uac->request.dst.send_flags,
1093 1095
 							old_uac->request.dst.proto, UAC_DNS_FAILOVER_F,
1094 1096
 							&old_uac->instance, &old_uac->ruid,
1095 1097
 							&old_uac->location_ua);
1098
+			}
1096 1099
 
1097 1100
 			if (ret<0){
1098 1101
 				/* failed, delete the copied dns_h */
... ...
@@ -316,6 +316,8 @@ int tm_remap_503_500 = 1;
316 316
 
317 317
 int tm_failure_exec_mode = 0;
318 318
 
319
+int tm_dns_reuse_rcv_socket = 0;
320
+
319 321
 static rpc_export_t tm_rpc[];
320 322
 
321 323
 static int fixup_t_check_status(void** param, int param_no);
... ...
@@ -540,6 +542,7 @@ static param_export_t params[]={
540 540
 	{"faked_reply_prio",    PARAM_INT, &faked_reply_prio                     },
541 541
 	{"remap_503_500",       PARAM_INT, &tm_remap_503_500                     },
542 542
 	{"failure_exec_mode",   PARAM_INT, &tm_failure_exec_mode                 },
543
+	{"dns_reuse_rcv_socket",PARAM_INT, &tm_dns_reuse_rcv_socket              },
543 544
 #ifdef CANCEL_REASON_SUPPORT
544 545
 	{"local_cancel_reason", PARAM_INT, &default_tm_cfg.local_cancel_reason   },
545 546
 	{"e2e_cancel_reason",   PARAM_INT, &default_tm_cfg.e2e_cancel_reason     },