Commit c7267d26 authored by Raphael Defosseux's avatar Raphael Defosseux

feat(pfcp): removing dependency to folly

 Drowbacks of std::map --> no lock and no restriction on size
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@openairinterface.org>
parent 03ad3782
################################################################################
# Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The OpenAirInterface Software Alliance licenses this file to You under
# the OAI Public License, Version 1.1 (the "License"); you may not use this file
# except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.openairinterface.org/?page_id=698
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------
# For more information about the OpenAirInterface (OAI) Software Alliance:
# contact@openairinterface.org
################################################################################
# file build_helper.fb_folly
# brief
# author Lionel GAUTHIER
#
#######################################
SCRIPT=$(readlink -f ${BASH_SOURCE})
THIS_SCRIPT_PATH=`dirname $SCRIPT`
source $THIS_SCRIPT_PATH/build_helper
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_fb_folly_from_source(){
echo "Starting to install folly"
if [ $1 -eq 0 ]; then
OPTION=""
read -p "Do you want to install FaceBook folly (github)? <y/N> " prompt
else
prompt='y'
OPTION="-y"
fi
if [ $2 -eq 0 ]; then
debug=0
else
debug=1
fi
if [[ $prompt =~ [yY](es)* ]]
then
if [[ "$OS_BASEDISTRO" == "fedora" ]]; then
$SUDO $INSTALLER install $OPTION \
gcc-c++ \
$CMAKE \
make \
boost-devel \
libevent-devel \
double-conversion-devel \
glog-devel \
gflags-devel \
snappy-devel \
lz4-devel \
zlib-devel \
binutils-devel \
jemalloc-devel \
openssl-devel
ret=$?;[[ $ret -ne 0 ]] && return $ret
elif [[ $OS_DISTRO == "ubuntu" ]]; then
$SUDO $INSTALLER install $OPTION \
$CMAKE \
g++ \
libevent-dev \
libdouble-conversion-dev \
libgoogle-glog-dev \
libgflags-dev \
libiberty-dev \
liblz4-dev \
liblzma-dev \
libsnappy-dev \
wget \
zlib1g-dev \
binutils-dev \
libjemalloc-dev
ret=$?;[[ $ret -ne 0 ]] && return $ret
fi
pushd /tmp
if [ $debug -eq 1 ]; then
# For advanced debugging options
$SUDO $INSTALLER install $OPTION \
libunwind8-dev \
libelf-dev \
libdwarf-dev
ret=$?;[[ $ret -ne 0 ]] && return $ret
wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz && \
tar zxf release-1.8.0.tar.gz && \
rm -f release-1.8.0.tar.gz && \
cd googletest-release-1.8.0 && \
$CMAKE . -DBUILD_GMOCK=OFF && \
make && \
$SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
cd ..
fi
$SUDO rm -rf /tmp/folly
git clone https://github.com/facebook/folly.git
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
cd folly
if [[ "$OS_BASEDISTRO" == "fedora" ]]; then
git checkout -f v2019.06.17.00
echo 'diff --git a/build/fbcode_builder/CMake/FindGflags.cmake b/build/fbcode_builder/CMake/FindGflags.cmake' > patch.diff
echo 'index 246ceac..3b96716 100644' >> patch.diff
echo '--- a/build/fbcode_builder/CMake/FindGflags.cmake' >> patch.diff
echo '+++ b/build/fbcode_builder/CMake/FindGflags.cmake' >> patch.diff
echo '@@ -34,6 +34,9 @@ IF (LIBGFLAGS_INCLUDE_DIR)' >> patch.diff
echo ' ENDIF ()' >> patch.diff
echo '' >> patch.diff
echo ' find_package(gflags CONFIG QUIET)' >> patch.diff
echo '+get_filename_component (_LIB_PATH "${gflags_CONFIG}/../../../" ABSOLUTE)' >> patch.diff
echo '+unset(gflags_LIBRARIES)' >> patch.diff
echo '+find_library(gflags_LIBRARIES gflags PATHS ${_LIB_PATH})' >> patch.diff
echo ' if (gflags_FOUND)' >> patch.diff
echo ' if (NOT Gflags_FIND_QUIETLY)' >> patch.diff
echo ' message(STATUS "Found gflags from package config ${gflags_CONFIG}")' >> patch.diff
git apply patch.diff
else
git checkout -f v2019.11.11.00
fi
mkdir _build && cd _build
if [[ "$OS_BASEDISTRO" == "fedora" ]]; then
cmake3 ..
else
cmake ..
fi
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
make -j $(nproc)
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd
fi
echo_success "folly installation complete"
return 0
}
......@@ -31,7 +31,6 @@ SCRIPT=$(readlink -f ${BASH_SOURCE})
THIS_SCRIPT_PATH=`dirname $SCRIPT`
source $THIS_SCRIPT_PATH/build_helper
source $THIS_SCRIPT_PATH/build_helper.libconfig
source $THIS_SCRIPT_PATH/build_helper.fb_folly
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
......@@ -453,9 +452,6 @@ check_install_smf_deps() {
install_spdlog_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
install_fb_folly_from_source $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
install_pistache_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
......
......@@ -58,10 +58,11 @@ RUN apt-get update && \
perl \
openssl \
libasan4 \
librtmp1 \
libpsl5 \
libcurl?-gnutls \
libgssapi-krb5-2 \
libldap-2.4-2 \
libgoogle-glog0v5 \
libdouble-conversion1 \
libconfig++9v5 \
&& rm -rf /var/lib/apt/lists/*
......@@ -80,9 +81,6 @@ COPY --from=oai-smf-builder \
/usr/lib/libboost_system.so.1.67.0 \
/usr/lib/libboost_thread.so.1.67.0 \
/usr/lib/libboost_chrono.so.1.67.0 \
/usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 \
/usr/lib/x86_64-linux-gnu/librtmp.so.1 \
/usr/lib/x86_64-linux-gnu/libpsl.so.5 \
/openair-smf/build/smf/build/nas/libNAS.so \
./
RUN ldconfig && \
......
......@@ -481,8 +481,6 @@ class HtmlReport():
section_end_pattern = 'build_smf --clean --Verbose --build-type Release --jobs'
section_status = False
package_install = False
folly_build_start = False
folly_build_status = False
spdlog_build_start = False
spdlog_build_status = False
pistache_build_start = False
......@@ -510,12 +508,6 @@ class HtmlReport():
result = re.search('distro libs installation complete', line)
if result is not None:
package_install = True
result = re.search('Starting to install folly', line)
if result is not None:
folly_build_start = True
result = re.search('folly installation complete', line)
if result is not None and folly_build_start:
folly_build_status = True
result = re.search('Starting to install spdlog', line)
if result is not None:
spdlog_build_start = True
......@@ -563,12 +555,6 @@ class HtmlReport():
cell_msg += ' ** spdlog Installation: OK\n'
else:
cell_msg += ' ** spdlog Installation: KO\n'
if base_image:
cell_msg += ' ** folly Installation: N/A\n'
elif folly_build_status:
cell_msg += ' ** folly Installation: OK\n'
else:
cell_msg += ' ** folly Installation: KO\n'
if base_image:
cell_msg += ' ** pistache Installation: N/A\n'
elif pistache_build_status:
......
......@@ -94,9 +94,6 @@ COPY --from=oai-smf-builder \
COPY --from=oai-smf-builder \
/usr/local/lib64/libpistache.so.0 \
/usr/local/lib/libnghttp2_asio.so \
/usr/lib64/libgflags.so.2.1 \
/usr/lib64/libglog.so.0 \
/usr/lib64/libdouble-conversion.so.1 \
/usr/lib64/libconfig++.so.9 \
/usr/lib64/libboost_system.so.1.66.0 \
/usr/lib64/libboost_thread.so.1.66.0 \
......
......@@ -78,10 +78,11 @@ RUN apt-get update && \
perl \
openssl \
libasan4 \
librtmp1 \
libpsl5 \
libcurl?-gnutls \
libgssapi-krb5-2 \
libldap-2.4-2 \
libgoogle-glog0v5 \
libdouble-conversion1 \
libconfig++9v5 \
&& rm -rf /var/lib/apt/lists/*
......@@ -100,9 +101,6 @@ COPY --from=oai-smf-builder \
/usr/lib/libboost_system.so.1.67.0 \
/usr/lib/libboost_thread.so.1.67.0 \
/usr/lib/libboost_chrono.so.1.67.0 \
/usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 \
/usr/lib/x86_64-linux-gnu/librtmp.so.1 \
/usr/lib/x86_64-linux-gnu/libpsl.so.5 \
/openair-smf/build/smf/build/nas/libNAS.so \
./
RUN ldconfig && \
......
......@@ -320,5 +320,4 @@ IF(STATIC_LINKING)
ENDIF(STATIC_LINKING)
target_link_libraries (smf ${ASAN}
-Wl,--start-group CN_UTILS SMF UDP PFCP 3GPP_COMMON_TYPES SMF_API -lnettle ${NETTLE_LIBRARIES} ${CRYPTO_LIBRARIES} -lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system boost_chrono pistache curl)
\ No newline at end of file
-Wl,--start-group CN_UTILS SMF UDP PFCP 3GPP_COMMON_TYPES SMF_API -lnettle ${NETTLE_LIBRARIES} ${CRYPTO_LIBRARIES} -lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS dl -Wl,--end-group pthread m rt config++ event boost_system boost_chrono pistache curl)
......@@ -140,8 +140,12 @@ bool pfcp_associations::add_association(
break;
}
}
associations.insert((int32_t) hash_node_id, sa);
trigger_heartbeat_request_procedure(sa);
if (associations.size() < PFCP_MAX_ASSOCIATIONS) {
associations.insert({(int32_t) hash_node_id, sa});
trigger_heartbeat_request_procedure(sa);
} else {
Logger::smf_app().info("What do we do if too many associations?");
}
}
return true;
}
......@@ -210,10 +214,14 @@ bool pfcp_associations::add_association(
break;
}
}
associations.insert((int32_t) hash_node_id, sa);
// Display UPF Node profile
sa->get_upf_node_profile().display();
trigger_heartbeat_request_procedure(sa);
if (associations.size() < PFCP_MAX_ASSOCIATIONS) {
associations.insert({(int32_t) hash_node_id, sa});
// Display UPF Node profile
sa->get_upf_node_profile().display();
trigger_heartbeat_request_procedure(sa);
} else {
Logger::smf_app().info("What do we do if too many associations?");
}
}
return true;
}
......@@ -244,8 +252,12 @@ bool pfcp_associations::add_association(
sa->function_features.first = true;
sa->function_features.second = function_features;
std::size_t hash_node_id = std::hash<pfcp::node_id_t>{}(node_id);
associations.insert((int32_t) hash_node_id, sa);
trigger_heartbeat_request_procedure(sa);
if (associations.size() < PFCP_MAX_ASSOCIATIONS) {
associations.insert({(int32_t) hash_node_id, sa});
trigger_heartbeat_request_procedure(sa);
} else {
Logger::smf_app().info("What do we do if too many associations?");
}
}
return true;
}
......@@ -302,9 +314,7 @@ bool pfcp_associations::get_association(
bool pfcp_associations::get_association(
const pfcp::fseid_t& cp_fseid,
std::shared_ptr<pfcp_association>& sa) const {
folly::AtomicHashMap<int32_t, std::shared_ptr<pfcp_association>>::iterator it;
FOR_EACH(it, associations) {
for (auto it = associations.begin(); it != associations.end(); ++it) {
std::shared_ptr<pfcp_association> a = it->second;
if (it->second->has_session(cp_fseid)) {
sa = it->second;
......@@ -400,9 +410,7 @@ void pfcp_associations::timeout_release_request(
//------------------------------------------------------------------------------
void pfcp_associations::handle_receive_heartbeat_response(
const uint64_t trxn_id) {
folly::AtomicHashMap<int32_t, std::shared_ptr<pfcp_association>>::iterator it;
FOR_EACH(it, associations) {
for (auto it = associations.begin(); it != associations.end(); ++it) {
std::shared_ptr<pfcp_association> a = it->second;
if (it->second->trxn_id_heartbeat == trxn_id) {
itti_inst->timer_remove(it->second->timer_heartbeat);
......@@ -419,8 +427,7 @@ bool pfcp_associations::select_up_node(
if (associations.empty()) {
return false;
}
folly::AtomicHashMap<int32_t, std::shared_ptr<pfcp_association>>::iterator it;
FOR_EACH(it, associations) {
for (auto it = associations.begin(); it != associations.end(); ++it) {
std::shared_ptr<pfcp_association> a = it->second;
// TODO
switch (node_selection_criteria) {
......@@ -447,8 +454,7 @@ bool pfcp_associations::select_up_node(
Logger::smf_app().debug("No UPF available");
return false;
}
folly::AtomicHashMap<int32_t, std::shared_ptr<pfcp_association>>::iterator it;
FOR_EACH(it, associations) {
for (auto it = associations.begin(); it != associations.end(); ++it) {
std::shared_ptr<pfcp_association> a = it->second;
// get the first node id if there's no upf profile (get UPFs from conf file)
if (!a->upf_profile_is_set) {
......
......@@ -28,8 +28,7 @@
#ifndef FILE_SMF_PFCP_ASSOCIATION_HPP_SEEN
#define FILE_SMF_PFCP_ASSOCIATION_HPP_SEEN
#include <folly/AtomicHashMap.h>
#include <folly/AtomicLinkedList.h>
#include <map>
#include <mutex>
#include <vector>
......@@ -165,10 +164,9 @@ enum node_selection_criteria_e {
class pfcp_associations {
private:
std::vector<std::shared_ptr<pfcp_association>> pending_associations;
folly::AtomicHashMap<int32_t, std::shared_ptr<pfcp_association>> associations;
std::map<int32_t, std::shared_ptr<pfcp_association>> associations;
pfcp_associations()
: associations(PFCP_MAX_ASSOCIATIONS), pending_associations(){};
pfcp_associations(){};
void trigger_heartbeat_request_procedure(
std::shared_ptr<pfcp_association>& s);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment