summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2021-06-26 13:42:58 +0200
committerSander Vrijders <sander@ouroboros.rocks>2021-06-28 15:29:23 +0200
commit9d2688340bea357e2c2206f3c69ea64c866cb2ad (patch)
treef677da48234c8d38178c0af29a7e680318d229ed /src
parent18b0de19830e7286ad5eecbba23013e835739cdc (diff)
downloadouroboros-9d2688340bea357e2c2206f3c69ea64c866cb2ad.tar.gz
ouroboros-9d2688340bea357e2c2206f3c69ea64c866cb2ad.zip
ipcpd: Fix unregistering fa and dt RIBs
These RIBs were not properly unregistered on shutdown. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/unicast/dt.c17
-rw-r--r--src/ipcpd/unicast/fa.c6
2 files changed, 13 insertions, 10 deletions
diff --git a/src/ipcpd/unicast/dt.c b/src/ipcpd/unicast/dt.c
index 38fb51f3..9f15e2da 100644
--- a/src/ipcpd/unicast/dt.c
+++ b/src/ipcpd/unicast/dt.c
@@ -58,8 +58,9 @@
#include <inttypes.h>
#include <assert.h>
-#define QOS_BLOCK_LEN 672
-#define STAT_FILE_LEN (189 + QOS_BLOCK_LEN * QOS_CUBE_MAX)
+#define QOS_BLOCK_LEN 672
+#define RIB_FILE_STRLEN (189 + QOS_BLOCK_LEN * QOS_CUBE_MAX)
+#define RIB_NAME_STRLEN 256
#ifndef CLOCK_REALTIME_COARSE
#define CLOCK_REALTIME_COARSE CLOCK_REALTIME
@@ -192,7 +193,7 @@ static int dt_rib_read(const char * path,
/* NOTE: we may need stronger checks. */
fd = atoi(path);
- if (len < STAT_FILE_LEN)
+ if (len < RIB_FILE_STRLEN)
return 0;
buf[0] = '\0';
@@ -261,7 +262,7 @@ static int dt_rib_read(const char * path,
pthread_mutex_unlock(&dt.stat[fd].lock);
- return STAT_FILE_LEN;
+ return RIB_FILE_STRLEN;
#else
(void) path;
(void) buf;
@@ -339,7 +340,7 @@ static int dt_rib_getattr(const char * path,
pthread_mutex_lock(&dt.stat[fd].lock);
if (dt.stat[fd].stamp != -1) {
- attr->size = STAT_FILE_LEN;
+ attr->size = RIB_FILE_STRLEN;
attr->mtime = dt.stat[fd].stamp;
} else {
attr->size = 0;
@@ -561,7 +562,7 @@ int dt_init(enum pol_routing pr,
{
int i;
int j;
- char dtstr[256];
+ char dtstr[RIB_NAME_STRLEN + 1];
int pp;
struct conn_info info;
@@ -676,9 +677,11 @@ int dt_init(enum pol_routing pr,
void dt_fini(void)
{
+ char dtstr[RIB_NAME_STRLEN + 1];
int i;
- rib_unreg(DT);
+ sprintf(dtstr, "%s.%" PRIu64, DT, ipcpi.dt_addr);
+ rib_unreg(dtstr);
#ifdef IPCP_FLOW_STATS
for (i = 0; i < PROG_MAX_FLOWS; ++i)
pthread_mutex_destroy(&dt.stat[i].lock);
diff --git a/src/ipcpd/unicast/fa.c b/src/ipcpd/unicast/fa.c
index 428b5af7..de9ca83d 100644
--- a/src/ipcpd/unicast/fa.c
+++ b/src/ipcpd/unicast/fa.c
@@ -591,7 +591,6 @@ static void * fa_handle_packet(void * o)
int fa_init(void)
{
pthread_condattr_t cattr;
- char fastr[256];
if (pthread_rwlock_init(&fa.flows_lock, NULL))
goto fail_rwlock;
@@ -612,8 +611,7 @@ int fa_init(void)
list_head_init(&fa.cmds);
- sprintf(fastr, "%s", FA);
- if (rib_reg(fastr, &r_ops))
+ if (rib_reg(FA, &r_ops))
goto fail_rib_reg;
fa.eid = dt_reg_comp(&fa, &fa_post_packet, FA);
@@ -637,6 +635,8 @@ int fa_init(void)
void fa_fini(void)
{
+ rib_unreg(FA);
+
pthread_cond_destroy(&fa.cond);;
pthread_mutex_destroy(&fa.mtx);
pthread_rwlock_destroy(&fa.flows_lock);