diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-02-11 17:04:27 +0100 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-02-11 18:42:05 +0100 |
commit | 2ee140ec27335ca50e813080ee0e85e4ab86af37 (patch) | |
tree | 83212c1effddb0e8cd2e4fe180eb90a448111863 /src/ipcpd/normal | |
parent | f0ef4bdbf66ed12e52ff33da90d79af0cbc00436 (diff) | |
download | ouroboros-2ee140ec27335ca50e813080ee0e85e4ab86af37.tar.gz ouroboros-2ee140ec27335ca50e813080ee0e85e4ab86af37.zip |
ipcpd: Prevent access to directory before init
Doing a directory query before the IPCP is has bootstrapped or is
enrolled will result in an assertion failure as the directory is not
yet ready. This fixes flow allocation over the LLC shim (which
triggers a directory query from the IRMd) with a normal IPCP present.
Diffstat (limited to 'src/ipcpd/normal')
-rw-r--r-- | src/ipcpd/normal/dir.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/ipcpd/normal/dir.c b/src/ipcpd/normal/dir.c index d30b9ec0..703f4e79 100644 --- a/src/ipcpd/normal/dir.c +++ b/src/ipcpd/normal/dir.c @@ -31,21 +31,22 @@ #include <string.h> #include <assert.h> +#define DIR_PATH "/" DIR_NAME + static char dir_path[RIB_MAX_PATH_LEN + 1]; static void dir_path_reset(void) { - dir_path[strlen("/" DIR_NAME)]= '\0'; - assert(strcmp("/" DIR_NAME, dir_path) == 0); + dir_path[strlen(DIR_PATH)]= '\0'; + assert(strcmp(DIR_PATH, dir_path) == 0); } int dir_init(void) { /*FIXME: set ribmgr dissemination here */ - if (rib_add(RIB_ROOT, DIR_NAME)) return -1; - strcpy(dir_path, "/" DIR_NAME); + strcpy(dir_path, DIR_PATH); return 0; } @@ -66,6 +67,9 @@ int dir_name_reg(char * name) assert(name); + if (ipcp_get_state() != IPCP_OPERATIONAL) + return -EPERM; + dir_path_reset(); ret = rib_add(dir_path, name); @@ -91,6 +95,9 @@ int dir_name_unreg(char * name) assert(name); + if (ipcp_get_state() != IPCP_OPERATIONAL) + return -EPERM; + dir_path_reset(); rib_path_append(dir_path, name); @@ -116,6 +123,9 @@ int dir_name_query(char * name) { size_t len; + if (ipcp_get_state() != IPCP_OPERATIONAL) + return -EPERM; + dir_path_reset(); rib_path_append(dir_path, name); |