[PATCH 6/7] ipa: better log error messages for ipa_msg_recv()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

pablo at gnumonks.org pablo at gnumonks.org
Fri Sep 9 00:37:00 UTC 2011


From: Pablo Neira Ayuso <pablo at gnumonks.org>

More descriptive errors help to debug problems.
---
 src/input/ipa.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/input/ipa.c b/src/input/ipa.c
index 4773dff..a519f07 100644
--- a/src/input/ipa.c
+++ b/src/input/ipa.c
@@ -63,6 +63,7 @@ int ipa_msg_recv(int fd, struct msgb **rmsg)
 		msgb_free(msg);
 		return ret;
 	} else if (ret != sizeof(*hh)) {
+		LOGP(DLINP, LOGL_ERROR, "too small message received\n");
 		msgb_free(msg);
 		return -EIO;
 	}
@@ -73,6 +74,8 @@ int ipa_msg_recv(int fd, struct msgb **rmsg)
 	len = ntohs(hh->len);
 
 	if (len < 0 || IPA_ALLOC_SIZE < len + sizeof(*hh)) {
+		LOGP(DLINP, LOGL_ERROR, "bad message length of %d bytes, "
+					"received %d bytes\n", len, ret);
 		msgb_free(msg);
 		return -EIO;
 	}
@@ -82,6 +85,7 @@ int ipa_msg_recv(int fd, struct msgb **rmsg)
 		msgb_free(msg);
 		return ret;
 	} else if (ret < len) {
+		LOGP(DLINP, LOGL_ERROR, "trunked message received\n");
 		msgb_free(msg);
 		return -EIO;
 	}
@@ -119,8 +123,6 @@ static void ipa_client_read(struct ipa_client_conn *link)
 	if (ret < 0) {
 		if (errno == EPIPE || errno == ECONNRESET) {
 			LOGP(DLINP, LOGL_ERROR, "lost connection with server\n");
-		} else {
-			LOGP(DLINP, LOGL_ERROR, "unknown error\n");
 		}
 		ipa_client_retry(link);
 		return;
@@ -387,8 +389,6 @@ static void ipa_server_conn_read(struct ipa_server_conn *conn)
 	if (ret < 0) {
 		if (errno == EPIPE || errno == ECONNRESET) {
 			LOGP(DLINP, LOGL_ERROR, "lost connection with server\n");
-		} else {
-			LOGP(DLINP, LOGL_ERROR, "unknown error\n");
 		}
 		return;
 	} else if (ret == 0) {
-- 
1.7.2.5





More information about the OpenBSC mailing list