summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/ouroboros/rib.h3
-rw-r--r--src/ipcpd/unicast/dt.c14
-rw-r--r--src/ipcpd/unicast/fa.c12
-rw-r--r--src/ipcpd/unicast/pol/link_state.c12
-rw-r--r--src/lib/rib.c19
5 files changed, 42 insertions, 18 deletions
diff --git a/include/ouroboros/rib.h b/include/ouroboros/rib.h
index 3a74bee3..9eab6334 100644
--- a/include/ouroboros/rib.h
+++ b/include/ouroboros/rib.h
@@ -23,7 +23,8 @@
#ifndef OUROBOROS_LIB_RIB_H
#define OUROBOROS_LIB_RIB_H
-#define RIB_PATH_LEN 128
+#define RIB_PATH_LEN 128
+#define RIB_SEPARATOR "/"
#include <sys/types.h>
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;
diff --git a/src/lib/rib.c b/src/lib/rib.c
index b5222d6d..dfac69d7 100644
--- a/src/lib/rib.c
+++ b/src/lib/rib.c
@@ -52,8 +52,6 @@
#define CLOCK_REALTIME_COARSE CLOCK_REALTIME
#endif
-#define RT "/"
-
struct reg_comp {
struct list_head next;
@@ -108,8 +106,7 @@ static int rib_read(const char * path,
strcpy(comp, path + 1);
- c = strstr(comp, "/");
-
+ c = strstr(comp, RIB_SEPARATOR);
if (c != NULL)
*c = '\0';
@@ -121,7 +118,7 @@ static int rib_read(const char * path,
list_for_each(p, &rib.reg_comps) {
struct reg_comp * r = list_entry(p, struct reg_comp, next);
if (strcmp(comp, r->path) == 0) {
- int ret = r->ops->read(c + 1, buf, size);
+ int ret = r->ops->read(path + 1, buf, size);
pthread_rwlock_unlock(&rib.lock);
return ret;
}
@@ -148,7 +145,7 @@ static int rib_readdir(const char * path,
pthread_rwlock_rdlock(&rib.lock);
- if (strcmp(path, RT) == 0) {
+ if (strcmp(path, RIB_SEPARATOR) == 0) {
list_for_each(p, &rib.reg_comps) {
struct reg_comp * c;
c = list_entry(p, struct reg_comp, next);
@@ -194,8 +191,7 @@ static size_t __getattr(const char * path,
strcpy(comp, path + 1);
- c = strstr(comp, "/");
-
+ c = strstr(comp, RIB_SEPARATOR);
if (c != NULL)
*c = '\0';
@@ -206,7 +202,7 @@ static size_t __getattr(const char * path,
list_for_each(p, &rib.reg_comps) {
struct reg_comp * r = list_entry(p, struct reg_comp, next);
if (strcmp(comp, r->path) == 0) {
- size_t ret = r->ops->getattr(c + 1, &attr);
+ size_t ret = r->ops->getattr(path + 1, &attr);
pthread_rwlock_unlock(&rib.lock);
st->st_mode = S_IFREG | 0755;
st->st_nlink = 1;
@@ -231,7 +227,7 @@ static int rib_getattr(const char * path,
memset(st, 0, sizeof(*st));
- if (strcmp(path, RT) == 0)
+ if (strcmp(path, RIB_SEPARATOR) == 0)
goto finish_dir;
pthread_rwlock_rdlock(&rib.lock);
@@ -352,6 +348,9 @@ void rib_fini(void)
struct list_head * p;
struct list_head * h;
+ if (strlen(rib.mnt) == 0)
+ return;
+
fuse_exit(rib.fuse);
fuse_unmount(rib.mnt, rib.ch);