Browse code

core: more verbose logs when get_send_socket fails

All the get_send_socket() errors or warnings include now the
forced socket and the destination (protocol:ip:port).

Andrei Pelinescu-Onciul authored on 22/09/2010 10:45:53
Showing 1 changed files
... ...
@@ -234,26 +234,36 @@ struct socket_info* get_send_socket2(struct socket_info* force_send_socket,
234 234
 										enum ss_mismatch* mismatch)
235 235
 {
236 236
 	struct socket_info* send_sock;
237
+	struct socket_info* orig;
237 238
 	
238 239
 	if (likely(mismatch)) *mismatch=0;
239 240
 	/* check if send interface is not forced */
240 241
 	if (unlikely(force_send_socket)){
241 242
 		if (unlikely(force_send_socket->proto!=proto)){
243
+			orig=force_send_socket;
242 244
 			force_send_socket=find_si(&(force_send_socket->address),
243 245
 											force_send_socket->port_no,
244 246
 											proto);
245 247
 			if (unlikely(force_send_socket == 0)){
246 248
 				if (likely(mismatch)) *mismatch=SS_MISMATCH_ADDR;
247 249
 				LOG(L_WARN, "WARNING: get_send_socket: "
248
-						"protocol/port mismatch\n");
250
+						"protocol/port mismatch (forced %s:%s:%d,"
251
+						" to %s:%s)\n",
252
+						proto2a(orig->proto), ip_addr2a(&orig->address),
253
+						orig->port_no,
254
+						proto2a(proto), su2a(to, sizeof(*to)));
249 255
 				goto not_forced;
250 256
 			}
251 257
 			if (likely(mismatch)) *mismatch=SS_MISMATCH_PROTO;
252 258
 		}
253 259
 		if (unlikely(force_send_socket->address.af!=to->s.sa_family)){
254
-			DBG("get_send_socket: force_send_socket of different af (dst %d,"
255
-					" forced %d)\n",
256
-					to->s.sa_family, force_send_socket->address.af);
260
+			DBG("get_send_socket: force_send_socket of different af"
261
+					" (dst %d - %s:%s forced %d -%s:%s:%d)\n",
262
+					to->s.sa_family, proto2a(proto), su2a(to, sizeof(*to)),
263
+					force_send_socket->address.af,
264
+					proto2a(force_send_socket->proto),
265
+					ip_addr2a(&force_send_socket->address),
266
+					force_send_socket->port_no);
257 267
 			if (likely(mismatch)) *mismatch=SS_MISMATCH_AF;
258 268
 			goto not_forced;
259 269
 		}
... ...
@@ -268,7 +278,11 @@ struct socket_info* get_send_socket2(struct socket_info* force_send_socket,
268 268
 		else{
269 269
 			if (!(force_send_socket->flags & SI_IS_MCAST))
270 270
 				LOG(L_WARN, "WARNING: get_send_socket: not listening"
271
-							 " on the requested socket, no fork mode?\n");
271
+							 " on the requested socket (%s:%s:%d),"
272
+							 " no fork mode?\n",
273
+							proto2a(force_send_socket->proto),
274
+							ip_addr2a(&force_send_socket->address),
275
+							force_send_socket->port_no);
272 276
 			else if (likely(mismatch)) *mismatch=SS_MISMATCH_MCAST;
273 277
 		}
274 278
 	};
... ...
@@ -279,7 +293,9 @@ not_forced:
279 279
 			return send_sock; /* found or error*/
280 280
 		else if (send_sock->socket==-1){
281 281
 			LOG(L_WARN, "WARNING: get_send_socket: not listening on the"
282
-					" requested socket, no fork mode?\n");
282
+					" requested socket (%s:%s:%d), no fork mode?\n",
283
+					proto2a(send_sock->proto), ip_addr2a(&send_sock->address),
284
+					send_sock->port_no);
283 285
 			/* continue: try to use some socket */
284 286
 		}
285 287
 	}
... ...
@@ -358,7 +374,8 @@ not_forced:
358 358
 			}else send_sock=bind_address;
359 359
 			break;
360 360
 		default:
361
-			LOG(L_CRIT, "BUG: get_send_socket: unknown proto %d\n", proto);
361
+			LOG(L_CRIT, "BUG: get_send_socket: unsupported proto %d (%s)\n",
362
+					proto, proto2a(proto));
362 363
 	}
363 364
 	return send_sock;
364 365
 }