From d5c7ea1f1470e5a0cd1e2818034f248f6b5dbd02 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 28 Jun 2021 21:47:09 +0200 Subject: 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 ///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 ///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 //flows/ 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 Signed-off-by: Sander Vrijders --- src/ipcpd/unicast/pol/link_state.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ipcpd/unicast/pol') 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; -- cgit v1.2.3