summaryrefslogtreecommitdiffstats
path: root/ctrl
diff options
context:
space:
mode:
Diffstat (limited to 'ctrl')
-rw-r--r--ctrl/facemgr/src/api.c71
-rw-r--r--ctrl/facemgr/src/cfg.c5
-rw-r--r--ctrl/facemgr/src/facelet.c12
-rw-r--r--ctrl/facemgr/src/facelet.h5
-rw-r--r--ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c1
-rw-r--r--ctrl/facemgr/src/main.c52
6 files changed, 110 insertions, 36 deletions
diff --git a/ctrl/facemgr/src/api.c b/ctrl/facemgr/src/api.c
index 88595a9bc..de0f062d3 100644
--- a/ctrl/facemgr/src/api.c
+++ b/ctrl/facemgr/src/api.c
@@ -833,12 +833,6 @@ facemgr_process_create(facemgr_t * facemgr, facelet_t * facelet)
*/
int rc;
- if (facelet_cache_add(&facemgr->facelet_cache, facelet) < 0) {
- ERROR("[facemgr_process_create] Error adding facelet to cache");
- return -1;
- }
- DEBUG("Facelet added to cache");
-
/*
* If the facelet does not satisfy filters, we do not lose any information
* but do not take any action to complement the face
@@ -998,6 +992,7 @@ facemgr_process_update(facemgr_t * facemgr, facelet_t * facelet)
}
/* Process GET/UDPATE... */
+ int rc;
switch(facelet_get_status(facelet)) {
case FACELET_STATUS_UNDEFINED:
ERROR("[facemgr_process_update] Unexpected facelet status");
@@ -1015,6 +1010,13 @@ facemgr_process_update(facemgr_t * facemgr, facelet_t * facelet)
return -1;
}
}
+
+ rc = facemgr_facelet_satisfy_rules(facemgr, facelet);
+ if (rc == -3) {
+ /* Does not satisfy rules */
+ return 0;
+ }
+
if (!facelet_validate_face(facelet))
return 0;
@@ -1044,6 +1046,12 @@ facemgr_process_update(facemgr_t * facemgr, facelet_t * facelet)
}
}
+ rc = facemgr_facelet_satisfy_rules(facemgr, facelet);
+ if (rc == -3) {
+ /* Does not satisfy rules */
+ return 0;
+ }
+
if (!facelet_validate_face(facelet))
return 0;
@@ -1075,15 +1083,30 @@ facemgr_process_update(facemgr_t * facemgr, facelet_t * facelet)
int
facemgr_process_delete(facemgr_t * facemgr, facelet_t * facelet)
{
+
+ DEBUG("[facemgr_process_delete] Deleting facelet on hicn-light");
if (interface_on_event(facemgr->hl, facelet) < 0)
return -1;
+ /*
+ * It might be tempting to cache old information, but for now we reset the
+ * facelet state that might change (such as IP addresses etc).
+ * netdevice, netdevice_type and admin_state should not be affected.
+ */
+ DEBUG("[facemgr_process_delete] Cleaning cached data");
+ facelet_unset_local_addr(facelet);
+ facelet_unset_local_port(facelet);
+ facelet_unset_remote_addr(facelet);
+ facelet_unset_remote_port(facelet);
+
facelet_set_status(facelet, FACELET_STATUS_DELETED);
- //facelet_set_bj_done(facelet, false);
+
+ facelet_unset_bj_done(facelet);
return 0;
}
+
/**
* \brief Process incoming events from interfaces
*
@@ -1113,8 +1136,15 @@ facemgr_on_event(facemgr_t * facemgr, facelet_t * facelet_in)
/* This is a new facelet... we expect a CREATE event. */
switch(facelet_get_event(facelet_in)) {
case FACELET_EVENT_CREATE:
+
+ if (facelet_cache_add(&facemgr->facelet_cache, facelet_in) < 0) {
+ ERROR("[facemgr_on_event] Error adding facelet to cache");
+ return -1;
+ }
+ DEBUG("Facelet added to cache");
+
if (facemgr_process_create(facemgr, facelet_in) < 0) {
- ERROR("[facemgr_process_cached_facelet] Error processing CREATE event");
+ ERROR("[facemgr_on_event] Error processing CREATE event");
goto ERR;
}
break;
@@ -1122,7 +1152,7 @@ facemgr_on_event(facemgr_t * facemgr, facelet_t * facelet_in)
case FACELET_EVENT_GET:
/* Insert new facelet in cached */
if (facemgr_process_get(facemgr, facelet_in) < 0) {
- ERROR("[facemgr_process_cached_facelet] Error processing GET event");
+ ERROR("[facemgr_on_event] Error processing GET event");
goto ERR;
}
break;
@@ -1162,10 +1192,17 @@ facemgr_on_event(facemgr_t * facemgr, facelet_t * facelet_in)
DEBUG("... match #%d", i);
switch(facelet_get_event(facelet_in)) {
case FACELET_EVENT_CREATE:
- // FIXME, this might occur if the facemgr restarts and we try to
- // re-create existing faces
- ERROR("[facemgr_on_event] CREATE event for a face that already exists...");
- ret = -1;
+ // This case will occur when we try to re-create existing faces,
+ // eg. in the situation of a forwarder restarting.
+ // likely this occurs when the interface receives a (potentially new) address
+ if (facelet_merge(facelet, facelet_in) < 0) {
+ ERROR("[facemgr_on_event] Error merging facelets");
+ continue;
+ }
+ if (facemgr_process_create(facemgr, facelet) < 0) {
+ ERROR("[facemgr_on_event] Error processing CREATE event");
+ ret = -1;
+ }
continue;
case FACELET_EVENT_GET: /* should be an INFORM message */
@@ -1176,14 +1213,6 @@ facemgr_on_event(facemgr_t * facemgr, facelet_t * facelet_in)
continue;
case FACELET_EVENT_UPDATE:
- {
- DEBUG("FACELET_EVENT_UPDATE");
- char buf[128];
- facelet_snprintf(buf, 128, facelet_in);
- DEBUG("MERGE %s", buf);
- facelet_snprintf(buf, 128, facelet);
- DEBUG(" ON %s", buf);
- }
if (facelet_merge(facelet, facelet_in) < 0) {
ERROR("[facemgr_on_event] Error merging facelets");
continue;
diff --git a/ctrl/facemgr/src/cfg.c b/ctrl/facemgr/src/cfg.c
index 6b04208bb..be7ea33bb 100644
--- a/ctrl/facemgr/src/cfg.c
+++ b/ctrl/facemgr/src/cfg.c
@@ -112,6 +112,11 @@ facemgr_cfg_override_initialize(facemgr_cfg_override_t * override)
override->is_discovery = false;
override->discovery = false;
+ override->is_ipv4 = false;
+ override->ipv6 = false;
+ override->is_ipv6 = false;
+ override->ipv6 = false;
+
override->overlays.v4 = NULL;
override->overlays.v6 = NULL;
diff --git a/ctrl/facemgr/src/facelet.c b/ctrl/facemgr/src/facelet.c
index 8a3074d2a..def901ff3 100644
--- a/ctrl/facemgr/src/facelet.c
+++ b/ctrl/facemgr/src/facelet.c
@@ -518,6 +518,11 @@ facelet_set_ ## NAME(facelet_t * facelet, TYPE NAME)
return facelet_set_local_ ## NAME(facelet, NAME); \
} \
\
+int \
+facelet_unset_ ## NAME(facelet_t * facelet) \
+{ \
+ return facelet->NAME ## _status = FACELET_ATTR_STATUS_UNSET; \
+}
#define _(TYPE, NAME) FACELET_ACCESSORS(TYPE, NAME)
foreach_facelet_attr
@@ -779,6 +784,13 @@ facelet_set_bj_done(facelet_t * facelet)
facelet->bj_done = true;
}
+void
+facelet_unset_bj_done(facelet_t * facelet)
+{
+ facelet->bj_done = false;
+}
+
+
bool
facelet_is_bj_done(const facelet_t * facelet)
{
diff --git a/ctrl/facemgr/src/facelet.h b/ctrl/facemgr/src/facelet.h
index fecee8641..e07572e23 100644
--- a/ctrl/facemgr/src/facelet.h
+++ b/ctrl/facemgr/src/facelet.h
@@ -152,12 +152,12 @@ bool facelet_match(const facelet_t * facelet, const facelet_t * facelet_match);
*/
bool facelet_has_key(const facelet_t * facelet);
-
#define FACELET_ACCESSORS_H(TYPE, NAME) \
bool facelet_has_ ## NAME(const facelet_t * facelet); \
facelet_attr_status_t facelet_get_ ## NAME ## _status(const facelet_t * facelet);\
int facelet_get_ ## NAME(const facelet_t * facelet, TYPE * NAME); \
-int facelet_set_ ## NAME(facelet_t * facelet, TYPE NAME);
+int facelet_set_ ## NAME(facelet_t * facelet, TYPE NAME); \
+int facelet_unset_ ## NAME(facelet_t * facelet);
#define _(TYPE, NAME) FACELET_ACCESSORS_H(TYPE, NAME)
foreach_facelet_attr
@@ -175,6 +175,7 @@ int facelet_remove_pending(facelet_t * facelet);
bool facelet_has_pending(const facelet_t * facelet);
void facelet_set_bj_done(facelet_t * facelet);
+void facelet_unset_bj_done(facelet_t * facelet);
bool facelet_is_bj_done(const facelet_t * facelet);
void facelet_set_au_done(facelet_t * facelet);
bool facelet_is_au_done(const facelet_t * facelet);
diff --git a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
index e42c6c6ae..3ebbee4a1 100644
--- a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
+++ b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
@@ -205,7 +205,6 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet)
ERROR("Failed to delete face\n");
goto ERR;
}
- INFO("Deleted face id=%d\n", hc_face.id);
break;
case FACELET_EVENT_UPDATE:
diff --git a/ctrl/facemgr/src/main.c b/ctrl/facemgr/src/main.c
index 2a336db8f..307d05236 100644
--- a/ctrl/facemgr/src/main.c
+++ b/ctrl/facemgr/src/main.c
@@ -211,14 +211,18 @@ parse_config_global(facemgr_cfg_t * cfg, config_setting_t * setting)
config_setting_t *overlay_v4 = config_setting_get_member(overlay, "ipv4");
if (overlay_v4) {
const char * local_addr_str, * remote_addr_str;
- ip_address_t local_addr, remote_addr;
+ ip_address_t local_addr = IP_ADDRESS_EMPTY;
+ ip_address_t remote_addr = IP_ADDRESS_EMPTY;
ip_address_t * local_addr_p = NULL;
ip_address_t * remote_addr_p = NULL;
int local_port = 0;
int remote_port = 0;
if (config_setting_lookup_string(overlay_v4, "local_addr", &local_addr_str)) {
- ip_address_pton(local_addr_str, &local_addr);
+ if (ip_address_pton(local_addr_str, &local_addr) < 0) {
+ ERROR("Error parsing v4 local addr");
+ goto ERR;
+ }
local_addr_p = &local_addr;
}
@@ -228,7 +232,10 @@ parse_config_global(facemgr_cfg_t * cfg, config_setting_t * setting)
}
if (config_setting_lookup_string(overlay_v4, "remote_addr", &remote_addr_str)) {
- ip_address_pton(remote_addr_str, &remote_addr);
+ if (ip_address_pton(remote_addr_str, &remote_addr) < 0) {
+ ERROR("Error parsing v4 remote addr");
+ goto ERR;
+ }
remote_addr_p = &remote_addr;
}
@@ -247,14 +254,18 @@ parse_config_global(facemgr_cfg_t * cfg, config_setting_t * setting)
config_setting_t *overlay_v6 = config_setting_get_member(overlay, "ipv6");
if (overlay_v6) {
const char * local_addr_str, * remote_addr_str;
- ip_address_t local_addr, remote_addr;
+ ip_address_t local_addr = IP_ADDRESS_EMPTY;
+ ip_address_t remote_addr = IP_ADDRESS_EMPTY;
ip_address_t * local_addr_p = NULL;
ip_address_t * remote_addr_p = NULL;
int local_port = 0;
int remote_port = 0;
if (config_setting_lookup_string(overlay_v6, "local_addr", &local_addr_str)) {
- ip_address_pton(local_addr_str, &local_addr);
+ if (ip_address_pton(local_addr_str, &local_addr) < 0) {
+ ERROR("Error parsing v6 local addr");
+ goto ERR;
+ }
local_addr_p = &local_addr;
}
@@ -264,7 +275,10 @@ parse_config_global(facemgr_cfg_t * cfg, config_setting_t * setting)
}
if (config_setting_lookup_string(overlay_v6, "remote_addr", &remote_addr_str)) {
- ip_address_pton(remote_addr_str, &remote_addr);
+ if (ip_address_pton(remote_addr_str, &remote_addr) < 0) {
+ ERROR("Error parsing v6 remote addr");
+ goto ERR;
+ }
remote_addr_p = &remote_addr;
}
@@ -462,14 +476,18 @@ parse_config_rules(facemgr_cfg_t * cfg, config_setting_t * setting)
config_setting_t *overlay_v4 = config_setting_get_member(overlay, "ipv4");
if (overlay_v4) {
const char * local_addr_str, * remote_addr_str;
- ip_address_t local_addr, remote_addr;
+ ip_address_t local_addr = IP_ADDRESS_EMPTY;
+ ip_address_t remote_addr = IP_ADDRESS_EMPTY;
ip_address_t * local_addr_p = NULL;
ip_address_t * remote_addr_p = NULL;
int local_port = 0;
int remote_port = 0;
if (config_setting_lookup_string(overlay_v4, "local_addr", &local_addr_str)) {
- ip_address_pton(local_addr_str, &local_addr);
+ if (ip_address_pton(local_addr_str, &local_addr) < 0) {
+ ERROR("Error parsing v4 local addr");
+ goto ERR;
+ }
local_addr_p = &local_addr;
}
@@ -479,7 +497,10 @@ parse_config_rules(facemgr_cfg_t * cfg, config_setting_t * setting)
}
if (config_setting_lookup_string(overlay_v4, "remote_addr", &remote_addr_str)) {
- ip_address_pton(remote_addr_str, &remote_addr);
+ if (ip_address_pton(remote_addr_str, &remote_addr) < 0) {
+ ERROR("Error parsing v4 remote addr");
+ goto ERR;
+ }
remote_addr_p = &remote_addr;
}
@@ -498,14 +519,18 @@ parse_config_rules(facemgr_cfg_t * cfg, config_setting_t * setting)
config_setting_t *overlay_v6 = config_setting_get_member(overlay, "ipv6");
if (overlay_v6) {
const char * local_addr_str, * remote_addr_str;
- ip_address_t local_addr, remote_addr;
+ ip_address_t local_addr = IP_ADDRESS_EMPTY;
+ ip_address_t remote_addr = IP_ADDRESS_EMPTY;
ip_address_t * local_addr_p = NULL;
ip_address_t * remote_addr_p = NULL;
int local_port = 0;
int remote_port = 0;
if (config_setting_lookup_string(overlay_v6, "local_addr", &local_addr_str)) {
- ip_address_pton(local_addr_str, &local_addr);
+ if (ip_address_pton(local_addr_str, &local_addr) < 0) {
+ ERROR("Error parsing v6 local addr");
+ goto ERR;
+ }
local_addr_p = &local_addr;
}
@@ -515,7 +540,10 @@ parse_config_rules(facemgr_cfg_t * cfg, config_setting_t * setting)
}
if (config_setting_lookup_string(overlay_v6, "remote_addr", &remote_addr_str)) {
- ip_address_pton(remote_addr_str, &remote_addr);
+ if (ip_address_pton(remote_addr_str, &remote_addr) < 0) {
+ ERROR("Error parsing v6 remote addr");
+ goto ERR;
+ }
remote_addr_p = &remote_addr;
}