aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-06-04 18:01:06 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2021-06-04 18:01:06 +0200
commitef92a539e8893655fed36643d662b82ffac424f9 (patch)
tree5bb483e543f3d92a4f87853e7949b068716b3875
parent6e564a97b90dcd2c9a377235806ddaeb59fb5837 (diff)
Use new stat item/ctr getter APIsHEADmaster
Generated with spatch: """ @@ expression E1, E2; @@ - &E2->ctr[E1] + rate_ctr_group_get_ctr(E2, E1) """ Change-Id: Ic860db04489e9ee7312edb008497186116f30bfc
-rw-r--r--src/osmo_client_core.c10
-rw-r--r--src/osmo_client_network.c14
-rw-r--r--src/osmo_server_network.c18
3 files changed, 21 insertions, 21 deletions
diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c
index 025e3a4..59a6777 100644
--- a/src/osmo_client_core.c
+++ b/src/osmo_client_core.c
@@ -161,7 +161,7 @@ static int pcap_read_cb(struct osmo_fd *fd, unsigned int what)
data = pcap_next(client->handle, &hdr);
if (!data) {
- rate_ctr_inc(&client->ctrg->ctr[CLIENT_CTR_PERR]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(client->ctrg, CLIENT_CTR_PERR));
return -1;
}
@@ -190,14 +190,14 @@ static void add_psbl_wrapped_ctr(struct osmo_pcap_client *client,
* Only issue is we don't know sizeof(u_int)
*/
if (*old_val > new_val) {
- rate_ctr_add(&client->ctrg->ctr[ctr], P_CAP_UINT_MAX() - *old_val);
- rate_ctr_add(&client->ctrg->ctr[ctr], new_val);
+ rate_ctr_add(rate_ctr_group_get_ctr(client->ctrg, ctr), P_CAP_UINT_MAX() - *old_val);
+ rate_ctr_add(rate_ctr_group_get_ctr(client->ctrg, ctr), new_val);
*old_val = new_val;
return;
}
/* Just increment it */
- rate_ctr_add(&client->ctrg->ctr[ctr], new_val - *old_val);
+ rate_ctr_add(rate_ctr_group_get_ctr(client->ctrg, ctr), new_val - *old_val);
*old_val = new_val;
}
@@ -215,7 +215,7 @@ static void pcap_check_stats_cb(void *_client)
if (rc != 0) {
LOGP(DCLIENT, LOGL_ERROR, "Failed to query pcap stats: %s\n",
pcap_geterr(client->handle));
- rate_ctr_inc(&client->ctrg->ctr[CLIENT_CTR_PERR]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(client->ctrg, CLIENT_CTR_PERR));
return;
}
diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c
index e5616af..a36a285 100644
--- a/src/osmo_client_network.c
+++ b/src/osmo_client_network.c
@@ -60,7 +60,7 @@ 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\n", conn->name);
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_QERR]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_QERR));
msgb_free(msg);
return;
}
@@ -92,7 +92,7 @@ static int write_cb(struct osmo_fd *fd, struct msgb *msg)
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);
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_WERR]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_WERR));
lost_connection(conn);
return -1;
}
@@ -173,13 +173,13 @@ void osmo_client_send_data(struct osmo_pcap_client_conn *conn,
LOGP(DCLIENT, LOGL_ERROR,
"Recording truncated packet, len %zu > snaplen %zu\n",
(size_t) in_hdr->len, (size_t) in_hdr->caplen);
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_2BIG]);
+ 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");
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_NOMEM]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_NOMEM));
return;
}
@@ -199,8 +199,8 @@ void osmo_client_send_data(struct osmo_pcap_client_conn *conn,
memcpy(msg->l3h, data, in_hdr->caplen);
om_hdr->len = htons(msgb_l2len(msg));
- rate_ctr_add(&conn->client->ctrg->ctr[CLIENT_CTR_BYTES], hdr->caplen);
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_PKTS]);
+ rate_ctr_add(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_BYTES), hdr->caplen);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_PKTS));
break;
case PROTOCOL_IPIP:
offset = get_iphdr_offset(pcap_datalink(conn->client->handle));
@@ -305,7 +305,7 @@ void osmo_client_connect(struct osmo_pcap_client_conn *conn)
osmo_fd_setup(&conn->wqueue.bfd, rc, when, conn_cb, conn, 0);
osmo_fd_register(&conn->wqueue.bfd);
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_CONNECT]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_CONNECT));
}
void osmo_client_reconnect(struct osmo_pcap_client_conn *conn)
diff --git a/src/osmo_server_network.c b/src/osmo_server_network.c
index 164b161..47ede72 100644
--- a/src/osmo_server_network.c
+++ b/src/osmo_server_network.c
@@ -120,8 +120,8 @@ void osmo_pcap_server_close_trace(struct osmo_pcap_conn *conn)
if (conn->curr_filename) {
client_event(conn, "closingtracefile", conn->curr_filename);
- rate_ctr_inc(&conn->ctrg->ctr[PEER_CTR_PROTATE]);
- rate_ctr_inc(&conn->server->ctrg->ctr[SERVER_CTR_PROTATE]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->ctrg, PEER_CTR_PROTATE));
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->server->ctrg, SERVER_CTR_PROTATE));
talloc_free(conn->curr_filename);
conn->curr_filename = NULL;
}
@@ -422,12 +422,12 @@ static int read_cb_data(struct osmo_pcap_conn *conn)
conn->pend = sizeof(*conn->data);
/* count the full packet we got */
- rate_ctr_inc(&conn->ctrg->ctr[PEER_CTR_PKTS]);
- rate_ctr_inc(&conn->server->ctrg->ctr[SERVER_CTR_PKTS]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->ctrg, PEER_CTR_PKTS));
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->server->ctrg, SERVER_CTR_PKTS));
/* count the bytes of it */
- rate_ctr_add(&conn->ctrg->ctr[PEER_CTR_BYTES], conn->data->len);
- rate_ctr_add(&conn->server->ctrg->ctr[SERVER_CTR_BYTES], conn->data->len);
+ rate_ctr_add(rate_ctr_group_get_ctr(conn->ctrg, PEER_CTR_BYTES), conn->data->len);
+ rate_ctr_add(rate_ctr_group_get_ctr(conn->server->ctrg, SERVER_CTR_BYTES), conn->data->len);
switch (conn->data->type) {
case PKT_LINK_HDR:
@@ -520,7 +520,7 @@ static void new_connection(struct osmo_pcap_server *server,
return;
}
- rate_ctr_inc(&client->ctrg->ctr[PEER_CTR_CONNECT]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(client->ctrg, PEER_CTR_CONNECT));
client->state = STATE_INITIAL;
client->pend = sizeof(*client->data);
@@ -565,7 +565,7 @@ static int accept_cb(struct osmo_fd *fd, unsigned int when)
server = fd->data;
/* count any accept to see no clients */
- rate_ctr_inc(&server->ctrg->ctr[SERVER_CTR_CONNECT]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(server->ctrg, SERVER_CTR_CONNECT));
llist_for_each_entry(conn, &server->conn, entry) {
if (conn->remote_addr.s_addr == addr.sin_addr.s_addr) {
@@ -577,7 +577,7 @@ static int accept_cb(struct osmo_fd *fd, unsigned int when)
}
}
- rate_ctr_inc(&server->ctrg->ctr[SERVER_CTR_NOCLIENT]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(server->ctrg, SERVER_CTR_NOCLIENT));
/*
* TODO: In the future start with a tls handshake and see if we know