aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2019-02-22 12:20:19 +0100
committerMauro Sardara <msardara@cisco.com>2019-02-22 13:13:40 +0100
commit5c774765616b219ddb293ebf37ba79a806523f11 (patch)
tree8b228bf37f947f559f969721225e63e2caa6f73c
parent1e2e32c281ddb053d03efd74eea660dfb0b6316f (diff)
[HICN-80] Avoid segfault when deleting memif interface on VPP.
Change-Id: Ie36cfc0ade82b38815d61a7ead2c72fc640236ed Signed-off-by: Mauro Sardara <msardara@cisco.com>
-rw-r--r--libtransport/src/hicn/transport/core/memif_connector.cc3
-rw-r--r--libtransport/src/hicn/transport/core/name.cc2
-rw-r--r--libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc19
-rw-r--r--libtransport/src/hicn/transport/utils/epoll_event_reactor.h3
-rw-r--r--utils/src/hiperf.cc2
5 files changed, 14 insertions, 15 deletions
diff --git a/libtransport/src/hicn/transport/core/memif_connector.cc b/libtransport/src/hicn/transport/core/memif_connector.cc
index c69a87fb7..af737412d 100644
--- a/libtransport/src/hicn/transport/core/memif_connector.cc
+++ b/libtransport/src/hicn/transport/core/memif_connector.cc
@@ -136,8 +136,7 @@ int MemifConnector::createMemif(uint32_t index, uint8_t mode, char *s) {
args.buffer_size = MEMIF_BUF_SIZE;
args.num_s2m_rings = 1;
args.num_m2s_rings = 1;
- strncpy((char *)args.interface_name, IF_NAME, strlen(IF_NAME));
- // strncpy((char *) args.instance_name, APP_NAME, strlen(APP_NAME));
+ strncpy((char *)args.interface_name, IF_NAME, strlen(IF_NAME) + 1);
args.mode = memif_interface_mode_t::MEMIF_INTERFACE_MODE_IP;
args.socket_filename = (uint8_t *)socket_filename_.c_str();
diff --git a/libtransport/src/hicn/transport/core/name.cc b/libtransport/src/hicn/transport/core/name.cc
index ba3e9e825..867d3a755 100644
--- a/libtransport/src/hicn/transport/core/name.cc
+++ b/libtransport/src/hicn/transport/core/name.cc
@@ -67,7 +67,7 @@ Name::Name(const std::string &uri) {
try {
seq_number = tokenizer.nextToken();
- } catch (errors::TokenizerException) {
+ } catch (errors::TokenizerException &) {
seq_number = "0";
}
diff --git a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
index 8dc607295..0d622f9a3 100644
--- a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
+++ b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc
@@ -208,20 +208,21 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) {
}
void VPPForwarderInterface::closeConnection() {
- if (sw_if_index_ != uint32_t(~0) && VPPForwarderInterface::memif_api_) {
- int ret = memif_binary_api_delete_memif(VPPForwarderInterface::memif_api_,
- sw_if_index_);
+ if (VPPForwarderInterface::api_) {
+ if (sw_if_index_ != uint32_t(~0)) {
+ int ret = memif_binary_api_delete_memif(VPPForwarderInterface::memif_api_,
+ sw_if_index_);
- if (ret < 0) {
- TRANSPORT_LOGE("Error deleting memif with sw idx %u.", sw_if_index_);
+ if (ret < 0) {
+ TRANSPORT_LOGE("Error deleting memif with sw idx %u.", sw_if_index_);
+ }
}
- }
- if (VPPForwarderInterface::api_) {
vpp_binary_api_destroy(VPPForwarderInterface::api_);
- }
+ connector_.close();
- connector_.close();
+ VPPForwarderInterface::api_ = nullptr;
+ }
}
} // namespace core
diff --git a/libtransport/src/hicn/transport/utils/epoll_event_reactor.h b/libtransport/src/hicn/transport/utils/epoll_event_reactor.h
index bb4db3ee7..dbb87c6c5 100644
--- a/libtransport/src/hicn/transport/utils/epoll_event_reactor.h
+++ b/libtransport/src/hicn/transport/utils/epoll_event_reactor.h
@@ -18,6 +18,7 @@
#include <hicn/transport/utils/event_reactor.h>
#include <sys/epoll.h>
+#include <atomic>
#include <cstddef>
#include <functional>
#include <mutex>
@@ -57,7 +58,7 @@ class EpollEventReactor : public EventReactor {
int addFileDescriptor(int fd, uint32_t events);
int epoll_fd_;
- volatile bool run_event_loop_;
+ std::atomic_bool run_event_loop_;
EventCallbackMap event_callback_map_;
std::mutex event_callback_map_mutex_;
};
diff --git a/utils/src/hiperf.cc b/utils/src/hiperf.cc
index bbef2d27e..f2387b57c 100644
--- a/utils/src/hiperf.cc
+++ b/utils/src/hiperf.cc
@@ -754,8 +754,6 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
- std::cout << "Bye bye" << std::endl;
-
#ifdef _WIN32
WSACleanup();
#endif