From eb8ed5e4ebef1b34bc6dd749fb7210cac618a9fe Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Wed, 28 Feb 2018 14:06:01 +0100 Subject: lib: Add fccntl operation to get queue lengths This adds the FLOWGRXQLEN and FLOWGTXQLEN operations to fccntl to get the number of packets that are in the receive and transmit buffers respectively. The flow statistics are updated to show these queue lengths. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/normal/dt.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/ipcpd/normal/dt.c') diff --git a/src/ipcpd/normal/dt.c b/src/ipcpd/normal/dt.c index 566ede24..68cd498f 100644 --- a/src/ipcpd/normal/dt.c +++ b/src/ipcpd/normal/dt.c @@ -35,6 +35,9 @@ #include #include #include +#ifdef IPCP_FLOW_STATS +#include +#endif #include "connmgr.h" #include "ipcp.h" @@ -53,7 +56,7 @@ #include #include -#define STAT_FILE_LEN 2088 +#define STAT_FILE_LEN 2205 #ifndef CLOCK_REALTIME_COARSE #define CLOCK_REALTIME_COARSE CLOCK_REALTIME @@ -110,6 +113,8 @@ static int dt_stat_read(const char * path, char str[681]; char addrstr[20]; char tmstr[20]; + size_t rxqlen = 0; + size_t txqlen = 0; struct tm * tm; /* NOTE: we may need stronger checks. */ @@ -135,10 +140,17 @@ static int dt_stat_read(const char * path, tm = localtime(&dt.stat[fd].stamp); strftime(tmstr, sizeof(tmstr), "%F %T", tm); + if (fd >= PROG_RES_FDS) { + fccntl(fd, FLOWGRXQLEN, &rxqlen); + fccntl(fd, FLOWGTXQLEN, &txqlen); + } + sprintf(buf, - "Established : %20s\n" - "Endpt address: %20s\n", - tmstr, addrstr); + "Flow established at: %20s\n" + "Endpoint address: %20s\n" + "Queued packets (rx): %20zu\n" + "Queued packets (tx): %20zu\n\n", + tmstr, addrstr, rxqlen, txqlen); for (i = 0; i < QOS_CUBE_MAX; ++i) { sprintf(str, @@ -430,7 +442,7 @@ static void sdu_handler(int fd, #endif } else { dt_pci_shrink(sdb); - if (dt_pci.eid > PROG_RES_FDS) { + if (dt_pci.eid >= PROG_RES_FDS) { if (ipcp_flow_write(dt_pci.eid, sdb)) { ipcp_sdb_release(sdb); #ifdef IPCP_FLOW_STATS -- cgit v1.2.3