[sr-dev] git:master: core: more verbose logs when get_send_socket fails

Andrei Pelinescu-Onciul andrei at iptel.org
Fri Sep 24 09:53:38 CEST 2010


Module: sip-router
Branch: master
Commit: 20a8b62b515ac00bebf00177d0971be11dbedd08
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=20a8b62b515ac00bebf00177d0971be11dbedd08

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Wed Sep 22 12:45:53 2010 +0200

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).

---

 forward.c |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/forward.c b/forward.c
index 9e675da..25bc11d 100644
--- a/forward.c
+++ b/forward.c
@@ -234,26 +234,36 @@ struct socket_info* get_send_socket2(struct socket_info* force_send_socket,
 										enum ss_mismatch* mismatch)
 {
 	struct socket_info* send_sock;
+	struct socket_info* orig;
 	
 	if (likely(mismatch)) *mismatch=0;
 	/* check if send interface is not forced */
 	if (unlikely(force_send_socket)){
 		if (unlikely(force_send_socket->proto!=proto)){
+			orig=force_send_socket;
 			force_send_socket=find_si(&(force_send_socket->address),
 											force_send_socket->port_no,
 											proto);
 			if (unlikely(force_send_socket == 0)){
 				if (likely(mismatch)) *mismatch=SS_MISMATCH_ADDR;
 				LOG(L_WARN, "WARNING: get_send_socket: "
-						"protocol/port mismatch\n");
+						"protocol/port mismatch (forced %s:%s:%d,"
+						" to %s:%s)\n",
+						proto2a(orig->proto), ip_addr2a(&orig->address),
+						orig->port_no,
+						proto2a(proto), su2a(to, sizeof(*to)));
 				goto not_forced;
 			}
 			if (likely(mismatch)) *mismatch=SS_MISMATCH_PROTO;
 		}
 		if (unlikely(force_send_socket->address.af!=to->s.sa_family)){
-			DBG("get_send_socket: force_send_socket of different af (dst %d,"
-					" forced %d)\n",
-					to->s.sa_family, force_send_socket->address.af);
+			DBG("get_send_socket: force_send_socket of different af"
+					" (dst %d - %s:%s forced %d -%s:%s:%d)\n",
+					to->s.sa_family, proto2a(proto), su2a(to, sizeof(*to)),
+					force_send_socket->address.af,
+					proto2a(force_send_socket->proto),
+					ip_addr2a(&force_send_socket->address),
+					force_send_socket->port_no);
 			if (likely(mismatch)) *mismatch=SS_MISMATCH_AF;
 			goto not_forced;
 		}
@@ -268,7 +278,11 @@ struct socket_info* get_send_socket2(struct socket_info* force_send_socket,
 		else{
 			if (!(force_send_socket->flags & SI_IS_MCAST))
 				LOG(L_WARN, "WARNING: get_send_socket: not listening"
-							 " on the requested socket, no fork mode?\n");
+							 " on the requested socket (%s:%s:%d),"
+							 " no fork mode?\n",
+							proto2a(force_send_socket->proto),
+							ip_addr2a(&force_send_socket->address),
+							force_send_socket->port_no);
 			else if (likely(mismatch)) *mismatch=SS_MISMATCH_MCAST;
 		}
 	};
@@ -279,7 +293,9 @@ not_forced:
 			return send_sock; /* found or error*/
 		else if (send_sock->socket==-1){
 			LOG(L_WARN, "WARNING: get_send_socket: not listening on the"
-					" requested socket, no fork mode?\n");
+					" requested socket (%s:%s:%d), no fork mode?\n",
+					proto2a(send_sock->proto), ip_addr2a(&send_sock->address),
+					send_sock->port_no);
 			/* continue: try to use some socket */
 		}
 	}
@@ -358,7 +374,8 @@ not_forced:
 			}else send_sock=bind_address;
 			break;
 		default:
-			LOG(L_CRIT, "BUG: get_send_socket: unknown proto %d\n", proto);
+			LOG(L_CRIT, "BUG: get_send_socket: unsupported proto %d (%s)\n",
+					proto, proto2a(proto));
 	}
 	return send_sock;
 }




More information about the sr-dev mailing list