[MERGED] libosmo-abis[master]: IPA: log remote address

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/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Feb 13 23:59:05 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: IPA: log remote address
......................................................................


IPA: log remote address

Wrap IPA logging to always print peer's address to simplify
troubleshooting.

Change-Id: I19ebaea45812aad6b3d3480cac0f1f833daf428d
---
M src/input/ipa.c
1 file changed, 20 insertions(+), 18 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/input/ipa.c b/src/input/ipa.c
index fbed038..fc1ca50 100644
--- a/src/input/ipa.c
+++ b/src/input/ipa.c
@@ -23,6 +23,8 @@
 
 #include <osmocom/abis/ipa.h>
 
+#define LOGIPA(link, level, fmt, args...) LOGP(DLINP, level, "%s:%u " fmt, link->addr, link->port, ## args)
+
 void ipa_msg_push_header(struct msgb *msg, uint8_t proto)
 {
 	struct ipaccess_head *hh;
@@ -51,20 +53,20 @@
 	struct msgb *msg;
 	int ret;
 
-	LOGP(DLINP, LOGL_DEBUG, "message received\n");
+	LOGIPA(link, LOGL_DEBUG, "message received\n");
 
 	ret = ipa_msg_recv_buffered(ofd->fd, &msg, &link->pending_msg);
 	if (ret < 0) {
 		if (ret == -EAGAIN)
 			return;
 		if (ret == -EPIPE || ret == -ECONNRESET)
-			LOGP(DLINP, LOGL_ERROR, "lost connection with server\n");
+			LOGIPA(link, LOGL_ERROR, "lost connection with server\n");
 		ipa_client_conn_close(link);
 		if (link->updown_cb)
 			link->updown_cb(link, 0);
 		return;
 	} else if (ret == 0) {
-		LOGP(DLINP, LOGL_ERROR, "connection closed with server\n");
+		LOGIPA(link, LOGL_ERROR, "connection closed with server\n");
 		ipa_client_conn_close(link);
 		if (link->updown_cb)
 			link->updown_cb(link, 0);
@@ -87,7 +89,7 @@
 	struct llist_head *lh;
 	int ret;
 
-	LOGP(DLINP, LOGL_DEBUG, "sending data\n");
+	LOGIPA(link, LOGL_DEBUG, "sending data\n");
 
 	if (llist_empty(&link->tx_queue)) {
 		ofd->when &= ~BSC_FD_WRITE;
@@ -104,7 +106,7 @@
 			if (link->updown_cb)
 				link->updown_cb(link, 0);
 		}
-		LOGP(DLINP, LOGL_ERROR, "error to send\n");
+		LOGIPA(link, LOGL_ERROR, "error to send\n");
 	}
 	msgb_free(msg);
 	return 0;
@@ -126,18 +128,18 @@
 			return 0;
 		}
 		ofd->when &= ~BSC_FD_WRITE;
-		LOGP(DLINP, LOGL_NOTICE, "connection done.\n");
+		LOGIPA(link, LOGL_NOTICE, "connection done\n");
 		link->state = IPA_CLIENT_LINK_STATE_CONNECTED;
 		if (link->updown_cb)
 			link->updown_cb(link, 1);
 		break;
 	case IPA_CLIENT_LINK_STATE_CONNECTED:
 		if (what & BSC_FD_READ) {
-			LOGP(DLINP, LOGL_DEBUG, "connected read\n");
+			LOGIPA(link, LOGL_DEBUG, "connected read\n");
 			ipa_client_read(link);
 		}
 		if (what & BSC_FD_WRITE) {
-			LOGP(DLINP, LOGL_DEBUG, "connected write\n");
+			LOGIPA(link, LOGL_DEBUG, "connected write\n");
 			ipa_client_write(link);
 		}
 		break;
@@ -335,18 +337,18 @@
 	struct msgb *msg;
 	int ret;
 
-	LOGP(DLINP, LOGL_DEBUG, "message received\n");
+	LOGIPA(conn, LOGL_DEBUG, "message received\n");
 
 	ret = ipa_msg_recv_buffered(ofd->fd, &msg, &conn->pending_msg);
 	if (ret < 0) {
 		if (ret == -EAGAIN)
 			return;
 		if (ret == -EPIPE || ret == -ECONNRESET)
-			LOGP(DLINP, LOGL_ERROR, "lost connection with server\n");
+			LOGIPA(conn, LOGL_ERROR, "lost connection with server\n");
 		ipa_server_conn_destroy(conn);
 		return;
 	} else if (ret == 0) {
-		LOGP(DLINP, LOGL_ERROR, "connection closed with server\n");
+		LOGIPA(conn, LOGL_ERROR, "connection closed with server\n");
 		ipa_server_conn_destroy(conn);
 		return;
 	}
@@ -361,7 +363,7 @@
 	struct msgb *msg;
 	int ret;
 
-	LOGP(DLINP, LOGL_DEBUG, "sending data\n");
+	LOGIPA(conn, LOGL_DEBUG, "sending data\n");
 	msg = msgb_dequeue(&conn->tx_queue);
 
 	if (!msg) {
@@ -371,7 +373,7 @@
 
 	ret = send(conn->ofd.fd, msg->data, msg->len, 0);
 	if (ret < 0) {
-		LOGP(DLINP, LOGL_ERROR, "error to send\n");
+		LOGIPA(conn, LOGL_ERROR, "error to send\n");
 	}
 	msgb_free(msg);
 }
@@ -450,7 +452,7 @@
 		break;
 	default:
 		/* Error */
-		LOGP(DLINP, LOGL_ERROR, "Unexpected return from "
+		LOGIPA(conn, LOGL_ERROR, "Unexpected return from "
 		     "ipa_ccm_rcvmsg_base: %d\n", rc);
 		goto err;
 	}
@@ -460,18 +462,18 @@
 		rc = ipa_ccm_idtag_parse(&tlvp, (uint8_t *)msg->l2h + 2,
 					 msgb_l2len(msg)-2);
 		if (rc < 0) {
-			LOGP(DLINP, LOGL_ERROR, "IPA CCM RESPonse with "
+			LOGIPA(conn, LOGL_ERROR, "IPA CCM RESPonse with "
 				"malformed TLVs\n");
 			goto err;
 		}
 		if (!TLVP_PRESENT(&tlvp, IPAC_IDTAG_UNIT)) {
-			LOGP(DLINP, LOGL_ERROR, "IPA CCM RESP without "
+			LOGIPA(conn, LOGL_ERROR, "IPA CCM RESP without "
 				"unit ID\n");
 			goto err;
 		}
 		len = TLVP_LEN(&tlvp, IPAC_IDTAG_UNIT);
 		if (len < 1) {
-			LOGP(DLINP, LOGL_ERROR, "IPA CCM RESP with short"
+			LOGIPA(conn, LOGL_ERROR, "IPA CCM RESP with short"
 				"unit ID\n");
 			goto err;
 		}
@@ -485,7 +487,7 @@
 			goto err;
 		break;
 	default:
-		LOGP(DLINP, LOGL_ERROR, "Unknown IPA message type\n");
+		LOGIPA(conn, LOGL_ERROR, "Unknown IPA message type\n");
 		break;
 	}
 	return 0;

-- 
To view, visit https://gerrit.osmocom.org/6408
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I19ebaea45812aad6b3d3480cac0f1f833daf428d
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list