Browse code

dispatcher: flag 16 (1<<4) for destinations with host not having A/AAAA record

- use it for addresses that should not be resolved with an A/AAAA query
at startup (e.g., it is a NAPTR or SRV only record for that specific
hostname)
- such addresses will not match when using ds_is_from_list(...)
- GH #1743

Daniel-Constantin Mierla authored on 29/11/2018 17:20:24
Showing 2 changed files
... ...
@@ -424,11 +424,17 @@ ds_dest_t *pack_dest(str iuri, int flags, int priority, str *attrs)
424 424
 	/* Do a DNS-Lookup for the Host-Name: */
425 425
 	he = resolvehost(hn);
426 426
 	if(he == 0) {
427
-		LM_ERR("could not resolve %.*s\n", puri.host.len, puri.host.s);
428
-		goto err;
427
+		if(dp->flags & DS_NODNSARES_DST) {
428
+			dp->irmode |= DS_IRMODE_NOIPADDR;
429
+		} else {
430
+			LM_ERR("could not resolve %.*s (missing no-probing flag?!?)\n",
431
+					puri.host.len, puri.host.s);
432
+			goto err;
433
+		}
434
+	} else {
435
+		/* Store hostent in the dispatcher structure */
436
+		hostent2ip_addr(&dp->ip_address, he, 0);
429 437
 	}
430
-	/* Free the hostname */
431
-	hostent2ip_addr(&dp->ip_address, he, 0);
432 438
 
433 439
 	/* Copy the port out of the URI */
434 440
 	dp->port = puri.port_no;
... ...
@@ -2957,8 +2963,8 @@ int ds_is_addr_from_list(sip_msg_t *_m, int group, str *uri, int mode)
2957 2963
 
2958 2964
 
2959 2965
 	if(group == -1) {
2960
-		rc = ds_is_addr_from_set_r(
2961
-				_m, pipaddr, tport, tproto, _ds_list, mode, 1);
2966
+		rc = ds_is_addr_from_set_r(_m, pipaddr, tport, tproto, _ds_list,
2967
+				mode, 1);
2962 2968
 	} else {
2963 2969
 		list = ds_avl_find(_ds_list, group);
2964 2970
 		if(list) {
... ...
@@ -44,7 +44,8 @@
44 44
 #define DS_TRYING_DST		2  /*!< temporary trying destination */
45 45
 #define DS_DISABLED_DST		4  /*!< admin disabled destination */
46 46
 #define DS_PROBING_DST		8  /*!< checking destination */
47
-#define DS_STATES_ALL		15  /*!< all bits for the states of destination */
47
+#define DS_NODNSARES_DST	16 /*!< no DNS A/AAAA resolve for host in uri */
48
+#define DS_STATES_ALL		31 /*!< all bits for the states of destination */
48 49
 
49 50
 #define ds_skip_dst(flags)	((flags) & (DS_INACTIVE_DST|DS_DISABLED_DST))
50 51
 
... ...
@@ -68,6 +69,8 @@
68 69
 
69 70
 #define DS_XAVP_CTX_SKIP_CNT	1
70 71
 
72
+#define DS_IRMODE_NOIPADDR	1
73
+
71 74
 /* clang-format on */
72 75
 
73 76
 extern str ds_db_url;
... ...
@@ -185,16 +188,17 @@ typedef struct _ds_latency_stats {
185 188
 } ds_latency_stats_t;
186 189
 
187 190
 typedef struct _ds_dest {
188
-	str uri;
189
-	int flags;
190
-	int priority;
191
-	int dload;
192
-	ds_attrs_t attrs;
193
-	ds_latency_stats_t latency_stats;
194
-	struct socket_info * sock;
195
-	struct ip_addr ip_address; 	/*!< IP-Address of the entry */
196
-	unsigned short int port; 	/*!< Port of the URI */
197
-	unsigned short int proto; 	/*!< Protocol of the URI */
191
+	str uri;          /*!< address/uri */
192
+	int flags;        /*!< flags */
193
+	int priority;     /*!< priority */
194
+	int dload;        /*!< load */
195
+	ds_attrs_t attrs; /*!< the atttributes */
196
+	ds_latency_stats_t latency_stats; /*!< latency statistics */
197
+	int irmode;       /*!< internal runtime mode (flags) */
198
+	struct socket_info *sock; /*!< pointer to local socket */
199
+	struct ip_addr ip_address; 	/*!< IP of the address */
200
+	unsigned short int port; 	/*!< port of the URI */
201
+	unsigned short int proto; 	/*!< protocol of the URI */
198 202
 	int message_count;
199 203
 	struct _ds_dest *next;
200 204
 } ds_dest_t;