aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/facemgr/src/api.c
diff options
context:
space:
mode:
authorLuca Muscariello <muscariello@ieee.org>2022-08-04 16:06:34 +0200
committerLuca Muscariello <muscariello@ieee.org>2022-08-04 16:31:51 +0200
commit6d22a0db96aa7f8e3102ae44d00c09e36a2e9c57 (patch)
tree79546bbf09f6fbf74db7bc89117843f06ce937ea /ctrl/facemgr/src/api.c
parent012843b1c0bc0838e69085ed83a79ec8b6f97360 (diff)
feat: Due to the deep modifications related to names and packet format,
this task cover a large part of the codebase and involves several changes: - the library provides a name data structure (hicn_name_t ), which is composed of a name prefix (hicn_name_prefix_t) and a name suffix (hicn_name_suffix_t), and it has been extended to provide all support functions required for name manipulation, including common prefix computation, as required for the Longest Prefix Match (LPM)in the forwarder, in addition to Exact Prefix Match (EPM). - all code has been rewritten to use this data structure instead of having for instance the forwarder define its own name class (used to be Name and NameBitVector) the code has been refactored to minimize name allocations and copies, one remaining aspect is the difference of name storage between PIT and CS entries (respectively in the PIT entry, and in the message buffer), which causes the packet cache index to be updated when a PIT entry is converted into a CS entry. By storing the name in the PIT/CS entry everytime, we might save on this operation). - hicn-light FIB has been rewritten : code has been refactored and should now be shorter and documented; unit tests have been drafted but more would be required to cover all cases and match the algorithms to add/remove nodes, as specified in the doc. all protocol details and hICN header formats are now abstracted by the library for the forwarder (and thus header.h and  protocols/*.h have been removed from public includes, and replaced by packet.h providing protocol agnostic packet level functions, completely replacing the compat.h header that used to provide similar functions. - this works by exposing a opaque buffer to the application (a kind of socket buffer) which is used by the lib to cache the packet format and offsets of the different layers in the buffer and provider efficient operations (the packet format is either defined for packet construction, or guessed at ingress, and this structure is updated accordingly only once). Co-authored-by: Jordan Augé <jordan.auge+fdio@cisco.com> Signed-off-by: Luca Muscariello <muscariello@ieee.org> Change-Id: I31e321897f85f0267fe8ba4720363c180564492f
Diffstat (limited to 'ctrl/facemgr/src/api.c')
-rw-r--r--ctrl/facemgr/src/api.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/ctrl/facemgr/src/api.c b/ctrl/facemgr/src/api.c
index d030abd1f..f271b24c7 100644
--- a/ctrl/facemgr/src/api.c
+++ b/ctrl/facemgr/src/api.c
@@ -28,7 +28,7 @@
/*
* Dump facelets (debug)
*/
-//#define WITH_DUMP
+#define WITH_DUMP 1
/*
* Allow priority setting before interface is actually created
@@ -291,7 +291,10 @@ int facemgr_finalize(facemgr_t *facemgr) {
facelet_set_free(facemgr->facelet_cache);
/* Free all facelets from static array */
- for (unsigned i = 0; i < facelet_array_len(facemgr->static_facelets); i++) {
+ n = (int)facelet_array_len(facemgr->static_facelets);
+
+ INFO("Removing %d facelets from static array", n);
+ for (unsigned i = 0; i < n; i++) {
facelet_t *facelet;
if (facelet_array_get_index(facemgr->static_facelets, i, &facelet) < 0) {
ERROR("[facemgr_cfg_finalize] Error getting facelet in array");
@@ -817,7 +820,7 @@ int facemgr_complement_facelet_manual(facemgr_t *facemgr, facelet_t *facelet) {
* We never override a result we have obtained through bonjour
*/
if (!facelet_has_remote_addr(facelet)) {
- ip_address_t remote_addr;
+ hicn_ip_address_t remote_addr;
if (facemgr_cfg_get_overlay_remote_addr(facemgr->cfg, &netdevice,
netdevice_type, family,
&remote_addr) < 0) {
@@ -826,7 +829,7 @@ int facemgr_complement_facelet_manual(facemgr_t *facemgr, facelet_t *facelet) {
"information from cfg");
return -1;
}
- if (ip_address_empty(&remote_addr)) {
+ if (hicn_ip_address_empty(&remote_addr)) {
ERROR(
"[facemgr_complement_facelet_manual] Got empty remote addr "
"information from cfg");
@@ -859,7 +862,7 @@ int facemgr_complement_facelet_manual(facemgr_t *facemgr, facelet_t *facelet) {
* whether this is an address that belong to us... it might be used
* to arbitrate amongst several IP addresses instead...
*/
- ip_address_t local_addr;
+ hicn_ip_address_t local_addr;
if (facemgr_cfg_get_overlay_local_addr(
facemgr->cfg, &netdevice, netdevice_type, family, &local_addr) < 0) {
ERROR(
@@ -867,7 +870,7 @@ int facemgr_complement_facelet_manual(facemgr_t *facemgr, facelet_t *facelet) {
"information from cfg");
return -1;
}
- if (ip_address_empty(&local_addr)) {
+ if (hicn_ip_address_empty(&local_addr)) {
ERROR(
"[facemgr_complement_facelet_manual] Got empty local addr information "
"from cfg");
@@ -1435,7 +1438,7 @@ int facemgr_process_facelet_get(facemgr_t *facemgr, facelet_t *facelet) {
if (facelet_get_netdevice_type(facelet, &netdevice_type) < 0) {
/* Inspect local address */
int family;
- ip_address_t local;
+ hicn_ip_address_t local;
if (facelet_get_family(facelet, &family) < 0) {
ERROR("[facemgr_process_facelet_get] Error getting facelet family");
return -1;
@@ -1448,14 +1451,14 @@ int facemgr_process_facelet_get(facemgr_t *facemgr, facelet_t *facelet) {
}
switch (family) {
case AF_INET:
- if (ip_address_cmp(&local, &IPV4_LOOPBACK, family) == 0) {
+ if (hicn_ip_address_cmp(&local, &IPV4_LOOPBACK) == 0) {
facelet_set_netdevice_type(facelet, NETDEVICE_TYPE_LOOPBACK);
} else {
return -2;
}
break;
case AF_INET6:
- if (ip_address_cmp(&local, &IPV6_LOOPBACK, family) == 0) {
+ if (hicn_ip_address_cmp(&local, &IPV6_LOOPBACK) == 0) {
facelet_set_netdevice_type(facelet, NETDEVICE_TYPE_LOOPBACK);
} else {
return -2;
@@ -1673,7 +1676,8 @@ ERR_PRIORITY:
* routes managed by the face manager.
*/
DEBUG("[facemgr_process_facelet_create_no_family] Loop static");
- for (unsigned i = 0; i < facelet_array_len(facemgr->static_facelets); i++) {
+ int n = (int)facelet_array_len(facemgr->static_facelets);
+ for (unsigned i = 0; i < n; i++) {
facelet_t *static_facelet;
if (facelet_array_get_index(facemgr->static_facelets, i, &static_facelet) <
0) {
@@ -1733,7 +1737,7 @@ ERR_PRIORITY:
*/
int facemgr_on_event(facemgr_t *facemgr, facelet_t *facelet_in) {
bool remove_facelet = true;
-#if WITH_DUMP
+#ifdef WITH_DUMP
bool dump = true;
#endif /* WITH_DUMP */
int ret = 0;
@@ -1826,7 +1830,7 @@ int facemgr_on_event(facemgr_t *facemgr, facelet_t *facelet_in) {
// DEBUG("[facemgr_on_event] GET NEW %s", facelet_s);
rc = facemgr_process_facelet_get(facemgr, facelet_in);
if (rc == 0) remove_facelet = false;
-#if WITH_DUMP
+#ifdef WITH_DUMP
dump = false;
#endif
if (rc == -1) {
@@ -1943,7 +1947,7 @@ int facemgr_on_event(facemgr_t *facemgr, facelet_t *facelet_in) {
// ERROR("[facemgr_on_event] GET event for a face that already
// exists...");
#ifdef WITH_DUMP
- dump = false;
+ // dump = false;
#endif /* WITH_DUMP */
continue;
@@ -2025,7 +2029,7 @@ ERR:
ret = -1;
DUMP_CACHE:
-#if WITH_DUMP
+#ifdef WITH_DUMP
if (dump) {
DEBUG(" <CACHE>");
facelet_set_dump(facemgr->facelet_cache);