diff options
author | Dimitri Staessens <[email protected]> | 2021-06-28 21:47:09 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2021-06-29 08:56:03 +0200 |
commit | d5c7ea1f1470e5a0cd1e2818034f248f6b5dbd02 (patch) | |
tree | fd97e0b4b84e80f2429727e8882158647c0f563f /src/ipcpd | |
parent | 16675c72764c59644c1822bf481482fcbd6e850c (diff) | |
download | ouroboros-d5c7ea1f1470e5a0cd1e2818034f248f6b5dbd02.tar.gz ouroboros-d5c7ea1f1470e5a0cd1e2818034f248f6b5dbd02.zip |
lib: Pass full path for RIB entries
The read functions for the RIB will now receive the full path, instead
of only the entry name. For IPCPs, we organized the RIB in an
/<ipcp>/<component>/entries
structure with a directory per component, so we don't need the full
path at this point. For process flow information, it's a lot more
convenient to organize it the following way
/<pid>/<fd>/stat
We can then register/unregister the flow descriptor when the frct
instance is created, and for getting the stats, we'd know the flow
descriptor from the fuse file path. If we would create a file per flow
instead of a directory per flow, something like
/<pid>/flows/<fd>
we'd need to do additional bookkeeping to list the contents of that
directory (we would need to track all flows with an active FRCT
instance), that fuse knows because it tracks the directories.
Signed-off-by: Dimitri Staessens <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/ipcpd')
-rw-r--r-- | src/ipcpd/unicast/dt.c | 14 | ||||
-rw-r--r-- | src/ipcpd/unicast/fa.c | 12 | ||||
-rw-r--r-- | src/ipcpd/unicast/pol/link_state.c | 12 |
3 files changed, 31 insertions, 7 deletions
diff --git a/src/ipcpd/unicast/dt.c b/src/ipcpd/unicast/dt.c index 9f15e2da..0f504daa 100644 --- a/src/ipcpd/unicast/dt.c +++ b/src/ipcpd/unicast/dt.c @@ -185,13 +185,17 @@ static int dt_rib_read(const char * path, int i; char str[QOS_BLOCK_LEN + 1]; char addrstr[20]; + char * entry; char tmstr[20]; size_t rxqlen = 0; size_t txqlen = 0; struct tm * tm; /* NOTE: we may need stronger checks. */ - fd = atoi(path); + entry = strstr(path, RIB_SEPARATOR) + 1; + assert(entry); + + fd = atoi(entry); if (len < RIB_FILE_STRLEN) return 0; @@ -333,9 +337,13 @@ static int dt_rib_getattr(const char * path, struct rib_attr * attr) { #ifdef IPCP_FLOW_STATS - int fd; + int fd; + char * entry; + + entry = strstr(path, RIB_SEPARATOR) + 1; + assert(entry); - fd = atoi(path); + fd = atoi(entry); pthread_mutex_lock(&dt.stat[fd].lock); diff --git a/src/ipcpd/unicast/fa.c b/src/ipcpd/unicast/fa.c index de9ca83d..2fa335e2 100644 --- a/src/ipcpd/unicast/fa.c +++ b/src/ipcpd/unicast/fa.c @@ -133,9 +133,13 @@ static int fa_rib_read(const char * path, char r_eidstr[21]; char tmstr[20]; char castr[1024]; + char * entry; struct tm * tm; - fd = atoi(path); + entry = strstr(path, RIB_SEPARATOR) + 1; + assert(entry); + + fd = atoi(entry); if (fd < 0 || fd > PROG_MAX_FLOWS) return -1; @@ -253,9 +257,13 @@ static int fa_rib_getattr(const char * path, { #ifdef IPCP_FLOW_STATS int fd; + char * entry; struct fa_flow * flow; - fd = atoi(path); + entry = strstr(path, RIB_SEPARATOR) + 1; + assert(entry); + + fd = atoi(entry); flow = &fa.flows[fd]; diff --git a/src/ipcpd/unicast/pol/link_state.c b/src/ipcpd/unicast/pol/link_state.c index 882bb8ac..08d39372 100644 --- a/src/ipcpd/unicast/pol/link_state.c +++ b/src/ipcpd/unicast/pol/link_state.c @@ -184,15 +184,19 @@ static int lsdb_rib_getattr(const char * path, { struct adjacency * adj; struct timespec now; + char * entry; assert(path); assert(attr); + entry = strstr(path, RIB_SEPARATOR) + 1; + assert(entry); + clock_gettime(CLOCK_REALTIME_COARSE, &now); pthread_rwlock_rdlock(&ls.db_lock); - adj = get_adj(path); + adj = get_adj(entry); if (adj != NULL) { attr->mtime = adj->stamp; attr->size = LS_ENTRY_SIZE; @@ -211,16 +215,20 @@ static int lsdb_rib_read(const char * path, size_t len) { struct adjacency * a; + char * entry; int size; assert(path); + entry = strstr(path, RIB_SEPARATOR) + 1; + assert(entry); + pthread_rwlock_rdlock(&ls.db_lock); if (ls.db_len + ls.nbs_len == 0) goto fail; - a = get_adj(path); + a = get_adj(entry); if (a == NULL) goto fail; |