From 373efaf24d3600fe4dadf6bfaaee8d19e2ec32d7 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Mon, 6 Feb 2017 16:05:44 +0100 Subject: ipcpd, lib: Revise normal IPCP This PR updates the normal IPCP to use the new RIB. The old ribmgr is removed and replaced by a stub that needs to be implemented. All components (dir, fmgr, frct) were adapted to the new RIB API. A lot of functionality was moved outside of the ribmgr, such as the addr_auth, which is now a component of the IPCP. The address is also stored to the ipcpi struct. The irm tool has an option to set the gam policy of the rib manager. --- src/ipcpd/normal/gam.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/ipcpd/normal/gam.c') diff --git a/src/ipcpd/normal/gam.c b/src/ipcpd/normal/gam.c index 0e626115..c337afd0 100644 --- a/src/ipcpd/normal/gam.c +++ b/src/ipcpd/normal/gam.c @@ -27,8 +27,8 @@ #include #include #include +#include -#include "ribmgr.h" #include "ipcp.h" #include "gam.h" #include "pol-gam-ops.h" @@ -72,6 +72,7 @@ struct gam * gam_create(enum pol_gam gam_type, tmp->ops = &complete_ops; break; default: + LOG_ERR("Unknown gam policy: %d.", gam_type); free(tmp); return NULL; } @@ -106,6 +107,14 @@ struct gam * gam_create(enum pol_gam gam_type, return NULL; } + if (tmp->ops->start(tmp->ops_o)) { + pthread_cond_destroy(&tmp->gas_cond); + pthread_mutex_destroy(&tmp->gas_lock); + free(tmp->ae_name); + free(tmp); + return NULL; + } + return tmp; } @@ -116,19 +125,25 @@ void gam_destroy(struct gam * instance) assert(instance); - instance->ops->destroy(instance->ops_o); + instance->ops->stop(instance->ops_o); - pthread_mutex_destroy(&instance->gas_lock); - pthread_cond_destroy(&instance->gas_cond); + pthread_mutex_lock(&instance->gas_lock); list_for_each_safe(p, n, &instance->gas) { struct ga * e = list_entry(p, struct ga, next); list_del(&e->next); + free(e->info->name); free(e->info); free(e); } + pthread_mutex_unlock(&instance->gas_lock); + + pthread_mutex_destroy(&instance->gas_lock); + pthread_cond_destroy(&instance->gas_cond); + free(instance->ae_name); + instance->ops->destroy(instance->ops_o); free(instance); } @@ -154,6 +169,8 @@ static int add_ga(struct gam * instance, pthread_cond_signal(&instance->gas_cond); pthread_mutex_unlock(&instance->gas_lock); + LOG_INFO("Added %s flow to %s.", instance->ae_name, info->name); + return 0; } @@ -170,7 +187,7 @@ int gam_flow_arr(struct gam * instance, return -1; } - cacep = cacep_create(fd, ipcpi.name, ribmgr_address()); + cacep = cacep_create(fd, ipcpi.name, ipcpi.address); if (cacep == NULL) { LOG_ERR("Failed to create CACEP instance."); return -1; @@ -187,12 +204,14 @@ int gam_flow_arr(struct gam * instance, if (instance->ops->accept_flow(instance->ops_o, qs, info)) { flow_dealloc(fd); + free(info->name); free(info); return 0; } if (add_ga(instance, fd, qs, info)) { LOG_ERR("Failed to add ga to graph adjacency manager list."); + free(info->name); free(info); return -1; } @@ -208,6 +227,7 @@ int gam_flow_alloc(struct gam * instance, struct cacep_info * info; int fd; + fd = flow_alloc(dst_name, instance->ae_name, NULL); if (fd < 0) { LOG_ERR("Failed to allocate flow to %s.", dst_name); @@ -220,7 +240,7 @@ int gam_flow_alloc(struct gam * instance, return -1; } - cacep = cacep_create(fd, ipcpi.name, ribmgr_address()); + cacep = cacep_create(fd, ipcpi.name, ipcpi.address); if (cacep == NULL) { LOG_ERR("Failed to create CACEP instance."); return -1; -- cgit v1.2.3