aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2020-01-27 16:04:33 +0100
committerAlberto Compagno <acompagn+fdio@cisco.com>2020-01-27 16:56:28 +0100
commitb0768b35fb515b7c0a15c3c7d8c1227497c59786 (patch)
tree1e2b1318f680fffd555ddc26a48e4a4156b06dfc /libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
parentbe54ac541c9700eaa9085bc8b4ee21b7a5f7e30a (diff)
[HICN-488] Adding lock to vapi calls and manage vapi_connect in order to connect only once.
- Added library to hicn-plugin called safe_vapi that takes care of handling concurrent calls to the vapi. - Removed dependency of libhicnctrl from libtransport and added dependency to safe_vapi. - Added dependency to safe_vapi on libhicnctrl Change-Id: Ie49e8319f64a50e7ed6a56e041db977c3b184cc5 Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc')
-rw-r--r--libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc23
1 files changed, 11 insertions, 12 deletions
diff --git a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
index 976d25a2f..06672279e 100644
--- a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
+++ b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
@@ -45,7 +45,6 @@ VPPForwarderInterface::VPPForwarderInterface(MemifConnector &connector)
face_id1_(~0),
face_id2_(~0),
is_consumer_(false){
- sock_ = hc_sock_create();
}
VPPForwarderInterface::~VPPForwarderInterface() {}
@@ -57,7 +56,7 @@ uint32_t VPPForwarderInterface::getMemifConfiguration() {
memif_create_params_t input_params = {0};
int ret = memif_vapi_get_next_memif_id(
- *(vapi_ctx_t *)VPPForwarderInterface::sock_, &memif_id_);
+ *VPPForwarderInterface::sock_, &memif_id_);
if (ret < 0) {
throw errors::RuntimeException(
@@ -74,7 +73,7 @@ uint32_t VPPForwarderInterface::getMemifConfiguration() {
memif_output_params_t output_params = {0};
- ret = memif_vapi_create_memif(*(vapi_ctx_t *)VPPForwarderInterface::sock_,
+ ret = memif_vapi_create_memif(*VPPForwarderInterface::sock_,
&input_params, &output_params);
if (ret < 0) {
@@ -97,7 +96,7 @@ void VPPForwarderInterface::consumerConnection() {
- int ret = hicn_vapi_register_cons_app(*(vapi_ctx_t *)VPPForwarderInterface::sock_,
+ int ret = hicn_vapi_register_cons_app(*VPPForwarderInterface::sock_,
&input, &output);
if (ret < 0) {
@@ -120,7 +119,7 @@ void VPPForwarderInterface::producerConnection() {
void VPPForwarderInterface::connect(bool is_consumer) {
std::lock_guard<std::mutex> connection_lock(global_lock_);
- hc_sock_connect(sock_);
+ vapi_connect_safe(sock_, 0);
sw_if_index_ = getMemifConfiguration();
@@ -158,7 +157,7 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) {
input.cs_reserved = content_store_reserved_;
int ret = hicn_vapi_register_prod_app(
- *(vapi_ctx_t *)VPPForwarderInterface::sock_, &input, &output);
+ *VPPForwarderInterface::sock_, &input, &output);
if (ret < 0) {
throw errors::RuntimeException(hicn_vapi_get_error_string(ret));
@@ -175,7 +174,7 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) {
params.prefix->len = addr.len;
params.face_id = face_id1_;
- int ret = hicn_vapi_register_route(*(vapi_ctx_t *)VPPForwarderInterface::sock_,
+ int ret = hicn_vapi_register_route(*VPPForwarderInterface::sock_,
&params);
if (ret < 0) {
@@ -191,25 +190,25 @@ void VPPForwarderInterface::closeConnection() {
if (is_consumer_) {
hicn_del_face_app_input_params params;
params.face_id = face_id1_;
- hicn_vapi_face_cons_del(*(vapi_ctx_t *)VPPForwarderInterface::sock_, &params);
+ hicn_vapi_face_cons_del(*VPPForwarderInterface::sock_, &params);
params.face_id = face_id2_;
- hicn_vapi_face_cons_del(*(vapi_ctx_t *)VPPForwarderInterface::sock_, &params);
+ hicn_vapi_face_cons_del(*VPPForwarderInterface::sock_, &params);
}
else {
hicn_del_face_app_input_params params;
params.face_id = face_id1_;
- hicn_vapi_face_prod_del(*(vapi_ctx_t *)VPPForwarderInterface::sock_, &params);
+ hicn_vapi_face_prod_del(*VPPForwarderInterface::sock_, &params);
}
if (sw_if_index_ != uint32_t(~0)) {
- int ret = memif_vapi_delete_memif(*(vapi_ctx_t *)VPPForwarderInterface::sock_,
+ int ret = memif_vapi_delete_memif(*VPPForwarderInterface::sock_,
sw_if_index_);
if (ret < 0) {
TRANSPORT_LOGE("Error deleting memif with sw idx %u.", sw_if_index_);
}
}
- hc_sock_free(sock_);
+ vapi_disconnect_safe();
VPPForwarderInterface::sock_ = nullptr;
}
}