aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/facemgr/src
diff options
context:
space:
mode:
Diffstat (limited to 'ctrl/facemgr/src')
-rw-r--r--ctrl/facemgr/src/api.c75
-rw-r--r--ctrl/facemgr/src/facelet.c25
-rw-r--r--ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c4
3 files changed, 71 insertions, 33 deletions
diff --git a/ctrl/facemgr/src/api.c b/ctrl/facemgr/src/api.c
index 7fbabbe72..ac436a433 100644
--- a/ctrl/facemgr/src/api.c
+++ b/ctrl/facemgr/src/api.c
@@ -1088,27 +1088,33 @@ facemgr_process_facelet(facemgr_t * facemgr, facelet_t * facelet)
goto ERR;
}
+ /* Facelets created from static get deleted */
#if 0
- if (facelet_set_remove(facemgr->facelet_cache, facelet, NULL) < 0) {
- ERROR("[facemgr_process_facelet] Could not remove deleted facelet from cache");
- goto ERR;
- }
- facelet_free(facelet);
-#else
- /* This works assuming the call to hicn-light is blocking */
- DEBUG("[facemgr_process_facelet] Cleaning cached data");
- facelet_unset_local_addr(facelet);
- facelet_unset_local_port(facelet);
- facelet_unset_remote_addr(facelet);
- facelet_unset_remote_port(facelet);
- facelet_unset_admin_state(facelet);
- facelet_unset_state(facelet);
- facelet_unset_bj_done(facelet);
+ if (facelet_get_id(facelet) > 0) {
+ if (facelet_set_remove(facemgr->facelet_cache, facelet, NULL) < 0) {
+ ERROR("[facemgr_process_facelet] Could not remove deleted facelet from cache");
+ return -1;
+ }
+ facelet_free(facelet);
+ } else {
+#endif
+ /* This works assuming the call to hicn-light is blocking */
+ DEBUG("[facemgr_process_facelet] Cleaning cached data");
+ facelet_unset_local_addr(facelet);
+ facelet_unset_local_port(facelet);
+ facelet_unset_remote_addr(facelet);
+ facelet_unset_remote_port(facelet);
+ facelet_unset_admin_state(facelet);
+ facelet_unset_state(facelet);
+ facelet_unset_bj_done(facelet);
+ facelet_clear_routes(facelet);
#ifdef WITH_ANDROID_UTILITY
- facelet_unset_au_done(facelet);
+ facelet_unset_au_done(facelet);
#endif /* WITH_ANDROID_UTILITY */
- facelet_set_status(facelet, FACELET_STATUS_DELETED);
+ facelet_set_status(facelet, FACELET_STATUS_DELETED);
+#if 0
+ }
#endif
break;
@@ -1323,6 +1329,8 @@ facemgr_consider_static_facelet(facemgr_t * facemgr, facelet_t * facelet)
if (facelet_found)
return 0;
+ facelet_set_id(static_facelet, ++facemgr->cur_static_id);
+
if (facelet_array_add(facemgr->static_facelets, static_facelet) < 0) {
ERROR("[facemgr_consider_static_facelet] Could not add facelet to static array");
facelet_free(static_facelet);
@@ -1494,9 +1502,34 @@ facemgr_process_facelet_delete(facemgr_t * facemgr, facelet_t * facelet)
case FACELET_STATUS_IGNORED:
case FACELET_STATUS_DOWN:
case FACELET_STATUS_CREATE:
- /* Face has not been created */
- facelet_unset_error(facelet);
- facelet_set_status(facelet, FACELET_STATUS_DELETED);
+#if 0
+ /* Facelets created from static get deleted */
+ if (facelet_get_id(facelet) > 0) {
+ if (facelet_set_remove(facemgr->facelet_cache, facelet, NULL) < 0) {
+ ERROR("[facemgr_process_facelet] Could not remove deleted facelet from cache");
+ return -1;
+ }
+ facelet_free(facelet);
+ } else {
+#endif
+ /* Face has not been created */
+ DEBUG("[facemgr_process_facelet] Cleaning cached data");
+ facelet_unset_local_addr(facelet);
+ facelet_unset_local_port(facelet);
+ facelet_unset_remote_addr(facelet);
+ facelet_unset_remote_port(facelet);
+ facelet_unset_admin_state(facelet);
+ facelet_unset_state(facelet);
+ facelet_unset_bj_done(facelet);
+ facelet_clear_routes(facelet);
+#ifdef WITH_ANDROID_UTILITY
+ facelet_unset_au_done(facelet);
+#endif /* WITH_ANDROID_UTILITY */
+ facelet_unset_error(facelet);
+ facelet_set_status(facelet, FACELET_STATUS_DELETED);
+#if 0
+ }
+#endif
break;
case FACELET_STATUS_UPDATE:
@@ -1590,8 +1623,8 @@ facemgr_process_facelet_create_no_family(facemgr_t * facemgr, facelet_t * facele
facelet_free(facelet_new);
continue;
}
+ facelet_set_id(facelet_new, facelet_get_id(static_facelet));
/* The id must be different than 0 */
- facelet_set_id(facelet_new, ++facemgr->cur_static_id);
facelet_set_attr_clean(facelet_new);
facelet_set_status(facelet, FACELET_STATUS_UNDEFINED);
diff --git a/ctrl/facemgr/src/facelet.c b/ctrl/facemgr/src/facelet.c
index cce7fe611..ac84f5f70 100644
--- a/ctrl/facemgr/src/facelet.c
+++ b/ctrl/facemgr/src/facelet.c
@@ -149,6 +149,12 @@ ERR_MALLOC:
return NULL;
}
+unsigned
+facelet_get_id(facelet_t * facelet)
+{
+ return facelet->id;
+}
+
void
facelet_set_id(facelet_t * facelet, unsigned id)
{
@@ -378,18 +384,7 @@ void
facelet_free(facelet_t * facelet)
{
/* Free up routes */
- hicn_route_t ** route_array;
- int n = route_set_get_array(facelet->routes, &route_array);
- if (n < 0) {
- ERROR("[facelet_free] Error getting route set associated to facelet");
- } else {
- for (unsigned i = 0; i < n; i++) {
- hicn_route_t * route = route_array[i];
- route_set_remove(facelet->routes, route, NULL);
- hicn_route_free(route);
- }
- }
- free(route_array);
+ route_set_clear(facelet->routes);
route_set_free(facelet->routes);
free(facelet);
}
@@ -1012,6 +1007,12 @@ facelet_remove_route(facelet_t * facelet, hicn_route_t * route, hicn_route_t **
}
int
+facelet_clear_routes(facelet_t * facelet)
+{
+ return route_set_clear(facelet->routes);
+}
+
+int
facelet_get_route_array(const facelet_t * facelet, hicn_route_t *** route_array)
{
return route_set_get_array(facelet->routes, route_array);
diff --git a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
index 71243aea1..b4e1f0695 100644
--- a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
+++ b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
@@ -108,6 +108,10 @@ int hl_process_state(interface_t * interface)
case HL_STATE_ROUTES_SENT:
case HL_STATE_FACES_SENT:
+ INFO("[hl_process_state] Out of sync... resetting state");
+ data->state = HL_STATE_IDLE;
+ break;
+
case HL_STATE_UNDEFINED:
case HL_STATE_N:
ERROR("[hl_process_state] Unexpected state");