From 6186945f88556619bdd9eec9f49e3c0fd3aedaf1 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Thu, 9 Feb 2023 16:02:33 +0000 Subject: feat(hicn-plugin): specify the dpo_proto when creating a new face Ticket: HICN-841 Change-Id: I4c5684db936835a0748715680cfbbc22ada642ff Signed-off-by: Mauro Sardara --- hicn-plugin/src/faces/face.c | 11 ++++++----- hicn-plugin/src/faces/face.h | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'hicn-plugin/src/faces') diff --git a/hicn-plugin/src/faces/face.c b/hicn-plugin/src/faces/face.c index 84fd5e6ee..ce3001ac7 100644 --- a/hicn-plugin/src/faces/face.c +++ b/hicn-plugin/src/faces/face.c @@ -266,10 +266,12 @@ hicn_face_del (hicn_face_id_t face_id) } static void -hicn_iface_to_face (hicn_face_t *face, const dpo_id_t *dpo) +hicn_iface_to_face (hicn_face_t *face, const dpo_id_t *dpo, + dpo_proto_t dpo_proto) { - dpo_stack (hicn_face_type, dpo->dpoi_proto, &face->dpo, dpo); + dpo_stack (hicn_face_type, dpo_proto, &face->dpo, dpo); + face->dpo.dpoi_proto = dpo_proto; face->flags &= ~HICN_FACE_FLAGS_IFACE; face->flags |= HICN_FACE_FLAGS_FACE; @@ -305,7 +307,7 @@ hicn_iface_to_face (hicn_face_t *face, const dpo_id_t *dpo) */ int hicn_face_add (const dpo_id_t *dpo_nh, ip46_address_t *nat_address, int sw_if, - hicn_face_id_t *pfaceid) + hicn_face_id_t *pfaceid, dpo_proto_t dpo_proto) { hicn_face_t *face; @@ -329,7 +331,6 @@ hicn_face_add (const dpo_id_t *dpo_nh, ip46_address_t *nat_address, int sw_if, if (face == NULL) { - hicn_iface_add (nat_address, sw_if, pfaceid, dpo_nh->dpoi_index, 0); face = hicn_dpoi_get_from_idx (*pfaceid); @@ -345,7 +346,7 @@ hicn_face_add (const dpo_id_t *dpo_nh, ip46_address_t *nat_address, int sw_if, mhash_set_mem (&hicn_face_hashtb, &key, (uword *) pfaceid, 0); } - hicn_iface_to_face (face, dpo_nh); + hicn_iface_to_face (face, dpo_nh, dpo_proto); temp_dpo.dpoi_index = ~0; diff --git a/hicn-plugin/src/faces/face.h b/hicn-plugin/src/faces/face.h index b23cb9b12..2c0a09a28 100644 --- a/hicn-plugin/src/faces/face.h +++ b/hicn-plugin/src/faces/face.h @@ -453,7 +453,7 @@ hicn_face_get_with_dpo (const ip46_address_t *addr, u32 sw_if, * reachable ip address, otherwise HICN_ERROR_NONE */ int hicn_face_add (const dpo_id_t *dpo_nh, ip46_address_t *nat_address, - int sw_if, hicn_face_id_t *pfaceid); + int sw_if, hicn_face_id_t *pfaceid, dpo_proto_t dpo_proto); /** * @brief Create a new incomplete face ip. (Meant to be used by the data plane) @@ -524,6 +524,7 @@ hicn_face_ip4_find (hicn_face_id_t *index, u8 *hicnb_flags, u32 node_index) { int ret = HICN_ERROR_FACE_NOT_FOUND; + hicn_face_id_t face_id; /*All (complete) faces are indexed by remote addess as well */ /* if the face exists, it adds a lock */ @@ -533,11 +534,13 @@ hicn_face_ip4_find (hicn_face_id_t *index, u8 *hicnb_flags, if (face != NULL) { /* unlock the face. We don't take a lock on each interest we receive */ - hicn_face_id_t face_id = hicn_dpoi_get_index (face); + face_id = hicn_dpoi_get_index (face); hicn_face_unlock_with_id (face_id); - ret = HICN_ERROR_FACE_ALREADY_CREATED; + *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; - *index = hicn_dpoi_get_index (face); + *index = face_id; + + ret = HICN_ERROR_FACE_ALREADY_CREATED; } return ret; @@ -621,6 +624,7 @@ hicn_face_ip6_find (hicn_face_id_t *index, u8 *hicnb_flags, u32 node_index) { int ret = HICN_ERROR_FACE_NOT_FOUND; + hicn_face_id_t face_id; hicn_face_t *face = hicn_face_get ((const ip46_address_t *) nat_addr, sw_if, &hicn_face_hashtb, adj_index); @@ -628,11 +632,12 @@ hicn_face_ip6_find (hicn_face_id_t *index, u8 *hicnb_flags, if (face != NULL) { /* unlock the face. We don't take a lock on each interest we receive */ - hicn_face_id_t face_id = hicn_dpoi_get_index (face); + face_id = hicn_dpoi_get_index (face); hicn_face_unlock_with_id (face_id); - ret = HICN_ERROR_FACE_ALREADY_CREATED; *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; - *index = hicn_dpoi_get_index (face); + *index = face_id; + + ret = HICN_ERROR_FACE_ALREADY_CREATED; } return ret; -- cgit 1.2.3-korg