summaryrefslogtreecommitdiffstats
path: root/libtransport/src
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2019-11-25 08:53:19 +0000
committerGerrit Code Review <gerrit@fd.io>2019-11-25 08:53:19 +0000
commit4bdc720d1a7d13f19eae6ba7e14b00cbfbd37ce0 (patch)
treee4ee6c80a9478b9e984747f4fa041a225afd557d /libtransport/src
parent93b0b7a95922defa19951dde01b1dce4047bb0e7 (diff)
parentcdcfbfcf608035797b5ceaf6f7fefa77ce5cb27a (diff)
Merge "[HICN-406] Adding face deletion on the hicn-plugin when the corresponding socket is destroyed"
Diffstat (limited to 'libtransport/src')
-rw-r--r--libtransport/src/hicn/transport/core/hicn_binary_api.c56
-rw-r--r--libtransport/src/hicn/transport/core/hicn_binary_api.h10
-rw-r--r--libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc31
-rw-r--r--libtransport/src/hicn/transport/core/vpp_forwarder_interface.h5
4 files changed, 95 insertions, 7 deletions
diff --git a/libtransport/src/hicn/transport/core/hicn_binary_api.c b/libtransport/src/hicn/transport/core/hicn_binary_api.c
index 7f63c9826..1f8dfd326 100644
--- a/libtransport/src/hicn/transport/core/hicn_binary_api.c
+++ b/libtransport/src/hicn/transport/core/hicn_binary_api.c
@@ -102,7 +102,9 @@ static context_store_t context_store = {
*/
#define foreach_hicn_api_reply_msg \
_(HICN_API_REGISTER_PROD_APP_REPLY, hicn_api_register_prod_app_reply) \
+ _(HICN_API_FACE_PROD_DEL_REPLY, hicn_api_face_prod_del_reply) \
_(HICN_API_REGISTER_CONS_APP_REPLY, hicn_api_register_cons_app_reply) \
+ _(HICN_API_FACE_CONS_DEL_REPLY, hicn_api_face_cons_del_reply) \
_(HICN_API_ROUTE_NHOPS_ADD_REPLY, hicn_api_route_nhops_add_reply)
int hicn_binary_api_register_prod_app(
@@ -145,6 +147,34 @@ static void vl_api_hicn_api_register_prod_app_reply_t_handler(
vpp_binary_api_unlock_waiting_thread(binary_api->vpp_api);
}
+int hicn_binary_api_face_prod_del(
+ vpp_plugin_binary_api_t *api, hicn_del_face_app_input_params *input_params) {
+ vl_api_hicn_api_face_prod_del_t *mp;
+ vpp_plugin_binary_api_t *hm = api;
+
+ //vpp_binary_api_set_user_param(hm->vpp_api, output_params);
+
+ /* Construct the API message */
+ M(HICN_API_FACE_PROD_DEL, mp);
+
+ mp->faceid = clib_host_to_net_u32(input_params->face_id);
+
+ CONTEXT_SAVE(context_store, api, mp)
+
+ return vpp_binary_api_send_request_wait_reply(api->vpp_api, mp);
+}
+
+static void vl_api_hicn_api_face_prod_del_reply_t_handler(
+ vl_api_hicn_api_face_prod_del_reply_t *mp) {
+ vpp_plugin_binary_api_t *binary_api;
+ CONTEXT_GET(context_store, mp, binary_api);
+
+ vpp_binary_api_set_ret_value(binary_api->vpp_api,
+ clib_net_to_host_u32(mp->retval));
+
+ vpp_binary_api_unlock_waiting_thread(binary_api->vpp_api);
+}
+
int hicn_binary_api_register_cons_app(
vpp_plugin_binary_api_t *api, hicn_consumer_input_params *input_params,
hicn_consumer_output_params *output_params) {
@@ -181,6 +211,32 @@ static void vl_api_hicn_api_register_cons_app_reply_t_handler(
vpp_binary_api_unlock_waiting_thread(binary_api->vpp_api);
}
+int hicn_binary_api_face_cons_del(
+ vpp_plugin_binary_api_t *api, hicn_del_face_app_input_params *input_params) {
+ vl_api_hicn_api_face_cons_del_t *mp;
+ vpp_plugin_binary_api_t *hm = api;
+
+ /* Construct the API message */
+ M(HICN_API_FACE_CONS_DEL, mp);
+
+ mp->faceid = clib_host_to_net_u32(input_params->face_id);
+
+ CONTEXT_SAVE(context_store, api, mp)
+
+ return vpp_binary_api_send_request_wait_reply(api->vpp_api, mp);
+}
+
+static void vl_api_hicn_api_face_cons_del_reply_t_handler(
+ vl_api_hicn_api_face_cons_del_reply_t *mp) {
+ vpp_plugin_binary_api_t *binary_api;
+ CONTEXT_GET(context_store, mp, binary_api);
+
+ vpp_binary_api_set_ret_value(binary_api->vpp_api,
+ clib_net_to_host_u32(mp->retval));
+
+ vpp_binary_api_unlock_waiting_thread(binary_api->vpp_api);
+}
+
int hicn_binary_api_register_route(
vpp_plugin_binary_api_t *api,
hicn_producer_set_route_params *input_params) {
diff --git a/libtransport/src/hicn/transport/core/hicn_binary_api.h b/libtransport/src/hicn/transport/core/hicn_binary_api.h
index 323d22fea..11543da19 100644
--- a/libtransport/src/hicn/transport/core/hicn_binary_api.h
+++ b/libtransport/src/hicn/transport/core/hicn_binary_api.h
@@ -39,6 +39,10 @@ typedef struct {
} hicn_consumer_input_params;
typedef struct {
+ uint32_t face_id;
+} hicn_del_face_app_input_params;
+
+typedef struct {
uint32_t cs_reserved;
ip_address_t* prod_addr;
uint32_t face_id;
@@ -69,6 +73,12 @@ int hicn_binary_api_register_cons_app(
int hicn_binary_api_register_route(
vpp_plugin_binary_api_t* api, hicn_producer_set_route_params* input_params);
+int hicn_binary_api_face_cons_del(
+ vpp_plugin_binary_api_t *api, hicn_del_face_app_input_params *input_params);
+
+int hicn_binary_api_face_prod_del(
+ vpp_plugin_binary_api_t *api, hicn_del_face_app_input_params *input_params);
+
char* hicn_binary_api_get_error_string(int ret_val);
#ifdef __cplusplus
diff --git a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
index 17239b8fb..45a37d551 100644
--- a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
+++ b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
@@ -45,7 +45,9 @@ std::mutex VPPForwarderInterface::global_lock_;
VPPForwarderInterface::VPPForwarderInterface(MemifConnector &connector)
: ForwarderInterface<VPPForwarderInterface, MemifConnector>(connector),
sw_if_index_(~0),
- face_id_(~0) {}
+ face_id1_(~0),
+ face_id2_(~0),
+ is_consumer_(false) {}
VPPForwarderInterface::~VPPForwarderInterface() {}
@@ -92,7 +94,6 @@ void VPPForwarderInterface::consumerConnection() {
output.src4 = &ip4_address;
output.src6 = &ip6_address;
-
input.swif = sw_if_index_;
int ret = hicn_binary_api_register_cons_app(VPPForwarderInterface::hicn_api_,
@@ -102,6 +103,10 @@ void VPPForwarderInterface::consumerConnection() {
throw errors::RuntimeException(hicn_binary_api_get_error_string(ret));
}
+ face_id1_ = output.face_id1;
+ face_id2_ = output.face_id2;
+
+
std::memcpy(inet_address_.v4.as_u8, output.src4->v4.as_u8, IPV4_ADDR_LEN);
std::memcpy(inet6_address_.v6.as_u8, output.src6->v6.as_u8, IPV6_ADDR_LEN);
@@ -129,7 +134,8 @@ void VPPForwarderInterface::connect(bool is_consumer) {
sw_if_index_ = getMemifConfiguration();
- if (is_consumer) {
+ is_consumer_ = is_consumer;
+ if (is_consumer_) {
consumerConnection();
}
@@ -142,7 +148,7 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) {
ip_prefix_t producer_prefix;
ip_address_t producer_locator;
- if (face_id_ == uint32_t(~0)) {
+ if (face_id1_ == uint32_t(~0)) {
hicn_producer_input_params input;
std::memset(&input, 0, sizeof(input));
@@ -170,14 +176,14 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) {
inet6_address_ = *output.prod_addr;
- face_id_ = output.face_id;
+ face_id1_ = output.face_id;
} else {
hicn_producer_set_route_params params;
params.prefix = &producer_prefix;
params.prefix->address = addr.address;
params.prefix->family = addr.family;
params.prefix->len = addr.len;
- params.face_id = face_id_;
+ params.face_id = face_id1_;
int ret = hicn_binary_api_register_route(VPPForwarderInterface::hicn_api_,
&params);
@@ -192,6 +198,19 @@ void VPPForwarderInterface::closeConnection() {
if (VPPForwarderInterface::api_) {
connector_.close();
+ if (is_consumer_) {
+ hicn_del_face_app_input_params params;
+ params.face_id = face_id1_;
+ hicn_binary_api_face_cons_del(VPPForwarderInterface::hicn_api_, &params);
+ params.face_id = face_id2_;
+ hicn_binary_api_face_cons_del(VPPForwarderInterface::hicn_api_, &params);
+ }
+ else {
+ hicn_del_face_app_input_params params;
+ params.face_id = face_id1_;
+ hicn_binary_api_face_prod_del(VPPForwarderInterface::hicn_api_, &params);
+ }
+
if (sw_if_index_ != uint32_t(~0)) {
int ret = memif_binary_api_delete_memif(VPPForwarderInterface::memif_api_,
sw_if_index_);
diff --git a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.h b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.h
index 62af8bc3b..b1cb4b9b3 100644
--- a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.h
+++ b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.h
@@ -68,7 +68,10 @@ class VPPForwarderInterface
static vpp_plugin_binary_api_t *hicn_api_;
uint32_t memif_id_;
uint32_t sw_if_index_;
- uint32_t face_id_;
+ //A consumer socket in vpp has two faces (ipv4 and ipv6)
+ uint32_t face_id1_;
+ uint32_t face_id2_;
+ bool is_consumer_;
static std::mutex global_lock_;
};