From 45bc09ae553e7ac5bf6cd7ab2e77e7f6d0877596 Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Tue, 12 Nov 2019 00:15:11 +0100 Subject: [HICN-395] Static face/route maintainance though face manager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8f2287a262412bacc50f3c89756ec9fd6ce30d33 Signed-off-by: Jordan Augé --- ctrl/facemgr/src/facelet.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'ctrl/facemgr/src/facelet.c') diff --git a/ctrl/facemgr/src/facelet.c b/ctrl/facemgr/src/facelet.c index 7a34b18c8..a7a1fd3ae 100644 --- a/ctrl/facemgr/src/facelet.c +++ b/ctrl/facemgr/src/facelet.c @@ -229,7 +229,8 @@ facelet_create_from_face(face_t * face) /* Attribute : netdevice */ /* NOTE index is not set */ if (IS_VALID_NETDEVICE(face->netdevice)) { - facelet->netdevice = face->netdevice; + /* /!\ A face has only the netdevice name */ + netdevice_set_name(&facelet->netdevice, face->netdevice.name); facelet->netdevice_status = FACELET_ATTR_STATUS_CLEAN; } else { facelet->netdevice_status = FACELET_ATTR_STATUS_UNSET; @@ -240,7 +241,7 @@ facelet_create_from_face(face_t * face) if (facelet->netdevice_type != NETDEVICE_TYPE_UNDEFINED) { facelet->netdevice_type_status = FACELET_ATTR_STATUS_CLEAN; } else { - facelet->netdevice = NETDEVICE_EMPTY; + facelet->netdevice_type = NETDEVICE_TYPE_UNDEFINED; facelet->netdevice_type_status = FACELET_ATTR_STATUS_UNSET; } @@ -407,13 +408,32 @@ facelet_dup(const facelet_t * current_facelet) } else { for (unsigned i = 0; i < n; i++) { hicn_route_t * route = route_array[i]; - route_set_add(facelet->routes, route); + hicn_route_t * new_route = hicn_route_dup(route); + if (!new_route) + goto ERR_ROUTE; + route_set_add(facelet->routes, new_route); } } free(route_array); return facelet; +ERR_ROUTE: + { + /* Free all routes */ + hicn_route_t ** new_route_array; + int n = route_set_get_array(facelet->routes, &new_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 * new_route = new_route_array[i]; + hicn_route_free(new_route); + } + } + free(route_array); + facelet_free(facelet); + } ERR_CREATE: return NULL; } @@ -489,7 +509,6 @@ do { } \ } while(0) -/* facelet_match is the incoming one */ bool facelet_equals(const facelet_t * facelet1, const facelet_t * facelet2) { -- cgit 1.2.3-korg