pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-pcap/+/39172?usp=email )
Change subject: pcap-client: Improve conn logging
......................................................................
pcap-client: Improve conn logging
Change-Id: I078557144a2604e343ed0b44f72035a4eda8a674
---
M include/osmo-pcap/osmo_pcap_client.h
M src/osmo_client_network.c
2 files changed, 11 insertions(+), 14 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
fixeria: Looks good to me, approved
diff --git a/include/osmo-pcap/osmo_pcap_client.h b/include/osmo-pcap/osmo_pcap_client.h
index 7641ef1..8ad5ffa 100644
--- a/include/osmo-pcap/osmo_pcap_client.h
+++ b/include/osmo-pcap/osmo_pcap_client.h
@@ -137,5 +137,8 @@
void osmo_pcap_handle_free(struct osmo_pcap_handle *ph);
int osmo_pcap_handle_start_capture(struct osmo_pcap_handle *ph);
+#define LOGCONN(conn, lvl, fmt, args...) \
+ LOGP(DCLIENT, lvl, "CONN(%s,%s:%d) " fmt, (conn)->name, (conn)->srv_ip,
(conn)->srv_port, ## args)
+
#define LOGPH(ph, lvl, fmt, args...) \
LOGP(DCLIENT, lvl, "PH(%s) " fmt, (ph)->devname, ## args)
diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c
index e27a91f..bc99087 100644
--- a/src/osmo_client_network.c
+++ b/src/osmo_client_network.c
@@ -59,8 +59,8 @@
static void write_data(struct osmo_pcap_client_conn *conn, struct msgb *msg)
{
if (osmo_wqueue_enqueue_quiet(&conn->wqueue, msg) != 0) {
- LOGP(DCLIENT, LOGL_ERROR, "Failed to enqueue conn=%s (capacity: %u/%u)\n",
- conn->name, conn->wqueue.current_length, conn->wqueue.max_length);
+ LOGCONN(conn, LOGL_ERROR, "Failed to enqueue msg (capacity: %u/%u)\n",
+ conn->wqueue.current_length, conn->wqueue.max_length);
rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_QERR));
msgb_free(msg);
return;
@@ -75,8 +75,7 @@
rc = read(fd->fd, buf, sizeof(buf));
if (rc <= 0) {
struct osmo_pcap_client_conn *conn = fd->data;
- LOGP(DCLIENT, LOGL_ERROR, "Lost connection on read conn=%s\n",
- conn->name);
+ LOGCONN(conn, LOGL_ERROR, "Lost connection on read\n");
lost_connection(conn);
return -1;
}
@@ -91,8 +90,7 @@
rc = write(fd->fd, msg->data, msg->len);
if (rc < 0) {
struct osmo_pcap_client_conn *conn = fd->data;
- LOGP(DCLIENT, LOGL_ERROR, "Lost connection on write to %s %s:%d.\n",
- conn->name, conn->srv_ip, conn->srv_port);
+ LOGCONN(conn, LOGL_ERROR, "Lost connection on write\n");
rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_WERR));
lost_connection(conn);
return -1;
@@ -172,15 +170,14 @@
struct osmo_pcap_handle *ph;
if (in_hdr->len > in_hdr->caplen) {
- LOGP(DCLIENT, LOGL_ERROR,
- "Recording truncated packet, len %zu > snaplen %zu\n",
+ LOGCONN(conn, LOGL_ERROR, "Recording truncated packet, len %zu > snaplen
%zu\n",
(size_t) in_hdr->len, (size_t) in_hdr->caplen);
rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_2BIG));
}
msg = msgb_alloc(in_hdr->caplen + sizeof(*om_hdr) + sizeof(*hdr),
"data-data");
if (!msg) {
- LOGP(DCLIENT, LOGL_ERROR, "Failed to allocate.\n");
+ LOGCONN(conn, LOGL_ERROR, "Failed to allocate\n");
rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_NOMEM));
return;
}
@@ -245,8 +242,7 @@
/* TODO: support capturing from multiple interfaces here: */
ph = llist_first_entry_or_null(&conn->client->handles, struct
osmo_pcap_handle, entry);
if (!ph || !ph->handle) {
- LOGP(DCLIENT, LOGL_ERROR,
- "No pcap_handle not sending link info to conn=%s\n", conn->name);
+ LOGCONN(conn, LOGL_ERROR, "No pcap_handle not sending link info\n");
return;
}
@@ -307,9 +303,7 @@
rc = osmo_sock_init2(AF_INET, sock_type, sock_proto, conn->source_ip, 0,
conn->srv_ip, srv_port,
OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT | OSMO_SOCK_F_NONBLOCK);
if (rc < 0) {
- LOGP(DCLIENT, LOGL_ERROR,
- "Failed to connect conn=%s to %s:%d\n",
- conn->name, conn->srv_ip, conn->srv_port);
+ LOGCONN(conn, LOGL_ERROR, "Failed to connect\n");
lost_connection(conn);
return;
}
--
To view, visit
https://gerrit.osmocom.org/c/osmo-pcap/+/39172?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: I078557144a2604e343ed0b44f72035a4eda8a674
Gerrit-Change-Number: 39172
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>