diff options
author | Dimitri Staessens <[email protected]> | 2018-02-28 14:06:01 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2018-02-28 14:15:53 +0100 |
commit | eb8ed5e4ebef1b34bc6dd749fb7210cac618a9fe (patch) | |
tree | 17d4e6e5cb6f69c583056fa47d81630ba318b93d | |
parent | 4159e60f9b61dd5c8ac33cd2dea3ff81945c06ce (diff) | |
download | ouroboros-eb8ed5e4ebef1b34bc6dd749fb7210cac618a9fe.tar.gz ouroboros-eb8ed5e4ebef1b34bc6dd749fb7210cac618a9fe.zip |
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 <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
-rw-r--r-- | doc/man/fccntl.3 | 8 | ||||
-rw-r--r-- | include/ouroboros/fccntl.h | 10 | ||||
-rw-r--r-- | src/ipcpd/normal/dt.c | 22 | ||||
-rw-r--r-- | src/lib/dev.c | 9 |
4 files changed, 40 insertions, 9 deletions
diff --git a/doc/man/fccntl.3 b/doc/man/fccntl.3 index 8cd64b13..34e63e7d 100644 --- a/doc/man/fccntl.3 +++ b/doc/man/fccntl.3 @@ -2,7 +2,7 @@ .\" Dimitri Staessens <[email protected]> .\" Sander Vrijders <[email protected]> -.TH FCCNTL 3 2017-08-30 Ouroboros "Ouroboros Programmer's Manual" +.TH FCCNTL 3 2018-02-28 Ouroboros "Ouroboros Programmer's Manual" .SH NAME @@ -65,6 +65,12 @@ argument. Supported flags are: \fBFLOWGFLAGS\fR - get the current flow flags. Takes an \fBuint32_t \fIflags\fR as third argument. +\fBFLOWGRXQLEN\fR - get the current number of packets in the receive +buffer. Takes a \fBsize_t \fIqlen\fR as third argument. + +\fBFLOWGTXQLEN\fR - get the current number of packets in the transmit +buffer. Takes a \fBsize_t \fIqlen\fR as third argument. + \fBFRCTSFLAGS\fR - set FRCT flags. Takes FRCT flags as third argument. Supported flags are: diff --git a/include/ouroboros/fccntl.h b/include/ouroboros/fccntl.h index 55e6a343..8940e6ef 100644 --- a/include/ouroboros/fccntl.h +++ b/include/ouroboros/fccntl.h @@ -50,7 +50,7 @@ #define FRCTFORDERING 00000010 /* Ordered delivery */ #define FRCTFPARTIAL 00000020 /* Allow partial delivery */ -/* Operations */ +/* Flow operations */ #define FLOWSRCVTIMEO 00000001 /* Set read timeout */ #define FLOWGRCVTIMEO 00000002 /* Get read timeout */ #define FLOWSSNDTIMEO 00000003 /* Set send timeout */ @@ -58,8 +58,12 @@ #define FLOWGQOSSPEC 00000005 /* Get qosspec_t */ #define FLOWSFLAGS 00000006 /* Set flags for flow */ #define FLOWGFLAGS 00000007 /* Get flags for flow */ -#define FRCTSFLAGS 00000010 /* Set flags for FRCT */ -#define FRCTGFLAGS 00000011 /* Get flags for FRCT */ +#define FLOWGRXQLEN 00000010 /* Get queue length on rx */ +#define FLOWGTXQLEN 00000011 /* Get queue length on tx */ + +/* FRCT operations */ +#define FRCTSFLAGS 00001000 /* Set flags for FRCT */ +#define FRCTGFLAGS 00001001 /* Get flags for FRCT */ __BEGIN_DECLS 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 <ouroboros/dev.h> #include <ouroboros/notifier.h> #include <ouroboros/rib.h> +#ifdef IPCP_FLOW_STATS +#include <ouroboros/fccntl.h> +#endif #include "connmgr.h" #include "ipcp.h" @@ -53,7 +56,7 @@ #include <inttypes.h> #include <assert.h> -#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 diff --git a/src/lib/dev.c b/src/lib/dev.c index 99ab4359..7e829a5f 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -670,6 +670,7 @@ int fccntl(int fd, qosspec_t * qs; uint32_t rx_acl; uint32_t tx_acl; + size_t * qlen; struct flow * flow; if (fd < 0 || fd >= PROG_MAX_FLOWS) @@ -728,6 +729,14 @@ int fccntl(int fd, goto einval; *qs = flow->spec; break; + case FLOWGRXQLEN: + qlen = va_arg(l, size_t *); + *qlen = shm_rbuff_queued(flow->rx_rb); + break; + case FLOWGTXQLEN: + qlen = va_arg(l, size_t *); + *qlen = shm_rbuff_queued(flow->rx_rb); + break; case FLOWSFLAGS: flow->oflags = va_arg(l, uint32_t); rx_acl = shm_rbuff_get_acl(flow->rx_rb); |