Commit 5d3fd80b authored by Raphael Defosseux's avatar Raphael Defosseux

Merge branch 'remove-folly-dependency' into 'develop'

feat(pfcp): removing dependency to folly

See merge request oai/cn5g/oai-cn5g-smf!145
parents cb93eb96 b5582880
################################################################################
# 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)
......@@ -352,7 +351,9 @@ check_install_smf_deps() {
autoconf \
automake \
bison \
gcc-c++ \
$CMAKE \
make \
doxygen \
flex \
gdb \
......@@ -408,6 +409,7 @@ check_install_smf_deps() {
libasan?"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\
boost-devel \
guile-devel \
libconfig-devel \
libgcrypt-devel \
......@@ -453,9 +455,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
......
......@@ -205,4 +205,4 @@ echo "Nb Files that do NOT follow OAI rules: $NB_TO_FORMAT over $NB_TOTAL checke
echo "NB_FILES_FAILING_CHECK=$NB_TO_FORMAT" > ./oai_rules_result.txt
echo "NB_FILES_CHECKED=$NB_TOTAL" >> ./oai_rules_result.txt
exit 0
if [ $NB_TO_FORMAT -ne 0 ]; then exit -1; else exit 0; fi
......@@ -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 && \
......
......@@ -198,7 +198,7 @@ class HtmlReport():
self.file.write(' <strong>All files in repository follow OAI rules. <span class="glyphicon glyphicon-ok-circle"></span> -> (' + nb_total.strip() + ' were checked)</strong>\n')
self.file.write(' </div>\n')
else:
self.file.write(' <div class="alert alert-warning">\n')
self.file.write(' <div class="alert alert-danger">\n')
if self.git_pull_request:
self.file.write(' <strong>' + nb_fail.strip() + ' modified files in Pull-Request DO NOT follow OAI rules. <span class="glyphicon glyphicon-warning-sign"></span> -> (' + nb_total.strip() + ' were checked)</strong>\n')
else:
......@@ -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,14 @@ 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) {
// Protect the insertion
std::lock_guard<std::mutex> lck(m_mutex);
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 +216,16 @@ 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) {
// Protect the insertion
std::lock_guard<std::mutex> lck(m_mutex);
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 +256,14 @@ 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) {
// Protect the insertion
std::lock_guard<std::mutex> lck(m_mutex);
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 +320,10 @@ 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;
// Protect the parsing
std::lock_guard<std::mutex> lck(m_mutex);
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 +419,10 @@ 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;
// Protect the parsing
std::lock_guard<std::mutex> lck(m_mutex);
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 +439,10 @@ 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) {
// Protect the parsing
std::lock_guard<std::mutex> lck(m_mutex);
for (auto it = associations.begin(); it != associations.end(); ++it) {
std::shared_ptr<pfcp_association> a = it->second;
// TODO
switch (node_selection_criteria) {
......@@ -447,8 +469,10 @@ 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) {
// Protect the parsing
std::lock_guard<std::mutex> lck(m_mutex);
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) {
......@@ -514,6 +538,8 @@ bool pfcp_associations::add_peer_candidate_node(
if ((*it)->node_id == node_id) {
// TODO purge sessions of this node
Logger::smf_app().info("TODO purge sessions of this node");
// Protect the deletion
std::lock_guard<std::mutex> lck(m_mutex);
pending_associations.erase(it);
break;
}
......
......@@ -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,10 @@ 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;
mutable std::mutex m_mutex;
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