summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2018-02-23 12:42:17 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2018-02-23 12:53:56 +0100
commitfe9d3fcb26b6ff30f4f02f14dddcde186b2955c1 (patch)
tree9d4d03468ed8993eb02d1407081dd9b3bcd872d3 /src
parent89388506dd7d88adfc9188547341d7f36bcce397 (diff)
downloadouroboros-fe9d3fcb26b6ff30f4f02f14dddcde186b2955c1.tar.gz
ouroboros-fe9d3fcb26b6ff30f4f02f14dddcde186b2955c1.zip
ipcpd: Print endpoint in flow statistics
The flow statistics will now print the endpoint of the flow. If it's a local endpoint for the IPCP, it will print the component (e.g. "flow-allocator"). For remote flows, it will print the address of the IPCP. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/normal/dht.c5
-rw-r--r--src/ipcpd/normal/dt.c31
-rw-r--r--src/ipcpd/normal/dt.h3
-rw-r--r--src/ipcpd/normal/fa.c5
4 files changed, 30 insertions, 14 deletions
diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c
index ebed4068..2577efc7 100644
--- a/src/ipcpd/normal/dht.c
+++ b/src/ipcpd/normal/dht.c
@@ -24,7 +24,8 @@
#include "config.h"
-#define OUROBOROS_PREFIX "dht"
+#define DHT "dht"
+#define OUROBOROS_PREFIX DHT
#include <ouroboros/hash.h>
#include <ouroboros/bitmap.h>
@@ -2767,7 +2768,7 @@ struct dht * dht_create(uint64_t addr)
if (tpm_start(dht->tpm))
goto fail_tpm_start;
- dht->fd = dt_reg_comp(dht, &dht_post_sdu);
+ dht->fd = dt_reg_comp(dht, &dht_post_sdu, DHT);
notifier_reg(handle_event, dht);
#else
(void) handle_event;
diff --git a/src/ipcpd/normal/dt.c b/src/ipcpd/normal/dt.c
index adf07d1a..d0ab1a14 100644
--- a/src/ipcpd/normal/dt.c
+++ b/src/ipcpd/normal/dt.c
@@ -53,11 +53,12 @@
#include <inttypes.h>
#include <assert.h>
-#define STAT_FILE_LEN 1590
+#define STAT_FILE_LEN 1627
struct comp_info {
void (* post_sdu)(void * comp, struct shm_du_buff * sdb);
void * comp;
+ char * name;
};
struct {
@@ -68,6 +69,7 @@ struct {
#ifdef IPCP_FLOW_STATS
struct {
time_t stamp;
+ uint64_t addr;
size_t snd_pkt[QOS_CUBE_MAX];
size_t rcv_pkt[QOS_CUBE_MAX];
size_t snd_bytes[QOS_CUBE_MAX];
@@ -102,6 +104,7 @@ static int dt_stat_read(const char * path,
int fd;
int i;
char str[587];
+ char addrstr[20];
/* NOTE: we may need stronger checks. */
fd = atoi(path);
@@ -118,6 +121,12 @@ static int dt_stat_read(const char * path,
return 0;
}
+ if (dt.stat[fd].addr == ipcpi.dt_addr)
+ sprintf(addrstr, dt.comps[fd].name);
+ else
+ sprintf(addrstr, "%" PRIu64, dt.stat[fd].addr);
+ sprintf(buf, "Endpt address: %20s\n", addrstr);
+
for (i = 0; i < QOS_CUBE_MAX; ++i) {
sprintf(str,
"Qos cube %d:\n"
@@ -263,8 +272,8 @@ static struct rib_ops r_ops = {
#ifdef IPCP_FLOW_STATS
-static void set_used(int fd,
- bool b)
+static void stat_used(int fd,
+ uint64_t addr)
{
struct timespec now;
@@ -274,13 +283,14 @@ static void set_used(int fd,
memset(&dt.stat[fd], 0, sizeof(dt.stat[fd]));
- dt.stat[fd].stamp = b ? now.tv_sec : 0;
+ dt.stat[fd].stamp = (addr != INVALID_ADDR) ? now.tv_sec : 0;
+ dt.stat[fd].addr = addr;
pthread_mutex_unlock(&dt.stat[fd].lock);
pthread_rwlock_wrlock(&dt.lock);
- b ? ++dt.n_flows : --dt.n_flows;
+ (addr != INVALID_ADDR) ? ++dt.n_flows : --dt.n_flows;
pthread_rwlock_unlock(&dt.lock);
}
@@ -299,14 +309,14 @@ static void handle_event(void * self,
switch (event) {
case NOTIFY_DT_CONN_ADD:
#ifdef IPCP_FLOW_STATS
- set_used(c->flow_info.fd, true);
+ stat_used(c->flow_info.fd, c->conn_info.addr);
#endif
sdu_sched_add(dt.sdu_sched, c->flow_info.fd);
log_dbg("Added fd %d to SDU scheduler.", c->flow_info.fd);
break;
case NOTIFY_DT_CONN_DEL:
#ifdef IPCP_FLOW_STATS
- set_used(c->flow_info.fd, false);
+ stat_used(c->flow_info.fd, INVALID_ADDR);
#endif
sdu_sched_del(dt.sdu_sched, c->flow_info.fd);
log_dbg("Removed fd %d from SDU scheduler.", c->flow_info.fd);
@@ -662,7 +672,8 @@ void dt_stop(void)
}
int dt_reg_comp(void * comp,
- void (* func)(void * func, struct shm_du_buff *))
+ void (* func)(void * func, struct shm_du_buff *),
+ char * name)
{
int res_fd;
@@ -679,13 +690,15 @@ int dt_reg_comp(void * comp,
assert(dt.comps[res_fd].post_sdu == NULL);
assert(dt.comps[res_fd].comp == NULL);
+ assert(dt.comps[res_fd].name == NULL);
dt.comps[res_fd].post_sdu = func;
dt.comps[res_fd].comp = comp;
+ dt.comps[res_fd].name = name;
pthread_rwlock_unlock(&dt.lock);
#ifdef IPCP_FLOW_STATS
- set_used(res_fd, true);
+ stat_used(res_fd, ipcpi.dt_addr);
#endif
return res_fd;
}
diff --git a/src/ipcpd/normal/dt.h b/src/ipcpd/normal/dt.h
index f3bfdc56..e0bbe3f3 100644
--- a/src/ipcpd/normal/dt.h
+++ b/src/ipcpd/normal/dt.h
@@ -46,7 +46,8 @@ int dt_start(void);
void dt_stop(void);
int dt_reg_comp(void * comp,
- void (* func)(void * comp, struct shm_du_buff * sdb));
+ void (* func)(void * comp, struct shm_du_buff * sdb),
+ char * name);
int dt_write_sdu(uint64_t dst_addr,
qoscube_t qc,
diff --git a/src/ipcpd/normal/fa.c b/src/ipcpd/normal/fa.c
index e7e5a786..00e93fb7 100644
--- a/src/ipcpd/normal/fa.c
+++ b/src/ipcpd/normal/fa.c
@@ -24,7 +24,8 @@
#include "config.h"
-#define OUROBOROS_PREFIX "flow-allocator"
+#define FA "flow-allocator"
+#define OUROBOROS_PREFIX FA
#include <ouroboros/logs.h>
#include <ouroboros/fqueue.h>
@@ -195,7 +196,7 @@ int fa_init(void)
if (pthread_rwlock_init(&fa.flows_lock, NULL))
return -1;
- fa.fd = dt_reg_comp(&fa, &fa_post_sdu);
+ fa.fd = dt_reg_comp(&fa, &fa_post_sdu, FA);
return 0;
}