aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/core/vpp_forwarder_interface.cc
diff options
context:
space:
mode:
authorEnrico Loparco (eloparco) <eloparco@cisco.com>2021-06-24 09:15:41 +0200
committerEnrico Loparco (eloparco) <eloparco@cisco.com>2021-06-24 09:15:41 +0200
commit229385955109b866a23c4ac2aa03d4d11044c39d (patch)
tree0591f9c2fc4144d62330337cc2b94c63dfeded54 /libtransport/src/core/vpp_forwarder_interface.cc
parent6ffbb5ed61733b8dbef39b1a9d437e899e9359d7 (diff)
[HICN-708] Rebase with master
Signed-off-by: Enrico Loparco (eloparco) <eloparco@cisco.com> Change-Id: I2122e1d61dd3b2e039972624ffbdbcb3c5610159
Diffstat (limited to 'libtransport/src/core/vpp_forwarder_interface.cc')
-rw-r--r--libtransport/src/core/vpp_forwarder_interface.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/libtransport/src/core/vpp_forwarder_interface.cc b/libtransport/src/core/vpp_forwarder_interface.cc
index 7b4298592..9f7beeb37 100644
--- a/libtransport/src/core/vpp_forwarder_interface.cc
+++ b/libtransport/src/core/vpp_forwarder_interface.cc
@@ -36,8 +36,6 @@ namespace transport {
namespace core {
-std::mutex VPPForwarderInterface::global_lock_;
-
VPPForwarderInterface::VPPForwarderInterface(MemifConnector &connector)
: ForwarderInterface<VPPForwarderInterface, MemifConnector>(connector),
sw_if_index_(~0),
@@ -112,9 +110,24 @@ void VPPForwarderInterface::producerConnection() {
}
void VPPForwarderInterface::connect(bool is_consumer) {
- std::lock_guard<std::mutex> connection_lock(global_lock_);
+ int retry = 20;
+
+ TRANSPORT_LOGI("Connecting to VPP through vapi.");
+ vapi_error_e ret = vapi_connect_safe(&sock_, 0);
+
+ while (ret != VAPI_OK && retry > 0) {
+ TRANSPORT_LOGE("Error connecting to VPP through vapi. Retrying..");
+ --retry;
+ ret = vapi_connect_safe(&sock_, 0);
+ }
+
+ if (ret != VAPI_OK) {
+ throw std::runtime_error(
+ "Impossible to connect to forwarder. Is VPP running?");
+ }
+
- vapi_connect_safe(&sock_, 0);
+ TRANSPORT_LOGI("Connected to VPP through vapi.");
sw_if_index_ = getMemifConfiguration();
@@ -167,7 +180,7 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) {
params.prefix->address = addr.address;
params.prefix->family = addr.family;
params.prefix->len = addr.len;
- params.face_id = face_id1_;
+ params.prod_addr = &producer_locator;
int ret = hicn_vapi_register_route(VPPForwarderInterface::sock_, &params);