Commit 72eb1d7e authored by Franck Messaoudi's avatar Franck Messaoudi

Update: refactrongi and some changes in the code

parent 1be76e18
...@@ -214,6 +214,8 @@ smf: ...@@ -214,6 +214,8 @@ smf:
upf: upf:
support_features: support_features:
enable_bpf_datapath: yes # If "on": BPF is used as datapath else simpleswitch is used, DEFAULT= off enable_bpf_datapath: yes # If "on": BPF is used as datapath else simpleswitch is used, DEFAULT= off
enable_qos: yes # Only supported for BPF datapath. If "on" we use qdiscs to manage the QoS
#qdisc_scheduler: "htb" # This value is used only in case QoS is enabled
enable_snat: no # If "on": Source natting is done for UE, DEFAULT= off enable_snat: no # If "on": Source natting is done for UE, DEFAULT= off
remote_n6_gw: oai-ext-dn remote_n6_gw: oai-ext-dn
smfs: smfs:
......
...@@ -256,6 +256,13 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) ...@@ -256,6 +256,13 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
set(CMAKE_MODULE_PATH "${SRC_TOP_DIR}/upf_app/cmake" "${CMAKE_MODULE_PATH}")
include(FindPkgConfig)
find_package (LibNL REQUIRED)
################################################################ ################################################################
# Add sub modules # Add sub modules
################################################################ ################################################################
...@@ -311,12 +318,15 @@ IF(STATIC_LINKING) ...@@ -311,12 +318,15 @@ IF(STATIC_LINKING)
SET(ASAN asan) SET(ASAN asan)
ENDIF(STATIC_LINKING) ENDIF(STATIC_LINKING)
## Common modules ## Common modules
include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger/logger.cmake) include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger/logger.cmake)
include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/config/config.cmake) include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/config/config.cmake)
include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/utils/utils.cmake) include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/utils/utils.cmake)
include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/model/nrf/nrf_model.cmake) include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/model/nrf/nrf_model.cmake)
include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/model/common_model/common_model.cmake) include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/model/common_model/common_model.cmake)
include(${SRC_TOP_DIR}/upf_app/cmake/FindLibNL.cmake)
# folly glog dl double-conversion for FB folly library # folly glog dl double-conversion for FB folly library
target_link_libraries (upf target_link_libraries (upf
...@@ -335,7 +345,7 @@ qer_ebpf_tc ...@@ -335,7 +345,7 @@ qer_ebpf_tc
UPF_XDP UPF_XDP
UPF_TC UPF_TC
gflags glog dl double-conversion folly fmt spdlog -Wl,--end-group gflags glog dl double-conversion folly fmt spdlog -Wl,--end-group
pthread m rt config++ pthread m rt config++
event boost_system curl yaml-cpp event boost_system curl yaml-cpp
) )
...@@ -69,6 +69,13 @@ extern upf_nrf* upf_nrf_inst; ...@@ -69,6 +69,13 @@ extern upf_nrf* upf_nrf_inst;
#define N6_IF_NAME upf_cfg.n6.if_name #define N6_IF_NAME upf_cfg.n6.if_name
#endif #endif
#ifndef QDISC_HTB_SCHEDULER
#define QDISC_HTB_SCHEDULER "HTB"
#endif
std::unique_ptr<upf_config_yaml> upf_cfg_yaml = nullptr; std::unique_ptr<upf_config_yaml> upf_cfg_yaml = nullptr;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -127,8 +134,9 @@ int my_check_redundant_process(char* exec_name) { ...@@ -127,8 +134,9 @@ int my_check_redundant_process(char* exec_name) {
delete[] cmd; delete[] cmd;
return result; return result;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void setup_bpf() { void setup_bpf(const char* qdisc_scheduler = nullptr) {
std::shared_ptr<RulesUtilities> mpRulesFactory; std::shared_ptr<RulesUtilities> mpRulesFactory;
mpRulesFactory = std::make_shared<RulesUtilitiesImpl>(); mpRulesFactory = std::make_shared<RulesUtilitiesImpl>();
...@@ -136,9 +144,13 @@ void setup_bpf() { ...@@ -136,9 +144,13 @@ void setup_bpf() {
string sUDPInterface = N6_IF_NAME; string sUDPInterface = N6_IF_NAME;
Logger::upf_app().info("GTP interface: %s", sGTPInterface.c_str()); Logger::upf_app().info("GTP interface: %s", sGTPInterface.c_str());
Logger::upf_app().info("UDP interface: %s", sUDPInterface.c_str()); Logger::upf_app().info("UDP interface: %s", sUDPInterface.c_str());
UserPlaneComponent::getInstance().setup(
mpRulesFactory, sGTPInterface, sUDPInterface); if(qdisc_scheduler){
// spSessionManager = UserPlaneComponent::getInstance().getSessionManager(); UserPlaneComponent::getInstance().setup(mpRulesFactory, sGTPInterface, sUDPInterface, qdisc_scheduler);
} else {
UserPlaneComponent::getInstance().setup(mpRulesFactory, sGTPInterface, sUDPInterface);
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int main(int argc, char** argv) { int main(int argc, char** argv) {
...@@ -218,7 +230,15 @@ int main(int argc, char** argv) { ...@@ -218,7 +230,15 @@ int main(int argc, char** argv) {
fflush(fp); fflush(fp);
fclose(fp); fclose(fp);
if (upf_cfg.enable_bpf_datapath) setup_bpf(); if (upf_cfg.enable_bpf_datapath){
const char *qdisc_scheduler = nullptr;
if (upf_cfg.enable_qos){
const char *qdisc_scheduler = QDISC_HTB_SCHEDULER;
}
setup_bpf(qdisc_scheduler);
}
// once all udp servers initialized // once all udp servers initialized
io_service.run(); io_service.run();
......
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLibNL.cmake)
add_subdirectory(bpf) add_subdirectory(bpf)
include_directories(${SRC_TOP_DIR}/upf_app/bpf/bpf_pfcp) include_directories(${SRC_TOP_DIR}/upf_app/bpf/bpf_pfcp)
include_directories(${SRC_TOP_DIR}/upf_app/simpleswitch) include_directories(${SRC_TOP_DIR}/upf_app/simpleswitch)
...@@ -23,6 +24,8 @@ include_directories(${SRC_TOP_DIR}/upf_app/bpf/rules/qer) ...@@ -23,6 +24,8 @@ include_directories(${SRC_TOP_DIR}/upf_app/bpf/rules/qer)
#include_directories(${SRC_TOP_DIR}/upf_app/bpf/rules/bar) #include_directories(${SRC_TOP_DIR}/upf_app/bpf/rules/bar)
#include_directories(${SRC_TOP_DIR}/upf_app/bpf/rules/mar) #include_directories(${SRC_TOP_DIR}/upf_app/bpf/rules/mar)
include_directories(${LibNL_INCLUDE_DIR})
include_directories(${SRC_TOP_DIR}/upf_app/app) include_directories(${SRC_TOP_DIR}/upf_app/app)
set(GTP_INTERFACE $ENV{GTP_INTERFACE}) set(GTP_INTERFACE $ENV{GTP_INTERFACE})
...@@ -33,7 +36,7 @@ add_library(UPF_XDP STATIC ...@@ -33,7 +36,7 @@ add_library(UPF_XDP STATIC
UserPlaneComponent.cpp UserPlaneComponent.cpp
Configuration.cpp Configuration.cpp
SignalHandler.cpp SignalHandler.cpp
NextHopFinder.cpp helpers/NextHopFinder.cpp
SessionProgramManager.cpp SessionProgramManager.cpp
SessionManager.cpp SessionManager.cpp
SessionPrograms.cpp SessionPrograms.cpp
...@@ -52,7 +55,7 @@ add_library(UPF_TC STATIC ...@@ -52,7 +55,7 @@ add_library(UPF_TC STATIC
UserPlaneComponent.cpp UserPlaneComponent.cpp
Configuration.cpp Configuration.cpp
SignalHandler.cpp SignalHandler.cpp
NextHopFinder.cpp helpers/NextHopFinder.cpp
SessionProgramManager.cpp SessionProgramManager.cpp
SessionManager.cpp SessionManager.cpp
SessionPrograms.cpp SessionPrograms.cpp
......
...@@ -17,13 +17,13 @@ ...@@ -17,13 +17,13 @@
using namespace oai::config; using namespace oai::config;
extern upf_config upf_cfg; extern upf_config upf_cfg;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
SessionManager::SessionManager() {} SessionManager::SessionManager() {}
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
SessionManager::~SessionManager() {} SessionManager::~SessionManager() {}
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// Helper function to extract PDI and source interface // Helper function to extract PDI and source interface
bool SessionManager::extractPdiAndInterface( bool SessionManager::extractPdiAndInterface(
std::shared_ptr<pfcp::pfcp_pdr> pdr, pfcp::pdi& pdi, std::shared_ptr<pfcp::pfcp_pdr> pdr, pfcp::pdi& pdi,
...@@ -32,7 +32,7 @@ bool SessionManager::extractPdiAndInterface( ...@@ -32,7 +32,7 @@ bool SessionManager::extractPdiAndInterface(
return (pdr->get(pdi) && pdi.get(sourceInterface) && pdi.get(ueIpAddress)); return (pdr->get(pdi) && pdi.get(sourceInterface) && pdi.get(ueIpAddress));
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// Helper function to extract FAR // Helper function to extract FAR
bool SessionManager::extractFar( bool SessionManager::extractFar(
std::shared_ptr<pfcp::pfcp_pdr> pdr, std::shared_ptr<pfcp::pfcp_pdr> pdr,
...@@ -45,7 +45,7 @@ bool SessionManager::extractFar( ...@@ -45,7 +45,7 @@ bool SessionManager::extractFar(
return false; return false;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// Helper function to extract Forwarding Parameters // Helper function to extract Forwarding Parameters
bool SessionManager::extractForwardingParameters( bool SessionManager::extractForwardingParameters(
std::shared_ptr<pfcp::pfcp_far> far, std::shared_ptr<pfcp::pfcp_far> far,
...@@ -53,7 +53,7 @@ bool SessionManager::extractForwardingParameters( ...@@ -53,7 +53,7 @@ bool SessionManager::extractForwardingParameters(
return far->get(forwardingParams); return far->get(forwardingParams);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// Helper function to find the Uplink TEID to update // Helper function to find the Uplink TEID to update
uint32_t SessionManager::findUplinkTeid( uint32_t SessionManager::findUplinkTeid(
uint32_t seid, uint32_t seid,
...@@ -84,14 +84,14 @@ uint32_t SessionManager::findUplinkTeid( ...@@ -84,14 +84,14 @@ uint32_t SessionManager::findUplinkTeid(
return teidToUpdate; return teidToUpdate;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void SessionManager::createSession(std::shared_ptr<SessionBpf> pSession) { void SessionManager::createSession(std::shared_ptr<SessionBpf> pSession) {
SessionProgramManager::getInstance().create(pSession->getSeid()); SessionProgramManager::getInstance().create(pSession->getSeid());
Logger::upf_app().debug( Logger::upf_app().debug(
"Session %d Has Been Cretead Successfully", pSession->getSeid()); "Session %d Has Been Cretead Successfully", pSession->getSeid());
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void SessionManager::createBPFSession( void SessionManager::createBPFSession(
std::shared_ptr<pfcp::pfcp_session> pSession_establishment, std::shared_ptr<pfcp::pfcp_session> pSession_establishment,
itti_n4_session_establishment_request* est_req, itti_n4_session_establishment_request* est_req,
...@@ -176,7 +176,7 @@ void SessionManager::createBPFSession( ...@@ -176,7 +176,7 @@ void SessionManager::createBPFSession(
mSeidToSession[pSession_establishment->get_up_seid()] = mSeidToSession[pSession_establishment->get_up_seid()] =
pSession_establishment; pSession_establishment;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void SessionManager::createBPFSessionUL( void SessionManager::createBPFSessionUL(
std::shared_ptr<pfcp::pfcp_session> pSession, std::shared_ptr<pfcp::pfcp_session> pSession,
std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceUl) { std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceUl) {
...@@ -211,7 +211,7 @@ void SessionManager::createBPFSessionUL( ...@@ -211,7 +211,7 @@ void SessionManager::createBPFSessionUL(
ueIpAddress.ipv4_address.s_addr, pFar, false, 0); ueIpAddress.ipv4_address.s_addr, pFar, false, 0);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void SessionManager::createBPFSessionDL( void SessionManager::createBPFSessionDL(
std::shared_ptr<pfcp::pfcp_session> pSession, std::shared_ptr<pfcp::pfcp_session> pSession,
std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceDl) { std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceDl) {
...@@ -247,7 +247,7 @@ void SessionManager::createBPFSessionDL( ...@@ -247,7 +247,7 @@ void SessionManager::createBPFSessionDL(
ueIpAddress.ipv4_address.s_addr, pFar, false, 0); ueIpAddress.ipv4_address.s_addr, pFar, false, 0);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void SessionManager::updateBPFSession( void SessionManager::updateBPFSession(
std::shared_ptr<pfcp::pfcp_session> pSession, std::shared_ptr<pfcp::pfcp_session> pSession,
itti_n4_session_establishment_request* est_req, itti_n4_session_establishment_request* est_req,
...@@ -329,7 +329,7 @@ void SessionManager::updateBPFSession( ...@@ -329,7 +329,7 @@ void SessionManager::updateBPFSession(
} }
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void SessionManager::updateBPFSessionUL( void SessionManager::updateBPFSessionUL(
std::shared_ptr<pfcp::pfcp_session> pSession, std::shared_ptr<pfcp::pfcp_session> pSession,
std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceUl) { std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceUl) {
...@@ -363,7 +363,7 @@ void SessionManager::updateBPFSessionUL( ...@@ -363,7 +363,7 @@ void SessionManager::updateBPFSessionUL(
Logger::upf_app().warn("TODO: update Uplink PDRs ..."); Logger::upf_app().warn("TODO: update Uplink PDRs ...");
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// Function to update the Downlink Direction of a session // Function to update the Downlink Direction of a session
void SessionManager::updateBPFSessionDL( void SessionManager::updateBPFSessionDL(
...@@ -420,7 +420,7 @@ void SessionManager::updateBPFSessionDL( ...@@ -420,7 +420,7 @@ void SessionManager::updateBPFSessionDL(
} }
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void SessionManager::removeBPFSession( void SessionManager::removeBPFSession(
std::shared_ptr<pfcp::pfcp_session> pSession, std::shared_ptr<pfcp::pfcp_session> pSession,
itti_n4_session_establishment_request* est_req, itti_n4_session_establishment_request* est_req,
...@@ -438,7 +438,7 @@ void SessionManager::removeBPFSession( ...@@ -438,7 +438,7 @@ void SessionManager::removeBPFSession(
Logger::upf_app().debug("Session 0x%x Has Been Removed Successfully", seid); Logger::upf_app().debug("Session 0x%x Has Been Removed Successfully", seid);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
bool SessionManager::comparePDR( bool SessionManager::comparePDR(
const std::shared_ptr<pfcp::pfcp_pdr>& pFirst, const std::shared_ptr<pfcp::pfcp_pdr>& pFirst,
const std::shared_ptr<pfcp::pfcp_pdr>& pSecond) { const std::shared_ptr<pfcp::pfcp_pdr>& pSecond) {
...@@ -449,10 +449,10 @@ bool SessionManager::comparePDR( ...@@ -449,10 +449,10 @@ bool SessionManager::comparePDR(
return precedenceFirst.precedence < precedenceSecond.precedence; return precedenceFirst.precedence < precedenceSecond.precedence;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void SessionManager::removeSession(uint64_t seid) { void SessionManager::removeSession(uint64_t seid) {
SessionProgramManager::getInstance().remove(seid); SessionProgramManager::getInstance().remove(seid);
Logger::upf_app().debug("Session %d has been removed", seid); Logger::upf_app().debug("Session %d has been removed", seid);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
...@@ -43,7 +43,7 @@ class SessionManager { ...@@ -43,7 +43,7 @@ class SessionManager {
// Set of PDRs. // Set of PDRs.
using pdrs_t = std::vector<std::shared_ptr<PacketDetectionRules>>; using pdrs_t = std::vector<std::shared_ptr<PacketDetectionRules>>;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Construct a new Session Manager object. * @brief Construct a new Session Manager object.
...@@ -51,21 +51,21 @@ class SessionManager { ...@@ -51,21 +51,21 @@ class SessionManager {
*/ */
SessionManager(); SessionManager();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Destroy the Session Manager object. * @brief Destroy the Session Manager object.
* *
*/ */
virtual ~SessionManager(); virtual ~SessionManager();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Create a Session object in BPF map. * @brief Create a Session object in BPF map.
* *
* @param pSession The session object to be created. * @param pSession The session object to be created.
*/ */
void createSession(std::shared_ptr<SessionBpf> pSession); void createSession(std::shared_ptr<SessionBpf> pSession);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Remove a session object from BPF map. * @brief Remove a session object from BPF map.
...@@ -75,7 +75,7 @@ class SessionManager { ...@@ -75,7 +75,7 @@ class SessionManager {
*/ */
void removeSession(uint64_t seid); void removeSession(uint64_t seid);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Creates BPF pipeline. * @brief Creates BPF pipeline.
* *
...@@ -87,7 +87,7 @@ class SessionManager { ...@@ -87,7 +87,7 @@ class SessionManager {
itti_n4_session_establishment_request* est_req, itti_n4_session_establishment_request* est_req,
itti_n4_session_modification_request* mod_req, itti_n4_session_modification_request* mod_req,
itti_n4_session_deletion_request* del_req); itti_n4_session_deletion_request* del_req);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Update a Session object in BPF map. * @brief Update a Session object in BPF map.
...@@ -100,7 +100,7 @@ class SessionManager { ...@@ -100,7 +100,7 @@ class SessionManager {
itti_n4_session_modification_request* mod_req, itti_n4_session_modification_request* mod_req,
itti_n4_session_deletion_request* del_req); itti_n4_session_deletion_request* del_req);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Remove BPF pipeline. * @brief Remove BPF pipeline.
* *
...@@ -113,56 +113,56 @@ class SessionManager { ...@@ -113,56 +113,56 @@ class SessionManager {
itti_n4_session_modification_request* mod_req, itti_n4_session_modification_request* mod_req,
itti_n4_session_deletion_request* del_req); itti_n4_session_deletion_request* del_req);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void createBPFSessionUL( void createBPFSessionUL(
std::shared_ptr<pfcp::pfcp_session> pSession, std::shared_ptr<pfcp::pfcp_session> pSession,
std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceUl); std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceUl);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void createBPFSessionDL( void createBPFSessionDL(
std::shared_ptr<pfcp::pfcp_session> pSession, std::shared_ptr<pfcp::pfcp_session> pSession,
std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceDl); std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceDl);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void updateBPFSessionUL( void updateBPFSessionUL(
std::shared_ptr<pfcp::pfcp_session> pSession, std::shared_ptr<pfcp::pfcp_session> pSession,
std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceUl); std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceUl);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void updateBPFSessionDL( void updateBPFSessionDL(
std::shared_ptr<pfcp::pfcp_session> pSession, std::shared_ptr<pfcp::pfcp_session> pSession,
std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceDl); std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceDl);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
bool extractPdiAndInterface( bool extractPdiAndInterface(
std::shared_ptr<pfcp::pfcp_pdr> pdr, pfcp::pdi& pdi, std::shared_ptr<pfcp::pfcp_pdr> pdr, pfcp::pdi& pdi,
pfcp::source_interface_t& sourceInterface, pfcp::source_interface_t& sourceInterface,
pfcp::ue_ip_address_t& ueIpAddress); pfcp::ue_ip_address_t& ueIpAddress);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
bool extractFar( bool extractFar(
std::shared_ptr<pfcp::pfcp_pdr> pdr, std::shared_ptr<pfcp::pfcp_pdr> pdr,
std::shared_ptr<pfcp::pfcp_session> session, std::shared_ptr<pfcp::pfcp_session> session,
std::shared_ptr<pfcp::pfcp_far>& outFar); std::shared_ptr<pfcp::pfcp_far>& outFar);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
bool extractForwardingParameters( bool extractForwardingParameters(
std::shared_ptr<pfcp::pfcp_far> far, std::shared_ptr<pfcp::pfcp_far> far,
pfcp::forwarding_parameters& forwardingParams); pfcp::forwarding_parameters& forwardingParams);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
uint32_t findUplinkTeid( uint32_t findUplinkTeid(
uint32_t seid, uint32_t seid,
const std::vector<std::shared_ptr<pfcp::pfcp_session>>& sessions); const std::vector<std::shared_ptr<pfcp::pfcp_session>>& sessions);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
static bool comparePDR( static bool comparePDR(
const std::shared_ptr<pfcp::pfcp_pdr>& first, const std::shared_ptr<pfcp::pfcp_pdr>& first,
const std::shared_ptr<pfcp::pfcp_pdr>& second); const std::shared_ptr<pfcp::pfcp_pdr>& second);
std::vector<std::shared_ptr<pfcp::pfcp_session>> sessions; std::vector<std::shared_ptr<pfcp::pfcp_session>> sessions;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::unordered_map<uint64_t, std::shared_ptr<pfcp::pfcp_session>> std::unordered_map<uint64_t, std::shared_ptr<pfcp::pfcp_session>>
mSeidToSession; mSeidToSession;
}; };
......
This diff is collapsed.
...@@ -36,7 +36,7 @@ class SessionProgramManager { ...@@ -36,7 +36,7 @@ class SessionProgramManager {
*/ */
virtual ~SessionProgramManager(); virtual ~SessionProgramManager();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Instance object. * @brief Get the Instance object.
* *
...@@ -44,7 +44,7 @@ class SessionProgramManager { ...@@ -44,7 +44,7 @@ class SessionProgramManager {
*/ */
static SessionProgramManager& getInstance(); static SessionProgramManager& getInstance();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Set the Programs Map object. * @brief Set the Programs Map object.
* *
...@@ -52,7 +52,7 @@ class SessionProgramManager { ...@@ -52,7 +52,7 @@ class SessionProgramManager {
*/ */
void setTeidSessionMap(std::shared_ptr<BPFMap> pProgramsMaps); void setTeidSessionMap(std::shared_ptr<BPFMap> pProgramsMaps);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Create a new program related to the SEID. * @brief Create a new program related to the SEID.
* The context will be empty. * The context will be empty.
...@@ -61,7 +61,7 @@ class SessionProgramManager { ...@@ -61,7 +61,7 @@ class SessionProgramManager {
*/ */
void create(uint32_t seid); void create(uint32_t seid);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Remove program session context. * @brief Remove program session context.
* *
...@@ -69,14 +69,14 @@ class SessionProgramManager { ...@@ -69,14 +69,14 @@ class SessionProgramManager {
*/ */
void remove(uint32_t seid); void remove(uint32_t seid);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Remove all programs. * @brief Remove all programs.
* *
*/ */
void removeAll(); void removeAll();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Set the On New Session Observer object. * @brief Set the On New Session Observer object.
* *
...@@ -85,7 +85,7 @@ class SessionProgramManager { ...@@ -85,7 +85,7 @@ class SessionProgramManager {
*/ */
void setOnNewSessionObserver(OnStateChangeSessionProgramObserver* pObserver); void setOnNewSessionObserver(OnStateChangeSessionProgramObserver* pObserver);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Find the Session Program object. * @brief Find the Session Program object.
* *
...@@ -96,80 +96,80 @@ class SessionProgramManager { ...@@ -96,80 +96,80 @@ class SessionProgramManager {
std::shared_ptr<PFCP_Session_PDR_LookupProgram> findSessionProgram( std::shared_ptr<PFCP_Session_PDR_LookupProgram> findSessionProgram(
uint32_t seid); uint32_t seid);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void addFarProgram(uint32_t seid, std::shared_ptr<FARProgram> pFARProgram); void addFarProgram(uint32_t seid, std::shared_ptr<FARProgram> pFARProgram);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void updateArpTableMap( void updateArpTableMap(
std::shared_ptr<FARProgram> pFARProgram, uint32_t upfIP, std::shared_ptr<FARProgram> pFARProgram, uint32_t upfIP,
uint32_t remoteIP); uint32_t remoteIP);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
uint32_t getRemoteIP(uint32_t upfIP, uint32_t remoteIP); uint32_t getRemoteIP(uint32_t upfIP, uint32_t remoteIP);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
pfcp_far_t_ createFar(std::shared_ptr<pfcp::pfcp_far> pFar); pfcp_far_t_ createFar(std::shared_ptr<pfcp::pfcp_far> pFar);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void createPipeline( void createPipeline(
uint32_t seid, uint32_t teid1, uint8_t sourceInterface, uint32_t seid, uint32_t teid1, uint8_t sourceInterface,
uint32_t ueIpAddress, std::shared_ptr<pfcp::pfcp_far> pFar, uint32_t ueIpAddress, std::shared_ptr<pfcp::pfcp_far> pFar,
bool isModification, uint32_t teid2); bool isModification, uint32_t teid2);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void initializeNextRuleProgIndexKey( void initializeNextRuleProgIndexKey(
next_rule_prog_index_key& key, uint32_t teid, uint32_t ueIpAddress, next_rule_prog_index_key& key, uint32_t teid, uint32_t ueIpAddress,
uint8_t sourceInterface); uint8_t sourceInterface);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void storeFarProgramIndexInNextProgRuleIndexMap( void storeFarProgramIndexInNextProgRuleIndexMap(
std::shared_ptr<FARProgram> pFARProgram, std::shared_ptr<FARProgram> pFARProgram,
const next_rule_prog_index_key& key, const next_rule_prog_index_key& key,
std::shared_ptr<PFCP_Session_LookupProgram> pPFCP_Session_LookupProgram); std::shared_ptr<PFCP_Session_LookupProgram> pPFCP_Session_LookupProgram);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void storeSessionMappingMap( void storeSessionMappingMap(
std::shared_ptr<PFCP_Session_LookupProgram> pPFCP_Session_LookupProgram, std::shared_ptr<PFCP_Session_LookupProgram> pPFCP_Session_LookupProgram,
uint32_t ue_ip_address, uint32_t teid_dl); uint32_t ue_ip_address, uint32_t teid_dl);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void storeFARInFARMap( void storeFARInFARMap(
std::shared_ptr<FARProgram> pFARProgram, std::shared_ptr<FARProgram> pFARProgram,
std::shared_ptr<pfcp::pfcp_far> pFar); std::shared_ptr<pfcp::pfcp_far> pFar);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void saveSeidWithinFARProgram( void saveSeidWithinFARProgram(
uint32_t seid, std::shared_ptr<FARProgram> pFARProgram, uint32_t seid, std::shared_ptr<FARProgram> pFARProgram,
const next_rule_prog_index_key& key); const next_rule_prog_index_key& key);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void updateARPTableForN6( void updateARPTableForN6(
std::shared_ptr<FARProgram> pFARProgram, uint32_t dnIP, uint32_t upfn6IP); std::shared_ptr<FARProgram> pFARProgram, uint32_t dnIP, uint32_t upfn6IP);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void updateARPTableForN3( void updateARPTableForN3(
std::shared_ptr<FARProgram> pFARProgram, uint32_t gNodeBIP, std::shared_ptr<FARProgram> pFARProgram, uint32_t gNodeBIP,
uint32_t upfn3IP, uint32_t seid); uint32_t upfn3IP, uint32_t seid);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
uint32_t getGnodebIp(std::shared_ptr<pfcp::pfcp_far> pFar); uint32_t getGnodebIp(std::shared_ptr<pfcp::pfcp_far> pFar);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void updatePipeline( void updatePipeline(
uint32_t seid, uint32_t teid, uint32_t gNBIpAddress, bool isModification); uint32_t seid, uint32_t teid, uint32_t gNBIpAddress, bool isModification);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// void storeUeQfiTeidMap( // void storeUeQfiTeidMap(
// std::shared_ptr<PFCP_Session_LookupProgram> // std::shared_ptr<PFCP_Session_LookupProgram>
// pPFCP_Session_LookupProgram, uint32_t ue_ip_address, uint8_t qfi, // pPFCP_Session_LookupProgram, uint32_t ue_ip_address, uint8_t qfi,
// uint32_t teid_ul); // uint32_t teid_ul);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// void updateMap(std::shared_ptr<PFCP_Session_LookupProgram> // void updateMap(std::shared_ptr<PFCP_Session_LookupProgram>
// pPFCP_Session_LookupProgram, // pPFCP_Session_LookupProgram,
// uint32_t seid, uint32_t teid_ul, uint32_t src_ip, uint32_t teid_dl); // uint32_t seid, uint32_t teid_ul, uint32_t src_ip, uint32_t teid_dl);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void removePipeline(uint32_t seid); void removePipeline(uint32_t seid);
std::shared_ptr<SessionPrograms> findSessionPrograms(uint32_t seid); std::shared_ptr<SessionPrograms> findSessionPrograms(uint32_t seid);
......
...@@ -6,8 +6,19 @@ ...@@ -6,8 +6,19 @@
#include <SignalHandler.h> #include <SignalHandler.h>
#include <pfcp_session_lookup_ebpf_xdp_prgrm_user.h> #include <pfcp_session_lookup_ebpf_xdp_prgrm_user.h>
#include "logger.hpp" #include "logger.hpp"
#include <helpers/GetNicInformation.hpp>
/*****************************************************************************************************************/ #include <netlink/netlink.h>
#include <netlink/route/qdisc.h>
#include <netlink/route/link.h>
#include <netlink/route/qdisc/htb.h>
#ifndef QDISC_HTB_SCHEDULER
#define QDISC_HTB_SCHEDULER HTB
#endif
/*---------------------------------------------------------------------------------------------------------------*/
UserPlaneComponent::UserPlaneComponent() { UserPlaneComponent::UserPlaneComponent() {
// Set new handlers for libbpf. // Set new handlers for libbpf.
#ifdef DEBUG_LIBBPF #ifdef DEBUG_LIBBPF
...@@ -15,64 +26,70 @@ UserPlaneComponent::UserPlaneComponent() { ...@@ -15,64 +26,70 @@ UserPlaneComponent::UserPlaneComponent() {
#endif #endif
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
UserPlaneComponent::~UserPlaneComponent() { UserPlaneComponent::~UserPlaneComponent() {
tearDown(); tearDown();
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<SessionManager> UserPlaneComponent::getSessionManager() const { std::shared_ptr<SessionManager> UserPlaneComponent::getSessionManager() const {
return mpSessionManager; return mpSessionManager;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<RulesUtilities> UserPlaneComponent::getRulesUtilities() const { std::shared_ptr<RulesUtilities> UserPlaneComponent::getRulesUtilities() const {
return mpRulesUtilities; return mpRulesUtilities;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<PFCP_Session_LookupProgram> std::shared_ptr<PFCP_Session_LookupProgram>
UserPlaneComponent::getPFCP_Session_LookupProgram() const { UserPlaneComponent::getPFCP_Session_LookupProgram() const {
return mpPFCP_Session_LookupProgram; return mpPFCP_Session_LookupProgram;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::string UserPlaneComponent::getGTPInterface() const { std::string UserPlaneComponent::getGTPInterface() const {
return mGTPInterface; return mGTPInterface;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::string UserPlaneComponent::getUDPInterface() const { std::string UserPlaneComponent::getUDPInterface() const {
return mUDPInterface; return mUDPInterface;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
const char* UserPlaneComponent::getQdiscScheduler() const {
return mQdiscScheduler;
}
/*---------------------------------------------------------------------------------------------------------------*/
void UserPlaneComponent::onNewSessionProgram( void UserPlaneComponent::onNewSessionProgram(
u_int32_t programId, u_int32_t fileDescriptor) { u_int32_t programId, u_int32_t fileDescriptor) {
mpPFCP_Session_LookupProgram->updateProgramMap(programId, fileDescriptor); mpPFCP_Session_LookupProgram->updateProgramMap(programId, fileDescriptor);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void UserPlaneComponent::onDestroySessionProgram(u_int32_t programId) { void UserPlaneComponent::onDestroySessionProgram(u_int32_t programId) {
mpPFCP_Session_LookupProgram->removeProgramMap(programId); mpPFCP_Session_LookupProgram->removeProgramMap(programId);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
int UserPlaneComponent::printLibbpfLog( int UserPlaneComponent::printLibbpfLog(
enum libbpf_print_level lvl, const char* fmt, va_list args) { enum libbpf_print_level lvl, const char* fmt, va_list args) {
return vfprintf(stderr, fmt, args); return vfprintf(stderr, fmt, args);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
UserPlaneComponent& UserPlaneComponent::getInstance() { UserPlaneComponent& UserPlaneComponent::getInstance() {
static UserPlaneComponent sInstance; static UserPlaneComponent sInstance;
return sInstance; return sInstance;
} }
/*****************************************************************************************************************/
void UserPlaneComponent::setup( /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<RulesUtilities> pRulesUtilities, void UserPlaneComponent::set_members(std::shared_ptr<RulesUtilities> pRulesUtilities,
const std::string& gtpInterface, const std::string& udpInterface) { const std::string& gtpInterface, const std::string& udpInterface){
mpRulesUtilities = pRulesUtilities; mpRulesUtilities = pRulesUtilities;
mGTPInterface = gtpInterface; mGTPInterface = gtpInterface;
mUDPInterface = udpInterface; mUDPInterface = udpInterface;
...@@ -84,14 +101,86 @@ void UserPlaneComponent::setup( ...@@ -84,14 +101,86 @@ void UserPlaneComponent::setup(
throw std::runtime_error("The eBPF Program is Not Initialized"); throw std::runtime_error("The eBPF Program is Not Initialized");
} }
}
/*---------------------------------------------------------------------------------------------------------------*/
void UserPlaneComponent::setup(
std::shared_ptr<RulesUtilities> pRulesUtilities,
const std::string& gtpInterface, const std::string& udpInterface) {
set_members(pRulesUtilities, gtpInterface, udpInterface);
SignalHandler::getInstance().enable();
mpPFCP_Session_LookupProgram->setup();
// Pass maps to sessionManager.
mpSessionManager = std::make_shared<SessionManager>();
}
/*---------------------------------------------------------------------------------------------------------------*/
void UserPlaneComponent::setup(
std::shared_ptr<RulesUtilities> pRulesUtilities,
const std::string& gtpInterface, const std::string& udpInterface, const char* qdisc_scheduler) {
set_members(pRulesUtilities, gtpInterface, udpInterface);
mQdiscScheduler = qdisc_scheduler;
SignalHandler::getInstance().enable(); SignalHandler::getInstance().enable();
mpPFCP_Session_LookupProgram->setup(); mpPFCP_Session_LookupProgram->setup();
// Pass maps to sessionManager. // Pass maps to sessionManager.
mpSessionManager = std::make_shared<SessionManager>(); mpSessionManager = std::make_shared<SessionManager>();
qdisc_att = new struct qdisc_params;
}
/*---------------------------------------------------------------------------------------------------------------*/
// Method to create the root qdisc
struct rtnl_qdisc* UserPlaneComponent::create_qdisc(struct nl_sock *sock){
// Allocate a new Qdisc object
struct rtnl_qdisc *qdisc = rtnl_qdisc_alloc();
if (!qdisc) {
perror("rtnl_qdisc_alloc");
nl_close(sock);
nl_socket_free(sock);
exit(EXIT_FAILURE);
}
return qdisc;
}
/*---------------------------------------------------------------------------------------------------------------*/
// Method definition to initialize qdisc_att
void UserPlaneComponent::initializeQdisc(std::string interface) {
NicInformationGetter nicInfoGet;
// Initialize qdisc_att members
qdisc_att->scheduler = getQdiscScheduler();
qdisc_att->rate = nicInfoGet.retrieveRate(interface);
qdisc_att->ceil = nicInfoGet.retrieveCeil(interface);
qdisc_att->rate_buffer = 0;
qdisc_att->ceil_buffer = 0;
qdisc_att->quantum = 0;
qdisc_att->level = 0;
}
/*---------------------------------------------------------------------------------------------------------------*/
struct rtnl_qdisc* UserPlaneComponent::configure_qdisc(struct rtnl_qdisc *qdisc, struct rtnl_class *htb_class){
// Set Qdisc attributes
rtnl_tc_set_kind(TC_CAST(qdisc), qdisc_att->scheduler);
if (strcmp(qdisc_att->scheduler, QDISC_HTB_SCHEDULER) == 0) {
rtnl_htb_set_rate(htb_class, qdisc_att->rate); // Set Physical capacity
rtnl_htb_set_rbuffer(htb_class, qdisc_att->rate_buffer);
rtnl_htb_set_cbuffer(htb_class, qdisc_att->ceil_buffer);
rtnl_htb_set_quantum(htb_class, qdisc_att->quantum);
rtnl_htb_set_level(htb_class, qdisc_att->level);
}
// Set additional Qdisc attributes as needed
return qdisc;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void UserPlaneComponent::tearDown() { void UserPlaneComponent::tearDown() {
mpPFCP_Session_LookupProgram->tearDown(); mpPFCP_Session_LookupProgram->tearDown();
SessionProgramManager::getInstance().removeAll(); SessionProgramManager::getInstance().removeAll();
......
This diff is collapsed.
...@@ -516,6 +516,13 @@ int upf_config::load(const string& config_file) { ...@@ -516,6 +516,13 @@ int upf_config::load(const string& config_file) {
enable_bpf_datapath = false; enable_bpf_datapath = false;
} }
support_features.lookupValue(UPF_CONFIG_STRING_ENABLE_QOS, opt);
if (boost::iequals(opt, "yes")) {
enable_qos = true;
} else {
enable_qos = false;
}
support_features.lookupValue( support_features.lookupValue(
UPF_CONFIG_STRING_5G_FEATURES_USE_FQDN_NRF, opt); UPF_CONFIG_STRING_5G_FEATURES_USE_FQDN_NRF, opt);
if (boost::iequals(opt, "yes")) { if (boost::iequals(opt, "yes")) {
...@@ -789,6 +796,12 @@ void upf_config::display() { ...@@ -789,6 +796,12 @@ void upf_config::display() {
Logger::upf_app().info(" register_nrf: %s", (register_nrf) ? "yes" : "no"); Logger::upf_app().info(" register_nrf: %s", (register_nrf) ? "yes" : "no");
Logger::upf_app().info( Logger::upf_app().info(
" enable_bpf_datapath: %s", (enable_bpf_datapath) ? "yes" : "no"); " enable_bpf_datapath: %s", (enable_bpf_datapath) ? "yes" : "no");
if (enable_bpf_datapath){
Logger::upf_app().info(" enable_qos: %s", (enable_qos) ? "yes" : "no");
} else {
Logger::upf_app().info(" enable_qos: no");
}
Logger::upf_app().info(" use_fqdn_dns: %s", (use_fqdn_dns) ? "yes" : "no"); Logger::upf_app().info(" use_fqdn_dns: %s", (use_fqdn_dns) ? "yes" : "no");
if (register_nrf) { if (register_nrf) {
Logger::upf_app().info(" NRF:"); Logger::upf_app().info(" NRF:");
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
constexpr auto UPF_CONFIG_OPTION_YES_STR = "Yes"; constexpr auto UPF_CONFIG_OPTION_YES_STR = "Yes";
constexpr auto UPF_CONFIG_OPTION_NO_STR = "No"; constexpr auto UPF_CONFIG_OPTION_NO_STR = "No";
const oai::model::common::Snssai DEFAULT_SNSSAI{1}; const oai::model::common::Snssai DEFAULT_SNSSAI{1};
const std::vector<oai::model::nrf::DnnUpfInfoItem> DEFAULT_DNN_LIST = { const std::vector<oai::model::nrf::DnnUpfInfoItem> DEFAULT_DNN_LIST = {
oai::model::nrf::DnnUpfInfoItem("default")}; oai::model::nrf::DnnUpfInfoItem("default")};
...@@ -88,6 +89,7 @@ const std::vector<oai::model::nrf::DnnUpfInfoItem> DEFAULT_DNN_LIST = { ...@@ -88,6 +89,7 @@ const std::vector<oai::model::nrf::DnnUpfInfoItem> DEFAULT_DNN_LIST = {
#define UPF_CONFIG_STRING_5G_FEATURES "SUPPORT_5G_FEATURES" #define UPF_CONFIG_STRING_5G_FEATURES "SUPPORT_5G_FEATURES"
#define UPF_CONFIG_STRING_ENABLE_BPF_DATAPATH "ENABLE_BPF_DATAPATH" #define UPF_CONFIG_STRING_ENABLE_BPF_DATAPATH "ENABLE_BPF_DATAPATH"
#define UPF_CONFIG_STRING_ENABLE_QOS "ENABLE_QOS"
#define UPF_CONFIG_STRING_5G_FEATURES_REGISTER_NRF "REGISTER_NRF" #define UPF_CONFIG_STRING_5G_FEATURES_REGISTER_NRF "REGISTER_NRF"
#define UPF_CONFIG_STRING_5G_FEATURES_UPF_FQDN "UPF_FQDN_5G" #define UPF_CONFIG_STRING_5G_FEATURES_UPF_FQDN "UPF_FQDN_5G"
#define UPF_CONFIG_STRING_5G_FEATURES_NRF "NRF" #define UPF_CONFIG_STRING_5G_FEATURES_NRF "NRF"
...@@ -184,6 +186,7 @@ class upf_config { ...@@ -184,6 +186,7 @@ class upf_config {
bool enable_5g_features; bool enable_5g_features;
bool enable_bpf_datapath; bool enable_bpf_datapath;
bool enable_qos;
bool register_nrf; bool register_nrf;
struct in_addr remote_n6; struct in_addr remote_n6;
upf_info_t upf_info; upf_info_t upf_info;
...@@ -237,6 +240,7 @@ class upf_config { ...@@ -237,6 +240,7 @@ class upf_config {
enable_5g_features = true; enable_5g_features = true;
enable_bpf_datapath = false; enable_bpf_datapath = false;
enable_qos = false;
register_nrf = false; register_nrf = false;
upf_info = {}; upf_info = {};
use_fqdn_dns = false; use_fqdn_dns = false;
......
...@@ -32,10 +32,15 @@ namespace oai::config { ...@@ -32,10 +32,15 @@ namespace oai::config {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
upf_support_features::upf_support_features( upf_support_features::upf_support_features(
bool enable_bpf_datapath, bool enable_snat) { bool enable_bpf_datapath, bool enable_qos, bool enable_snat) {
m_config_name = "Supported Features"; m_config_name = "Supported Features";
m_enable_bpf_datapath = option_config_value( m_enable_bpf_datapath = option_config_value(
UPF_CONFIG_SUPPORT_FEATURES_ENABLE_BPF_LABEL, enable_bpf_datapath); UPF_CONFIG_SUPPORT_FEATURES_ENABLE_BPF_LABEL, enable_bpf_datapath);
m_enable_qos = option_config_value(
UPF_CONFIG_SUPPORT_FEATURES_ENABLE_QOS_LABEL, enable_qos);
m_enable_snat = option_config_value( m_enable_snat = option_config_value(
UPF_CONFIG_SUPPORT_FEATURES_ENABLE_SNAT_LABEL, enable_snat); UPF_CONFIG_SUPPORT_FEATURES_ENABLE_SNAT_LABEL, enable_snat);
} }
...@@ -46,6 +51,12 @@ void upf_support_features::from_yaml(const YAML::Node& node) { ...@@ -46,6 +51,12 @@ void upf_support_features::from_yaml(const YAML::Node& node) {
m_enable_bpf_datapath.from_yaml( m_enable_bpf_datapath.from_yaml(
node[UPF_CONFIG_SUPPORT_FEATURES_ENABLE_BPF]); node[UPF_CONFIG_SUPPORT_FEATURES_ENABLE_BPF]);
} }
if (node[UPF_CONFIG_SUPPORT_FEATURES_ENABLE_QOS]) {
m_enable_qos.from_yaml(
node[UPF_CONFIG_SUPPORT_FEATURES_ENABLE_QOS]);
}
if (node[UPF_CONFIG_SUPPORT_FEATURES_ENABLE_SNAT]) { if (node[UPF_CONFIG_SUPPORT_FEATURES_ENABLE_SNAT]) {
m_enable_snat.from_yaml(node[UPF_CONFIG_SUPPORT_FEATURES_ENABLE_SNAT]); m_enable_snat.from_yaml(node[UPF_CONFIG_SUPPORT_FEATURES_ENABLE_SNAT]);
} }
...@@ -56,6 +67,7 @@ std::string upf_support_features::to_string(const std::string& indent) const { ...@@ -56,6 +67,7 @@ std::string upf_support_features::to_string(const std::string& indent) const {
std::string out; std::string out;
unsigned int inner_width = get_inner_width(indent.length()); unsigned int inner_width = get_inner_width(indent.length());
// Enable BPF
std::string enable_bpf_datapath = m_enable_bpf_datapath.get_value() ? std::string enable_bpf_datapath = m_enable_bpf_datapath.get_value() ?
UPF_CONFIG_OPTION_YES_STR : UPF_CONFIG_OPTION_YES_STR :
UPF_CONFIG_OPTION_NO_STR; UPF_CONFIG_OPTION_NO_STR;
...@@ -63,7 +75,17 @@ std::string upf_support_features::to_string(const std::string& indent) const { ...@@ -63,7 +75,17 @@ std::string upf_support_features::to_string(const std::string& indent) const {
BASE_FORMATTER, INNER_LIST_ELEM, BASE_FORMATTER, INNER_LIST_ELEM,
UPF_CONFIG_SUPPORT_FEATURES_ENABLE_BPF_LABEL, inner_width, UPF_CONFIG_SUPPORT_FEATURES_ENABLE_BPF_LABEL, inner_width,
enable_bpf_datapath)); enable_bpf_datapath));
// Enable QoS
std::string enable_qos = m_enable_qos.get_value() ?
UPF_CONFIG_OPTION_YES_STR :
UPF_CONFIG_OPTION_NO_STR;
out.append(indent).append(fmt::format(
BASE_FORMATTER, INNER_LIST_ELEM,
UPF_CONFIG_SUPPORT_FEATURES_ENABLE_QOS_LABEL, inner_width,
enable_qos));
// Enable SNAT
std::string enable_snat = m_enable_snat.get_value() ? std::string enable_snat = m_enable_snat.get_value() ?
UPF_CONFIG_OPTION_YES_STR : UPF_CONFIG_OPTION_YES_STR :
UPF_CONFIG_OPTION_NO_STR; UPF_CONFIG_OPTION_NO_STR;
...@@ -78,7 +100,7 @@ upf::upf( ...@@ -78,7 +100,7 @@ upf::upf(
const std::string& name, const std::string& host, const sbi_interface& sbi, const std::string& name, const std::string& host, const sbi_interface& sbi,
const std::map<std::string, upf_interface_config>& interfaces) const std::map<std::string, upf_interface_config>& interfaces)
: nf(name, host, sbi), : nf(name, host, sbi),
m_upf_support_features(false, false), m_upf_support_features(false, false, false),
m_interfaces(interfaces) { m_interfaces(interfaces) {
model::nrf::SnssaiUpfInfoItem item; model::nrf::SnssaiUpfInfoItem item;
item.setSNssai(DEFAULT_SNSSAI); item.setSNssai(DEFAULT_SNSSAI);
...@@ -179,6 +201,11 @@ bool upf_support_features::get_option_enable_bpf_datapath() const { ...@@ -179,6 +201,11 @@ bool upf_support_features::get_option_enable_bpf_datapath() const {
return m_enable_bpf_datapath.get_value(); return m_enable_bpf_datapath.get_value();
} }
//------------------------------------------------------------------------------
bool upf_support_features::get_option_enable_qos() const {
return m_enable_qos.get_value();
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool upf_support_features::get_option_enable_snat() const { bool upf_support_features::get_option_enable_snat() const {
return m_enable_snat.get_value(); return m_enable_snat.get_value();
...@@ -364,9 +391,9 @@ void upf_config_yaml::to_upf_config(upf_config& cfg) { ...@@ -364,9 +391,9 @@ void upf_config_yaml::to_upf_config(upf_config& cfg) {
cfg.sbi.addr4 = local().get_sbi().get_addr4(); cfg.sbi.addr4 = local().get_sbi().get_addr4();
cfg.sbi.if_name = local().get_sbi().get_if_name(); cfg.sbi.if_name = local().get_sbi().get_if_name();
cfg.enable_bpf_datapath = cfg.enable_bpf_datapath = upf_local->get_support_features().get_option_enable_bpf_datapath();
upf_local->get_support_features().get_option_enable_bpf_datapath(); cfg.enable_qos = upf_local->get_support_features().get_option_enable_qos();
cfg.enable_snat = upf_local->get_support_features().get_option_enable_snat(); cfg.enable_snat = upf_local->get_support_features().get_option_enable_snat();
auto snssai_upf_list = upf_local->get_upf_info().getSNssaiUpfInfoList(); auto snssai_upf_list = upf_local->get_upf_info().getSNssaiUpfInfoList();
for (const auto& snssai : snssai_upf_list) { for (const auto& snssai : snssai_upf_list) {
......
...@@ -39,6 +39,9 @@ constexpr auto UPF_CONFIG_SUPPORT_FEATURES_ENABLE_BPF_LABEL = ...@@ -39,6 +39,9 @@ constexpr auto UPF_CONFIG_SUPPORT_FEATURES_ENABLE_BPF_LABEL =
constexpr auto UPF_CONFIG_SUPPORT_FEATURES_ENABLE_SNAT = "enable_snat"; constexpr auto UPF_CONFIG_SUPPORT_FEATURES_ENABLE_SNAT = "enable_snat";
constexpr auto UPF_CONFIG_SUPPORT_FEATURES_ENABLE_SNAT_LABEL = "Enable SNAT"; constexpr auto UPF_CONFIG_SUPPORT_FEATURES_ENABLE_SNAT_LABEL = "Enable SNAT";
constexpr auto UPF_CONFIG_SUPPORT_FEATURES_ENABLE_QOS = "enable_qos";
constexpr auto UPF_CONFIG_SUPPORT_FEATURES_ENABLE_QOS_LABEL = "Enable QoS";
constexpr auto UPF_CONFIG_REMOTE_N6_GW = "remote_n6_gw"; constexpr auto UPF_CONFIG_REMOTE_N6_GW = "remote_n6_gw";
constexpr auto UPF_CONFIG_REMOTE_N6_GW_LABEL = "Remote N6 Gateway"; constexpr auto UPF_CONFIG_REMOTE_N6_GW_LABEL = "Remote N6 Gateway";
...@@ -52,15 +55,17 @@ namespace oai::config { ...@@ -52,15 +55,17 @@ namespace oai::config {
class upf_support_features : public config_type { class upf_support_features : public config_type {
private: private:
option_config_value m_enable_bpf_datapath{}; option_config_value m_enable_bpf_datapath{};
option_config_value m_enable_qos{};
option_config_value m_enable_snat{}; option_config_value m_enable_snat{};
public: public:
explicit upf_support_features(bool enable_bpf_datapath, bool enable_snat); explicit upf_support_features(bool enable_bpf_datapath, bool enable_qos, bool enable_snat);
void from_yaml(const YAML::Node& node) override; void from_yaml(const YAML::Node& node) override;
[[nodiscard]] std::string to_string(const std::string& indent) const override; [[nodiscard]] std::string to_string(const std::string& indent) const override;
[[nodiscard]] bool get_option_enable_bpf_datapath() const; [[nodiscard]] bool get_option_enable_bpf_datapath() const;
[[nodiscard]] bool get_option_enable_qos() const;
[[nodiscard]] bool get_option_enable_snat() const; [[nodiscard]] bool get_option_enable_snat() const;
}; };
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
// INTERFACE_VALUE_5G_VN_INTERNAL = 4 // INTERFACE_VALUE_5G_VN_INTERNAL = 4
// }; // };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
typedef struct source_interface { typedef struct source_interface {
ie_base_t_ base; ie_base_t_ base;
u8 interface_value; u8 interface_value;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <string.h> //Needed for memcpy #include <string.h> //Needed for memcpy
#include "bpf_endian.h" #include "bpf_endian.h"
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// TODO: Put dummy in test folder. // TODO: Put dummy in test folder.
/** /**
* WARNING: Redirect require an XDP bpf_prog loaded on the TX device. * WARNING: Redirect require an XDP bpf_prog loaded on the TX device.
...@@ -36,7 +36,7 @@ int xdp_redirect_gtpu(struct xdp_md* p_ctx) { ...@@ -36,7 +36,7 @@ int xdp_redirect_gtpu(struct xdp_md* p_ctx) {
return XDP_PASS; return XDP_PASS;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Update MAC address * @brief Update MAC address
* *
...@@ -60,7 +60,7 @@ static u32 update_dst_mac_address(u32 ip, struct ethhdr* p_eth) { ...@@ -60,7 +60,7 @@ static u32 update_dst_mac_address(u32 ip, struct ethhdr* p_eth) {
return 0; return 0;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
static u32 get_ip_address_from_map(e_reference_point key) { static u32 get_ip_address_from_map(e_reference_point key) {
struct s_interface* map_element = struct s_interface* map_element =
bpf_map_lookup_elem(&m_upf_interfaces, &key); bpf_map_lookup_elem(&m_upf_interfaces, &key);
...@@ -76,7 +76,7 @@ static u32 get_ip_address_from_map(e_reference_point key) { ...@@ -76,7 +76,7 @@ static u32 get_ip_address_from_map(e_reference_point key) {
return XDP_DROP; return XDP_DROP;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
static u32 create_outer_header_gtpu_ipv4( static u32 create_outer_header_gtpu_ipv4(
struct xdp_md* p_ctx, pfcp_far_t_* p_far) { struct xdp_md* p_ctx, pfcp_far_t_* p_far) {
bpf_debug("Create Outer Header GTPU_IPv4"); bpf_debug("Create Outer Header GTPU_IPv4");
...@@ -238,7 +238,7 @@ static u32 create_outer_header_gtpu_ipv4( ...@@ -238,7 +238,7 @@ static u32 create_outer_header_gtpu_ipv4(
bpf_debug("GTPU header were pushed!"); bpf_debug("GTPU header were pushed!");
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Apply forwarding action rules. * @brief Apply forwarding action rules.
* *
...@@ -333,7 +333,7 @@ static u32 pfcp_far_apply(struct xdp_md* p_ctx, pfcp_far_t_* p_far) { ...@@ -333,7 +333,7 @@ static u32 pfcp_far_apply(struct xdp_md* p_ctx, pfcp_far_t_* p_far) {
} }
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
SEC("xdp_far") SEC("xdp_far")
int far_entry_point(struct xdp_md* p_ctx) { int far_entry_point(struct xdp_md* p_ctx) {
bpf_debug("==========< FAR CONTEXT >=========="); bpf_debug("==========< FAR CONTEXT >==========");
...@@ -352,4 +352,4 @@ int far_entry_point(struct xdp_md* p_ctx) { ...@@ -352,4 +352,4 @@ int far_entry_point(struct xdp_md* p_ctx) {
} }
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#define ARP_ENTRIES_MAX_SIZE 12 #define ARP_ENTRIES_MAX_SIZE 12
#define FAR_TAILS_MAX 1 #define FAR_TAILS_MAX 1
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The unique FAR that will be consumed in this program. // The unique FAR that will be consumed in this program.
struct bpf_map_def SEC("maps") m_far = { struct bpf_map_def SEC("maps") m_far = {
...@@ -21,7 +21,7 @@ struct bpf_map_def SEC("maps") m_far = { ...@@ -21,7 +21,7 @@ struct bpf_map_def SEC("maps") m_far = {
.max_entries = FAR_TAILS_MAX, // 1, .max_entries = FAR_TAILS_MAX, // 1,
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
struct bpf_map_def SEC("maps") m_redirect_interfaces = { struct bpf_map_def SEC("maps") m_redirect_interfaces = {
.type = BPF_MAP_TYPE_DEVMAP, .type = BPF_MAP_TYPE_DEVMAP,
.key_size = sizeof(u32), // id .key_size = sizeof(u32), // id
...@@ -29,7 +29,7 @@ struct bpf_map_def SEC("maps") m_redirect_interfaces = { ...@@ -29,7 +29,7 @@ struct bpf_map_def SEC("maps") m_redirect_interfaces = {
.max_entries = MAX_INTERFACES, // 10, .max_entries = MAX_INTERFACES, // 10,
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// Static ARP Table. Used to get the MAC address of the next hop. // Static ARP Table. Used to get the MAC address of the next hop.
// TODO: Pin this maps. It does not depend on the session program // TODO: Pin this maps. It does not depend on the session program
// struct bpf_map_def SEC("maps") m_arp_table = { // struct bpf_map_def SEC("maps") m_arp_table = {
...@@ -46,7 +46,7 @@ struct bpf_map_def SEC("maps") m_arp_table = { ...@@ -46,7 +46,7 @@ struct bpf_map_def SEC("maps") m_arp_table = {
.max_entries = ARP_ENTRIES_MAX_SIZE, // 2, .max_entries = ARP_ENTRIES_MAX_SIZE, // 2,
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// BPF_ANNOTATE_KV_PAIR(m_far, u8, pfcp_far_t_); // BPF_ANNOTATE_KV_PAIR(m_far, u8, pfcp_far_t_);
// BPF_ANNOTATE_KV_PAIR(m_redirect_interfaces, u32, u32); // BPF_ANNOTATE_KV_PAIR(m_redirect_interfaces, u32, u32);
// BPF_ANNOTATE_KV_PAIR(m_arp_table, u32, ??); // BPF_ANNOTATE_KV_PAIR(m_arp_table, u32, ??);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#define INTERFACE_ENTRIES_MAX 12 #define INTERFACE_ENTRIES_MAX 12
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
struct bpf_map_def SEC("maps") m_upf_interfaces = { struct bpf_map_def SEC("maps") m_upf_interfaces = {
.type = BPF_MAP_TYPE_HASH, .type = BPF_MAP_TYPE_HASH,
.key_size = sizeof(e_reference_point), .key_size = sizeof(e_reference_point),
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#define INTERFACE_ENTRIES_MAX 12 #define INTERFACE_ENTRIES_MAX 12
#define MAX_UEs 100000 #define MAX_UEs 100000
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// Maps TEID to PFCP_Session_PDR_LookupProgram // Maps TEID to PFCP_Session_PDR_LookupProgram
struct bpf_map_def SEC("maps") m_teid_session = { struct bpf_map_def SEC("maps") m_teid_session = {
...@@ -33,7 +33,7 @@ struct bpf_map_def SEC("maps") m_teid_session = { ...@@ -33,7 +33,7 @@ struct bpf_map_def SEC("maps") m_teid_session = {
.max_entries = MAX_LENGTH, // 10000, //!< TODO: Is it enought? .max_entries = MAX_LENGTH, // 10000, //!< TODO: Is it enought?
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// Maps UE IPv4 address to PFCP_Session_PDR_LookupProgram // Maps UE IPv4 address to PFCP_Session_PDR_LookupProgram
// FIXME: Select a primary key. We could use a hash value of the IP as a key. // FIXME: Select a primary key. We could use a hash value of the IP as a key.
...@@ -47,7 +47,7 @@ struct bpf_map_def SEC("maps") m_ueip_session = { ...@@ -47,7 +47,7 @@ struct bpf_map_def SEC("maps") m_ueip_session = {
.max_entries = MAX_UEs, //!< TODO: Is it enought? .max_entries = MAX_UEs, //!< TODO: Is it enought?
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
struct bpf_map_def SEC("maps") m_ue_ip_pdr = { struct bpf_map_def SEC("maps") m_ue_ip_pdr = {
.type = BPF_MAP_TYPE_HASH, .type = BPF_MAP_TYPE_HASH,
...@@ -56,7 +56,7 @@ struct bpf_map_def SEC("maps") m_ue_ip_pdr = { ...@@ -56,7 +56,7 @@ struct bpf_map_def SEC("maps") m_ue_ip_pdr = {
.max_entries = MAX_UEs, .max_entries = MAX_UEs,
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
struct bpf_map_def SEC("maps") m_next_rule_prog_index = { struct bpf_map_def SEC("maps") m_next_rule_prog_index = {
.type = BPF_MAP_TYPE_HASH, .type = BPF_MAP_TYPE_HASH,
...@@ -65,7 +65,7 @@ struct bpf_map_def SEC("maps") m_next_rule_prog_index = { ...@@ -65,7 +65,7 @@ struct bpf_map_def SEC("maps") m_next_rule_prog_index = {
.max_entries = MAX_LENGTH, // 10, .max_entries = MAX_LENGTH, // 10,
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
struct bpf_map_def SEC("maps") m_upf_interfaces = { struct bpf_map_def SEC("maps") m_upf_interfaces = {
.type = BPF_MAP_TYPE_HASH, .type = BPF_MAP_TYPE_HASH,
...@@ -74,7 +74,7 @@ struct bpf_map_def SEC("maps") m_upf_interfaces = { ...@@ -74,7 +74,7 @@ struct bpf_map_def SEC("maps") m_upf_interfaces = {
.max_entries = INTERFACE_ENTRIES_MAX, // 6, .max_entries = INTERFACE_ENTRIES_MAX, // 6,
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// struct bpf_map_def SEC("maps") m_session_mapping = { // struct bpf_map_def SEC("maps") m_session_mapping = {
// .type = BPF_MAP_TYPE_HASH, // .type = BPF_MAP_TYPE_HASH,
...@@ -91,7 +91,7 @@ struct bpf_map_def SEC("maps") m_session_mapping = { ...@@ -91,7 +91,7 @@ struct bpf_map_def SEC("maps") m_session_mapping = {
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// struct bpf_map_def SEC("maps") m_traffic_classification = { // struct bpf_map_def SEC("maps") m_traffic_classification = {
// .type = BPF_MAP_TYPE_HASH, // .type = BPF_MAP_TYPE_HASH,
...@@ -100,7 +100,7 @@ struct bpf_map_def SEC("maps") m_session_mapping = { ...@@ -100,7 +100,7 @@ struct bpf_map_def SEC("maps") m_session_mapping = {
// .max_entries = MAX_LENGTH, // .max_entries = MAX_LENGTH,
// }; // };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// struct bpf_map_def SEC("maps") m_ue_qfi_teid = { // struct bpf_map_def SEC("maps") m_ue_qfi_teid = {
// .type = BPF_MAP_TYPE_HASH, // .type = BPF_MAP_TYPE_HASH,
...@@ -109,7 +109,7 @@ struct bpf_map_def SEC("maps") m_session_mapping = { ...@@ -109,7 +109,7 @@ struct bpf_map_def SEC("maps") m_session_mapping = {
// .max_entries = MAX_LENGTH, // .max_entries = MAX_LENGTH,
// }; // };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// struct bpf_map_def SEC("maps") m_qos_flow_map = { // struct bpf_map_def SEC("maps") m_qos_flow_map = {
// .type = BPF_MAP_TYPE_HASH, // .type = BPF_MAP_TYPE_HASH,
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define FAR_ENTRIES_MAX_SIZE 5000 // 10 #define FAR_ENTRIES_MAX_SIZE 5000 // 10
#define ARP_ENTRIES_MAX_SIZE 12 #define ARP_ENTRIES_MAX_SIZE 12
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
struct bpf_map_def SEC("maps") m_fars = { struct bpf_map_def SEC("maps") m_fars = {
.type = BPF_MAP_TYPE_HASH, .type = BPF_MAP_TYPE_HASH,
.key_size = sizeof(u32), // teid .key_size = sizeof(u32), // teid
...@@ -21,7 +21,7 @@ struct bpf_map_def SEC("maps") m_fars = { ...@@ -21,7 +21,7 @@ struct bpf_map_def SEC("maps") m_fars = {
.max_entries = FAR_ENTRIES_MAX_SIZE, .max_entries = FAR_ENTRIES_MAX_SIZE,
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
struct bpf_map_def SEC("maps") m_redirect_interfaces = { struct bpf_map_def SEC("maps") m_redirect_interfaces = {
.type = BPF_MAP_TYPE_DEVMAP, .type = BPF_MAP_TYPE_DEVMAP,
.key_size = sizeof(u32), // id .key_size = sizeof(u32), // id
...@@ -29,7 +29,7 @@ struct bpf_map_def SEC("maps") m_redirect_interfaces = { ...@@ -29,7 +29,7 @@ struct bpf_map_def SEC("maps") m_redirect_interfaces = {
.max_entries = MAX_LENGTH, // 10, .max_entries = MAX_LENGTH, // 10,
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// Uplink map. // Uplink map.
// TODO: Store multiple PDR. // TODO: Store multiple PDR.
struct bpf_map_def SEC("maps") m_teid_pdr = { struct bpf_map_def SEC("maps") m_teid_pdr = {
...@@ -39,7 +39,7 @@ struct bpf_map_def SEC("maps") m_teid_pdr = { ...@@ -39,7 +39,7 @@ struct bpf_map_def SEC("maps") m_teid_pdr = {
.max_entries = PDR_ENTRIES_MAX_SIZE, // 10, .max_entries = PDR_ENTRIES_MAX_SIZE, // 10,
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// Downlink map. // Downlink map.
// TODO: Store multiple PDR. // TODO: Store multiple PDR.
struct bpf_map_def SEC("maps") m_ueip_pdr = { struct bpf_map_def SEC("maps") m_ueip_pdr = {
...@@ -49,7 +49,7 @@ struct bpf_map_def SEC("maps") m_ueip_pdr = { ...@@ -49,7 +49,7 @@ struct bpf_map_def SEC("maps") m_ueip_pdr = {
.max_entries = PDR_ENTRIES_MAX_SIZE, // 10, .max_entries = PDR_ENTRIES_MAX_SIZE, // 10,
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// Static ARP Table. Used to get the MAC address of the next hop. // Static ARP Table. Used to get the MAC address of the next hop.
// TODO: Pin this maps. It does not depend on the session program // TODO: Pin this maps. It does not depend on the session program
struct bpf_map_def SEC("maps") m_arp_table = { struct bpf_map_def SEC("maps") m_arp_table = {
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "xdp_stats_kern.h" #include "xdp_stats_kern.h"
#include "xdp_stats_kern_user.h" #include "xdp_stats_kern_user.h"
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
static u32 tail_call_next_prog( static u32 tail_call_next_prog(
struct xdp_md* p_ctx, teid_t_ teid, u8 source_value, u32 ipv4_address) { struct xdp_md* p_ctx, teid_t_ teid, u8 source_value, u32 ipv4_address) {
...@@ -61,7 +61,7 @@ static u32 tail_call_next_prog( ...@@ -61,7 +61,7 @@ static u32 tail_call_next_prog(
return XDP_DROP; return XDP_DROP;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
static u32 handle_downlink_traffic(struct xdp_md* p_ctx, u32 ue_ip_address) { static u32 handle_downlink_traffic(struct xdp_md* p_ctx, u32 ue_ip_address) {
struct session_id* session = NULL; struct session_id* session = NULL;
...@@ -80,7 +80,7 @@ static u32 handle_downlink_traffic(struct xdp_md* p_ctx, u32 ue_ip_address) { ...@@ -80,7 +80,7 @@ static u32 handle_downlink_traffic(struct xdp_md* p_ctx, u32 ue_ip_address) {
return XDP_PASS; return XDP_PASS;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* Uplink SECTION. * Uplink SECTION.
*/ */
...@@ -146,7 +146,7 @@ static u32 handle_uplink_traffic(struct xdp_md* p_ctx, struct udphdr* udph) { ...@@ -146,7 +146,7 @@ static u32 handle_uplink_traffic(struct xdp_md* p_ctx, struct udphdr* udph) {
return XDP_PASS; return XDP_PASS;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* IP SECTION. * IP SECTION.
...@@ -187,7 +187,7 @@ static u32 ipv4_handle(struct xdp_md* p_ctx, struct iphdr* iph) { ...@@ -187,7 +187,7 @@ static u32 ipv4_handle(struct xdp_md* p_ctx, struct iphdr* iph) {
} }
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* ETHERNET SECTION. * ETHERNET SECTION.
*/ */
...@@ -248,7 +248,7 @@ static u32 eth_handle(struct xdp_md* p_ctx, struct ethhdr* ethh) { ...@@ -248,7 +248,7 @@ static u32 eth_handle(struct xdp_md* p_ctx, struct ethhdr* ethh) {
} }
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
SEC("xdp_entry_point") SEC("xdp_entry_point")
int entry_point(struct xdp_md* p_ctx) { int entry_point(struct xdp_md* p_ctx) {
bpf_debug("==========< PFCP Session Lookup >=========="); bpf_debug("==========< PFCP Session Lookup >==========");
...@@ -265,4 +265,4 @@ int entry_point(struct xdp_md* p_ctx) { ...@@ -265,4 +265,4 @@ int entry_point(struct xdp_md* p_ctx) {
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
\ No newline at end of file \ No newline at end of file
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <pfcp_session_lookup_maps.h> #include <pfcp_session_lookup_maps.h>
#include <string.h> //Needed for memcpy #include <string.h> //Needed for memcpy
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// TODO: Put dummy in test folder. // TODO: Put dummy in test folder.
// /** // /**
// * WARNING: Redirect require an XDP bpf_prog loaded on the TX device. // * WARNING: Redirect require an XDP bpf_prog loaded on the TX device.
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
// return XDP_PASS; // return XDP_PASS;
// } // }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// /** // /**
// * @brief Update MAC address // * @brief Update MAC address
// * // *
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
// return XDP_PASS; // return XDP_PASS;
// } // }
// /*****************************************************************************************************************/ // /*---------------------------------------------------------------------------------------------------------------*/
// static u32 create_outer_header_gtpu_ipv4( // static u32 create_outer_header_gtpu_ipv4(
// struct xdp_md* p_ctx, pfcp_far_t_* p_far) { // struct xdp_md* p_ctx, pfcp_far_t_* p_far) {
// bpf_debug("Create Outer Header GTPU_IPv4\n"); // bpf_debug("Create Outer Header GTPU_IPv4\n");
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
// bpf_debug("GTPU header were pushed!\n"); // bpf_debug("GTPU header were pushed!\n");
// } // }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// /** // /**
// * @brief Apply forwarding action rules. // * @brief Apply forwarding action rules.
// * // *
...@@ -321,7 +321,7 @@ ...@@ -321,7 +321,7 @@
// return XDP_PASS; // return XDP_PASS;
// } // }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Match the PDRs attribuites for UL data flow. * @brief Match the PDRs attribuites for UL data flow.
...@@ -365,7 +365,7 @@ static u32 pfcp_pdr_match_pdi_access( ...@@ -365,7 +365,7 @@ static u32 pfcp_pdr_match_pdi_access(
return XDP_PASS; return XDP_PASS;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Match the PDRs attribuites for DL data flow. * @brief Match the PDRs attribuites for DL data flow.
* - Destination IP from IP header with source address stored in PDI. * - Destination IP from IP header with source address stored in PDI.
...@@ -407,7 +407,7 @@ static u32 pfcp_pdr_match_pdi_downlink( ...@@ -407,7 +407,7 @@ static u32 pfcp_pdr_match_pdi_downlink(
return XDP_PASS; return XDP_PASS;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
static u32 tail_call_next_prog( static u32 tail_call_next_prog(
struct xdp_md* p_ctx, teid_t_ teid, u8 source_value, u32 ipv4_address) { struct xdp_md* p_ctx, teid_t_ teid, u8 source_value, u32 ipv4_address) {
struct next_rule_prog_index_key map_key; struct next_rule_prog_index_key map_key;
...@@ -440,7 +440,7 @@ static u32 tail_call_next_prog( ...@@ -440,7 +440,7 @@ static u32 tail_call_next_prog(
return 0; return 0;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Lookup all PDRs based on teid. * @brief Lookup all PDRs based on teid.
* After that, for each PDR, check the its attribuites with match with access * After that, for each PDR, check the its attribuites with match with access
...@@ -510,7 +510,7 @@ static u32 pfcp_pdr_lookup_uplink(struct xdp_md* p_ctx) { ...@@ -510,7 +510,7 @@ static u32 pfcp_pdr_lookup_uplink(struct xdp_md* p_ctx) {
return XDP_DROP; // XDP_PASS; return XDP_DROP; // XDP_PASS;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Lookup all PDRs based on IP. * @brief Lookup all PDRs based on IP.
* After that, for each PDR, check the its attribuites with match with access * After that, for each PDR, check the its attribuites with match with access
...@@ -575,7 +575,7 @@ static u32 pfcp_pdr_lookup_downlink(struct xdp_md* p_ctx) { ...@@ -575,7 +575,7 @@ static u32 pfcp_pdr_lookup_downlink(struct xdp_md* p_ctx) {
bpf_debug("FAR was NOT Found\n"); bpf_debug("FAR was NOT Found\n");
return XDP_DROP; // XDP_PASS; return XDP_DROP; // XDP_PASS;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
SEC("xdp_uplink_entry_point") SEC("xdp_uplink_entry_point")
int uplink_entry_point(struct xdp_md* p_ctx) { int uplink_entry_point(struct xdp_md* p_ctx) {
...@@ -590,4 +590,4 @@ int downlink_entry_point(struct xdp_md* p_ctx) { ...@@ -590,4 +590,4 @@ int downlink_entry_point(struct xdp_md* p_ctx) {
} }
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
// } // }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Filter the Uplink traffic * @brief Filter the Uplink traffic
* *
...@@ -260,7 +260,7 @@ static __always_inline u32 uplink_sdf_filter(struct __sk_buff *skb, struct ethhd ...@@ -260,7 +260,7 @@ static __always_inline u32 uplink_sdf_filter(struct __sk_buff *skb, struct ethhd
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
static __always_inline u32 downlink_sdf_filter(struct __sk_buff *skb, struct ethhdr* ethh, struct iphdr* iph) { static __always_inline u32 downlink_sdf_filter(struct __sk_buff *skb, struct ethhdr* ethh, struct iphdr* iph) {
void* data_end = (void*) (long) skb->data_end; void* data_end = (void*) (long) skb->data_end;
...@@ -336,7 +336,7 @@ static __always_inline u32 downlink_sdf_filter(struct __sk_buff *skb, struct eth ...@@ -336,7 +336,7 @@ static __always_inline u32 downlink_sdf_filter(struct __sk_buff *skb, struct eth
return TC_ACT_OK; return TC_ACT_OK;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* IP SECTION. * IP SECTION.
*/ */
...@@ -374,7 +374,7 @@ static __always_inline u32 ipv4_sdf_filter(struct __sk_buff *skb, struct ethhdr* ...@@ -374,7 +374,7 @@ static __always_inline u32 ipv4_sdf_filter(struct __sk_buff *skb, struct ethhdr*
} }
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Filter traffic according to ETH_TYPE * @brief Filter traffic according to ETH_TYPE
...@@ -428,7 +428,7 @@ static __always_inline u32 sdf_filter(struct __sk_buff *skb, struct ethhdr* ethh ...@@ -428,7 +428,7 @@ static __always_inline u32 sdf_filter(struct __sk_buff *skb, struct ethhdr* ethh
} }
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief sections to be ran as eBPF tc code * @brief sections to be ran as eBPF tc code
...@@ -533,4 +533,4 @@ int egress_filter_entry_point(struct __sk_buff *skb) { ...@@ -533,4 +533,4 @@ int egress_filter_entry_point(struct __sk_buff *skb) {
} }
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#define QFI_MAX_ENTRIES 5000 #define QFI_MAX_ENTRIES 5000
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
struct bpf_map_def SEC("maps") m_gtp_u_tunnel = { struct bpf_map_def SEC("maps") m_gtp_u_tunnel = {
.type = BPF_MAP_TYPE_HASH, .type = BPF_MAP_TYPE_HASH,
.key_size = sizeof(struct gtp_u_tunnel), // < teid_ul, teid_dl > .key_size = sizeof(struct gtp_u_tunnel), // < teid_ul, teid_dl >
...@@ -18,16 +18,12 @@ struct bpf_map_def SEC("maps") m_gtp_u_tunnel = { ...@@ -18,16 +18,12 @@ struct bpf_map_def SEC("maps") m_gtp_u_tunnel = {
.max_entries = QFI_MAX_ENTRIES, .max_entries = QFI_MAX_ENTRIES,
}; };
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
struct bpf_map_def SEC("maps") m_filter = { struct bpf_map_def SEC("maps") m_filter = {
.type = BPF_MAP_TYPE_HASH, .type = BPF_MAP_TYPE_HASH,
.key_size = sizeof(struct filter_key), .key_size = sizeof(struct filter_key), // < src_ip, dst_ip, protocol, dst_port >
.value_size = sizeof(e_qfi), .value_size = sizeof(e_qfi), // QFI
.max_entries = QFI_MAX_ENTRIES, .max_entries = QFI_MAX_ENTRIES,
}; };
#endif // __QER_MAPS_H__ #endif // __QER_MAPS_H__
\ No newline at end of file
message("Searching for Linux netlink library")
if (LibNL_FIND_REQUIRED)
message(" (required)")
else (LibNL_FIND_REQUIRED)
message(" (not required)")
endif (LibNL_FIND_REQUIRED)
find_path(LibNL_INCLUDE_DIR netlink/netlink.h
/usr/include
/usr/include/libnl3
/usr/local/include
/usr/local/include/libnl3
)
find_library(LibNL_LIBRARY NAMES nl nl-3)
find_library(LibNL_ROUTE_LIBRARY NAMES nl-route nl-route-3)
find_library(LibNL_NETFILTER_LIBRARY NAMES nl-nf nl-nf-3)
find_library(LibNL_GENL_LIBRARY NAMES nl-genl nl-genl-3)
if (LibNL_INCLUDE_DIR AND LibNL_LIBRARY)
set(LibNL_FOUND TRUE)
endif (LibNL_INCLUDE_DIR AND LibNL_LIBRARY)
if (LibNL_FOUND)
if (NOT LibNL_FIND_QUIETLY)
set(LibNL_LIBRARIES ${LibNL_LIBRARY} ${LibNL_ROUTE_LIBRARY} ${LibNL_NETFILTER_LIBRARY} ${LibNL_GENL_LIBRARY})
message("Found netlink libraries: ${LibNL_LIBRARIES}")
message("Found netlink includes: ${LibNL_INCLUDE_DIR}")
endif (NOT LibNL_FIND_QUIETLY)
ELSE (LibNL_FOUND)
if (LibNL_FIND_REQUIRED)
message("Netlink version 3 development packages cannot be found.")
message("In Debian/Ubuntu, they may be called:")
message("libnl-3-dev libnl-genl-3dev libnl-nf-3-dev libnl-route-3-dev")
message(FATAL_ERROR "Could not find netlink library.")
endif (LibNL_FIND_REQUIRED)
endif (LibNL_FOUND)
#include "GetNicInformation.hpp"
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <types.h>
#include <arpa/inet.h>
#include <netinet/ether.h>
#include <fstream>
#include <string>
#include <stdexcept>
#include <arpa/inet.h>
#define COMMAND_MAX_LENGTH 256
#define OUTPUT_MAX_LENGTH 256
/*---------------------------------------------------------------------------------------------------------------*/
// Function to read a value from a file
std::string readValueFromFile(const std::string& path) {
std::ifstream file(path);
if (!file.is_open()) {
std::cerr << "Error: Failed to open file " << path << std::endl;
return "";
}
std::string value;
file >> value;
file.close();
return value;
}
NicInfromationGetter::NicInfromationGetter() {}
/*---------------------------------------------------------------------------------------------------------------*/
// const char *NicInfromationGetter::setScheduler(const char*) {
// }
/*---------------------------------------------------------------------------------------------------------------*/
uint32_t NicInfromationGetter::retrieveRate(std::string interface) {
// Paths to files containing interface information speed rate
std::string speedPath = INTERFACE_DIR + interface + "/speed";
// Read speed
std::string speed = readValueFromFile(speedPath);
uint32_t rate = 0;
std::istringstream iss(speed);
iss >> rate;
return rate;
}
/*---------------------------------------------------------------------------------------------------------------*/
uint32_t NicInfromationGetter::retrieveCeil(std::string interface) {
// Paths to files containing interface information speed rate
std::string speedPath = INTERFACE_DIR + interface + "/speed";
// Read speed
std::string speed = readValueFromFile(speedPath);
uint32_t ceil = 0;
std::istringstream iss(speed);
iss >> ceil;
return ceil;
}
uint32_t NicInfromationGetter::retrieveCeil(std::string interface) {
return NicInfromationGetter::retrieveRate(interface);
}
/*---------------------------------------------------------------------------------------------------------------*/
uint32_t NicInfromationGetter::retrieveRateBuffer(std::string interface) {
// char command[COMMAND_MAX_LENGTH];
// struct in_addr addr;
// addr.s_addr = next_hop_ip;
// char* ipAddress = inet_ntoa(addr);
// if (ipAddress == nullptr) {
// Logger::upf_app().error("The Next Hop IPv4 WAS NOT Retrieved");
// throw std::runtime_error("The Next Hop IPv4 WAS NOT Retrieved");
// }
// sprintf(command, "sudo arping -c 1 %s | awk '/from/ {print $4}'", ipAddress);
// // Logger::upf_app().debug("Next Hop SRC IP = %s", ipAddress);
// Logger::upf_app().debug(
// "Next Hop <SRC IP, MAC Address> = <%s, %s>", ipAddress,
// executeCommand(command).c_str());
// ether_addr* next_hop_mac = {};
// next_hop_mac = ether_aton(executeCommand(command).c_str());
// if (next_hop_mac == nullptr) {
// Logger::upf_app().error("The Next Hop MAC WAS NOT Retrieved");
// throw std::runtime_error("The Next Hop MAC WAS NOT Retrieved");
// }
// return next_hop_mac;
}
/*---------------------------------------------------------------------------------------------------------------*/
uint32_t NicInfromationGetter::retrieveCeilBuffer(std::string interface) {
}
/*---------------------------------------------------------------------------------------------------------------*/
std::string NicInfromationGetter::executeCommand(const std::string& command) {
char output[OUTPUT_MAX_LENGTH];
FILE* fp = popen(command.c_str(), "r");
if (fp == nullptr) {
Logger::upf_app().error("Failed to Run the Command: %s\n", command.c_str());
return "";
}
fgets(output, OUTPUT_MAX_LENGTH, fp);
pclose(fp);
return output;
}
/*---------------------------------------------------------------------------------------------------------------*/
#ifndef __Get_NIC_INFORMATION_HPP__
#define __Get_NIC_INFORMATION_HPP__
#include <string>
#include <memory>
#include <netinet/ether.h>
#include "logger.hpp"
class NicInfromationGetter {
public:
/**
* @brief Construct a new Nic Information Getter object
*
*/
NicInformationGetter();
/*---------------------------------------------------------------------------------------------------------------*/
/**
* @brief Set the Scheduler object
*
* @return const char*
*/
//const char *setScheduler(const char*);
/*---------------------------------------------------------------------------------------------------------------*/
/**
* @brief Retrieve the Transmission Rate of NIC
*
* @return uint32_t rate
*/
uint32_t retrieveRate(std::string interface);
/*---------------------------------------------------------------------------------------------------------------*/
/**
* @brief Retrieve the Ceil transmission of NIC
*
* @return uint32_t ceil
*/
uint32_t retrieveCeil(std::string interface);
/*---------------------------------------------------------------------------------------------------------------*/
/**
* @brief Retrieve the Rate Buffer of the NIC
*
* @return uint32_t rate_buffer
*/
uint32_t retrieveRateBuffer(std::string interface);
/*---------------------------------------------------------------------------------------------------------------*/
/**
* @brief Retrieve the Ceil Buffer of the NIC
*
* @return uint32_t ceil_buffer
*/
uint32_t retrieveCeilBuffer(std::string interface);
/*---------------------------------------------------------------------------------------------------------------*/
private:
const std::string INTERFACE_DIR = "/sys/class/net/";
//std::string executeCommand(const std::string& command);
};
#endif //__Get_NIC_INFORMATION_HPP__
\ No newline at end of file
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
#define COMMAND_MAX_LENGTH 256 #define COMMAND_MAX_LENGTH 256
#define OUTPUT_MAX_LENGTH 256 #define OUTPUT_MAX_LENGTH 256
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
NextHopFinder::NextHopFinder() {} NextHopFinder::NextHopFinder() {}
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
int NextHopFinder::calculateSubnetMask(uint32_t ip) { int NextHopFinder::calculateSubnetMask(uint32_t ip) {
int mask = 0; int mask = 0;
uint32_t temp = ip; uint32_t temp = ip;
...@@ -35,7 +35,7 @@ int NextHopFinder::calculateSubnetMask(uint32_t ip) { ...@@ -35,7 +35,7 @@ int NextHopFinder::calculateSubnetMask(uint32_t ip) {
return mask; return mask;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
int NextHopFinder::sameSubnet(uint32_t ip1, uint32_t ip2) { int NextHopFinder::sameSubnet(uint32_t ip1, uint32_t ip2) {
int subnet_mask = calculateSubnetMask(ip1); int subnet_mask = calculateSubnetMask(ip1);
uint32_t mask = 0xFFFFFFFFU << (32 - subnet_mask); uint32_t mask = 0xFFFFFFFFU << (32 - subnet_mask);
...@@ -43,7 +43,7 @@ int NextHopFinder::sameSubnet(uint32_t ip1, uint32_t ip2) { ...@@ -43,7 +43,7 @@ int NextHopFinder::sameSubnet(uint32_t ip1, uint32_t ip2) {
return (ip1 & mask) == (ip2 & mask); return (ip1 & mask) == (ip2 & mask);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
u_int32_t NextHopFinder::retrieveNextHopIP(uint32_t destination_ip) { u_int32_t NextHopFinder::retrieveNextHopIP(uint32_t destination_ip) {
char command[COMMAND_MAX_LENGTH]; char command[COMMAND_MAX_LENGTH];
...@@ -67,7 +67,7 @@ u_int32_t NextHopFinder::retrieveNextHopIP(uint32_t destination_ip) { ...@@ -67,7 +67,7 @@ u_int32_t NextHopFinder::retrieveNextHopIP(uint32_t destination_ip) {
return next_hop_ip; return next_hop_ip;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
ether_addr* NextHopFinder::retrieveNextHopMAC(uint32_t next_hop_ip) { ether_addr* NextHopFinder::retrieveNextHopMAC(uint32_t next_hop_ip) {
char command[COMMAND_MAX_LENGTH]; char command[COMMAND_MAX_LENGTH];
...@@ -98,7 +98,7 @@ ether_addr* NextHopFinder::retrieveNextHopMAC(uint32_t next_hop_ip) { ...@@ -98,7 +98,7 @@ ether_addr* NextHopFinder::retrieveNextHopMAC(uint32_t next_hop_ip) {
return next_hop_mac; return next_hop_mac;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::string NextHopFinder::executeCommand(const std::string& command) { std::string NextHopFinder::executeCommand(const std::string& command) {
char output[OUTPUT_MAX_LENGTH]; char output[OUTPUT_MAX_LENGTH];
FILE* fp = popen(command.c_str(), "r"); FILE* fp = popen(command.c_str(), "r");
...@@ -113,4 +113,4 @@ std::string NextHopFinder::executeCommand(const std::string& command) { ...@@ -113,4 +113,4 @@ std::string NextHopFinder::executeCommand(const std::string& command) {
return output; return output;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
#ifndef __QDISC_PARAMETERS_H__
#define __QDISC_PARAMETERS_H__
#include <types.h>
struct qdisc_params {
const char *scheduler;
uint32_t rate;
uint32_t ceil;
uint32_t rate_buffer;
uint32_t ceil_buffer;
// uint32_t quantum;
// int level;
};
#endif //__QDISC_PARAMETERS_H__
\ No newline at end of file
#include "BPFProgram.h" #include "BPFProgram.h"
#include "logger.hpp" #include "logger.hpp"
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
u_int32_t BPFProgram::sIdCounter = 1; u_int32_t BPFProgram::sIdCounter = 1;
BPFProgram::BPFProgram(/* args */) : mId(sIdCounter) { BPFProgram::BPFProgram(/* args */) : mId(sIdCounter) {
sIdCounter++; sIdCounter++;
Logger::upf_app().info("BPFProgram %d is created!!!", mId); Logger::upf_app().info("BPFProgram %d is created!!!", mId);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
BPFProgram::~BPFProgram() {} BPFProgram::~BPFProgram() {}
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
uint32_t BPFProgram::getId() const { uint32_t BPFProgram::getId() const {
return mId; return mId;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
\ No newline at end of file \ No newline at end of file
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
using namespace oai::config; using namespace oai::config;
extern upf_config upf_cfg; extern upf_config upf_cfg;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
FARProgram::FARProgram() : BPFProgram() { FARProgram::FARProgram() : BPFProgram() {
mpLifeCycle = std::make_shared<FARProgramLifeCycle>( mpLifeCycle = std::make_shared<FARProgramLifeCycle>(
far_ebpf_xdp_prgrm_kernel_c__open, far_ebpf_xdp_prgrm_kernel_c__load, far_ebpf_xdp_prgrm_kernel_c__open, far_ebpf_xdp_prgrm_kernel_c__load,
...@@ -20,10 +20,10 @@ FARProgram::FARProgram() : BPFProgram() { ...@@ -20,10 +20,10 @@ FARProgram::FARProgram() : BPFProgram() {
far_ebpf_xdp_prgrm_kernel_c__destroy); far_ebpf_xdp_prgrm_kernel_c__destroy);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
FARProgram::~FARProgram() {} FARProgram::~FARProgram() {}
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void FARProgram::create_upf_interface_map_entry(e_reference_point s) { void FARProgram::create_upf_interface_map_entry(e_reference_point s) {
struct s_interface iface; struct s_interface iface;
__builtin_memset(&iface, 0, sizeof(s_interface)); __builtin_memset(&iface, 0, sizeof(s_interface));
...@@ -61,7 +61,7 @@ void FARProgram::create_upf_interface_map_entry(e_reference_point s) { ...@@ -61,7 +61,7 @@ void FARProgram::create_upf_interface_map_entry(e_reference_point s) {
} }
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void FARProgram::setup() { void FARProgram::setup() {
spSkeleton = mpLifeCycle->open(); spSkeleton = mpLifeCycle->open();
initializeMaps(); initializeMaps();
...@@ -84,44 +84,44 @@ void FARProgram::setup() { ...@@ -84,44 +84,44 @@ void FARProgram::setup() {
create_upf_interface_map_entry(N4_INTERFACE); create_upf_interface_map_entry(N4_INTERFACE);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMaps> FARProgram::getMaps() { std::shared_ptr<BPFMaps> FARProgram::getMaps() {
return mpMaps; return mpMaps;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// TODO: Check when kill when running. // TODO: Check when kill when running.
// It was noted the infinity loop. // It was noted the infinity loop.
void FARProgram::tearDown() { void FARProgram::tearDown() {
mpLifeCycle->tearDown(); mpLifeCycle->tearDown();
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> FARProgram::getFARMap() const { std::shared_ptr<BPFMap> FARProgram::getFARMap() const {
return mpFARMap; return mpFARMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> FARProgram::getEgressInterfaceMap() const { std::shared_ptr<BPFMap> FARProgram::getEgressInterfaceMap() const {
return mpEgressInterfaceMap; return mpEgressInterfaceMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
int FARProgram::getFd() const { int FARProgram::getFd() const {
return bpf_program__fd(mpLifeCycle->getBPFSkeleton()->progs.far_entry_point); return bpf_program__fd(mpLifeCycle->getBPFSkeleton()->progs.far_entry_point);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> FARProgram::getArpTableMap() const { std::shared_ptr<BPFMap> FARProgram::getArpTableMap() const {
return mpArpTableMap; return mpArpTableMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> FARProgram::getIfaceMap() const { std::shared_ptr<BPFMap> FARProgram::getIfaceMap() const {
return mpUPFIfaceMap; return mpUPFIfaceMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void FARProgram::initializeMaps() { void FARProgram::initializeMaps() {
// Store all maps available in the program. // Store all maps available in the program.
mpMaps = std::make_shared<BPFMaps>(mpLifeCycle->getBPFSkeleton()->skeleton); mpMaps = std::make_shared<BPFMaps>(mpLifeCycle->getBPFSkeleton()->skeleton);
...@@ -133,4 +133,4 @@ void FARProgram::initializeMaps() { ...@@ -133,4 +133,4 @@ void FARProgram::initializeMaps() {
std::make_shared<BPFMap>(mpMaps->getMap("m_redirect_interfaces")); std::make_shared<BPFMap>(mpMaps->getMap("m_redirect_interfaces"));
mpUPFIfaceMap = std::make_shared<BPFMap>(mpMaps->getMap("m_upf_interfaces")); mpUPFIfaceMap = std::make_shared<BPFMap>(mpMaps->getMap("m_upf_interfaces"));
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
\ No newline at end of file \ No newline at end of file
...@@ -32,20 +32,20 @@ class FARProgram : public BPFProgram { ...@@ -32,20 +32,20 @@ class FARProgram : public BPFProgram {
*/ */
explicit FARProgram(); explicit FARProgram();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Destroy the FARProgram object * @brief Destroy the FARProgram object
*/ */
virtual ~FARProgram(); virtual ~FARProgram();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Insert one UPF reference point interface into a map. * @brief Insert one UPF reference point interface into a map.
* *
*/ */
void create_upf_interface_map_entry(e_reference_point s); void create_upf_interface_map_entry(e_reference_point s);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Setup the BPF program. * @brief Setup the BPF program.
...@@ -53,7 +53,7 @@ class FARProgram : public BPFProgram { ...@@ -53,7 +53,7 @@ class FARProgram : public BPFProgram {
*/ */
void setup(); void setup();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the BPFMaps object. * @brief Get the BPFMaps object.
* *
...@@ -61,13 +61,13 @@ class FARProgram : public BPFProgram { ...@@ -61,13 +61,13 @@ class FARProgram : public BPFProgram {
*/ */
std::shared_ptr<BPFMaps> getMaps(); std::shared_ptr<BPFMaps> getMaps();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Tear downs the BPF program. * @brief Tear downs the BPF program.
* *
*/ */
void tearDown(); void tearDown();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Update program int map. * @brief Update program int map.
...@@ -77,7 +77,7 @@ class FARProgram : public BPFProgram { ...@@ -77,7 +77,7 @@ class FARProgram : public BPFProgram {
*/ */
void updateProgramMap(uint32_t key, uint32_t fd); void updateProgramMap(uint32_t key, uint32_t fd);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Remove program in map. * @brief Remove program in map.
* *
...@@ -85,7 +85,7 @@ class FARProgram : public BPFProgram { ...@@ -85,7 +85,7 @@ class FARProgram : public BPFProgram {
*/ */
void removeProgramMap(uint32_t key); void removeProgramMap(uint32_t key);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the TEID to session Map object. * @brief Get the TEID to session Map object.
* *
...@@ -93,7 +93,7 @@ class FARProgram : public BPFProgram { ...@@ -93,7 +93,7 @@ class FARProgram : public BPFProgram {
*/ */
std::shared_ptr<BPFMap> getFARMap() const; std::shared_ptr<BPFMap> getFARMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Egress Interface Map object. * @brief Get the Egress Interface Map object.
* *
...@@ -101,7 +101,7 @@ class FARProgram : public BPFProgram { ...@@ -101,7 +101,7 @@ class FARProgram : public BPFProgram {
*/ */
std::shared_ptr<BPFMap> getEgressInterfaceMap() const; std::shared_ptr<BPFMap> getEgressInterfaceMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Arp Table Map object. * @brief Get the Arp Table Map object.
* *
...@@ -109,7 +109,7 @@ class FARProgram : public BPFProgram { ...@@ -109,7 +109,7 @@ class FARProgram : public BPFProgram {
*/ */
std::shared_ptr<BPFMap> getArpTableMap() const; std::shared_ptr<BPFMap> getArpTableMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the iface Map object. * @brief Get the iface Map object.
* *
...@@ -117,7 +117,7 @@ class FARProgram : public BPFProgram { ...@@ -117,7 +117,7 @@ class FARProgram : public BPFProgram {
*/ */
std::shared_ptr<BPFMap> getIfaceMap() const; std::shared_ptr<BPFMap> getIfaceMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the File Descriptor. * @brief Get the File Descriptor.
* *
...@@ -125,7 +125,7 @@ class FARProgram : public BPFProgram { ...@@ -125,7 +125,7 @@ class FARProgram : public BPFProgram {
*/ */
int getFd() const; int getFd() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
private: private:
/** /**
* @brief Initialize BPF wrappers maps. * @brief Initialize BPF wrappers maps.
...@@ -133,35 +133,35 @@ class FARProgram : public BPFProgram { ...@@ -133,35 +133,35 @@ class FARProgram : public BPFProgram {
*/ */
void initializeMaps(); void initializeMaps();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The reference of the bpf maps. // The reference of the bpf maps.
std::shared_ptr<BPFMaps> mpMaps; std::shared_ptr<BPFMaps> mpMaps;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The skeleton of the UPF program generated by bpftool. // The skeleton of the UPF program generated by bpftool.
// ProgramLifeCycle is the owner of the pointer. // ProgramLifeCycle is the owner of the pointer.
far_ebpf_xdp_prgrm_kernel_c* spSkeleton; far_ebpf_xdp_prgrm_kernel_c* spSkeleton;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The program eBPF map. // The program eBPF map.
std::shared_ptr<BPFMap> mpFARMap; std::shared_ptr<BPFMap> mpFARMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The egress interface map. // The egress interface map.
std::shared_ptr<BPFMap> mpEgressInterfaceMap; std::shared_ptr<BPFMap> mpEgressInterfaceMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The arp table map. // The arp table map.
std::shared_ptr<BPFMap> mpArpTableMap; std::shared_ptr<BPFMap> mpArpTableMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The BPF lifecycle program. // The BPF lifecycle program.
std::shared_ptr<FARProgramLifeCycle> mpLifeCycle; std::shared_ptr<FARProgramLifeCycle> mpLifeCycle;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The iface map. // The iface map.
std::shared_ptr<BPFMap> mpUPFIfaceMap; std::shared_ptr<BPFMap> mpUPFIfaceMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
}; };
#endif // __FAR_EBPF_XDP_PRGRM_USER_H__ #endif // __FAR_EBPF_XDP_PRGRM_USER_H__
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
// //#define DSCP_8 8 // 001000 // //#define DSCP_8 8 // 001000
// #define DSCP_DEFAULT 0 // 000000 // #define DSCP_DEFAULT 0 // 000000
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
int is_little_endian2() { int is_little_endian2() {
u32 value = 1; u32 value = 1;
...@@ -52,7 +52,7 @@ int is_little_endian2() { ...@@ -52,7 +52,7 @@ int is_little_endian2() {
return (*byte == 1); return (*byte == 1);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
PFCP_Session_LookupProgram::PFCP_Session_LookupProgram( PFCP_Session_LookupProgram::PFCP_Session_LookupProgram(
const std::string& gtpInterface, const std::string& udpInterface) const std::string& gtpInterface, const std::string& udpInterface)
: mGTPInterface(gtpInterface), mUDPInterface(udpInterface) { : mGTPInterface(gtpInterface), mUDPInterface(udpInterface) {
...@@ -63,10 +63,10 @@ PFCP_Session_LookupProgram::PFCP_Session_LookupProgram( ...@@ -63,10 +63,10 @@ PFCP_Session_LookupProgram::PFCP_Session_LookupProgram(
pfcp_session_lookup_ebpf_xdp_prgrm_kernel_c__destroy); pfcp_session_lookup_ebpf_xdp_prgrm_kernel_c__destroy);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
PFCP_Session_LookupProgram::~PFCP_Session_LookupProgram() {} PFCP_Session_LookupProgram::~PFCP_Session_LookupProgram() {}
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void PFCP_Session_LookupProgram::setup() { void PFCP_Session_LookupProgram::setup() {
spSkeleton = mpLifeCycle->open(); spSkeleton = mpLifeCycle->open();
initializeMaps(); initializeMaps();
...@@ -100,24 +100,24 @@ void PFCP_Session_LookupProgram::setup() { ...@@ -100,24 +100,24 @@ void PFCP_Session_LookupProgram::setup() {
// NON_GBR, QOS_DEFAULT, QFI_DEFALUT, DSCP_DEFAULT); // NON_GBR, QOS_DEFAULT, QFI_DEFALUT, DSCP_DEFAULT);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMaps> PFCP_Session_LookupProgram::getMaps() { std::shared_ptr<BPFMaps> PFCP_Session_LookupProgram::getMaps() {
return mpMaps; return mpMaps;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// TODO: Check when kill when running. // TODO: Check when kill when running.
// It was noted the infinity loop. // It was noted the infinity loop.
void PFCP_Session_LookupProgram::tearDown() { void PFCP_Session_LookupProgram::tearDown() {
mpLifeCycle->tearDown(); mpLifeCycle->tearDown();
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void PFCP_Session_LookupProgram::updateProgramMap(uint32_t key, uint32_t fd) { void PFCP_Session_LookupProgram::updateProgramMap(uint32_t key, uint32_t fd) {
mpTeidSessionMap->update(key, fd, BPF_ANY); mpTeidSessionMap->update(key, fd, BPF_ANY);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void PFCP_Session_LookupProgram::removeProgramMap(uint32_t key) { void PFCP_Session_LookupProgram::removeProgramMap(uint32_t key) {
s32 fd; s32 fd;
// Remove only if exists. // Remove only if exists.
...@@ -126,52 +126,52 @@ void PFCP_Session_LookupProgram::removeProgramMap(uint32_t key) { ...@@ -126,52 +126,52 @@ void PFCP_Session_LookupProgram::removeProgramMap(uint32_t key) {
} }
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getTeidSessionMap() const { std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getTeidSessionMap() const {
return mpTeidSessionMap; return mpTeidSessionMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getUeIpSessionMap() const { std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getUeIpSessionMap() const {
return mpUeIpSessionMap; return mpUeIpSessionMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getNextProgRuleMap() const { std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getNextProgRuleMap() const {
return mpNextProgRuleMap; return mpNextProgRuleMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getNextProgRuleIndexMap() std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getNextProgRuleIndexMap()
const { const {
return mpNextProgRuleIndexMap; return mpNextProgRuleIndexMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getSessionMappingMap() std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getSessionMappingMap()
const { const {
return mpSessionMappingMap; return mpSessionMappingMap;
} }
// /*****************************************************************************************************************/ // /*---------------------------------------------------------------------------------------------------------------*/
// std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getTrafficMap() const { // std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getTrafficMap() const {
// return mpTrafficMap; // return mpTrafficMap;
// } // }
// /*****************************************************************************************************************/ // /*---------------------------------------------------------------------------------------------------------------*/
// std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getUeQfiTeidMap() const { // std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getUeQfiTeidMap() const {
// return mpUeQfiTeidMap; // return mpUeQfiTeidMap;
// } // }
// /*****************************************************************************************************************/ // /*---------------------------------------------------------------------------------------------------------------*/
// std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getQosFlowMap() const { // std::shared_ptr<BPFMap> PFCP_Session_LookupProgram::getQosFlowMap() const {
// return mpQosFlowMap; // return mpQosFlowMap;
// } // }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void PFCP_Session_LookupProgram::initializeMaps() { void PFCP_Session_LookupProgram::initializeMaps() {
// Store all maps available in the program. // Store all maps available in the program.
...@@ -193,7 +193,7 @@ void PFCP_Session_LookupProgram::initializeMaps() { ...@@ -193,7 +193,7 @@ void PFCP_Session_LookupProgram::initializeMaps() {
// std::make_shared<BPFMap>(mpMaps->getMap("m_qos_flow_map")); // std::make_shared<BPFMap>(mpMaps->getMap("m_qos_flow_map"));
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// void PFCP_Session_LookupProgram::instrementQfiFlowMappingTable( // void PFCP_Session_LookupProgram::instrementQfiFlowMappingTable(
// e_resource_type type, uint32_t qos, uint8_t qfi, uint8_t dscp) { // e_resource_type type, uint32_t qos, uint8_t qfi, uint8_t dscp) {
......
...@@ -31,20 +31,20 @@ class PFCP_Session_LookupProgram { ...@@ -31,20 +31,20 @@ class PFCP_Session_LookupProgram {
explicit PFCP_Session_LookupProgram( explicit PFCP_Session_LookupProgram(
const std::string& gtpInterface, const std::string& udpInterface); const std::string& gtpInterface, const std::string& udpInterface);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Destroy the PFCP_Session_LookupProgram object * @brief Destroy the PFCP_Session_LookupProgram object
*/ */
virtual ~PFCP_Session_LookupProgram(); virtual ~PFCP_Session_LookupProgram();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Setup the BPF program. * @brief Setup the BPF program.
* *
*/ */
void setup(); void setup();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the BPFMaps object. * @brief Get the BPFMaps object.
* *
...@@ -52,14 +52,14 @@ class PFCP_Session_LookupProgram { ...@@ -52,14 +52,14 @@ class PFCP_Session_LookupProgram {
*/ */
std::shared_ptr<BPFMaps> getMaps(); std::shared_ptr<BPFMaps> getMaps();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Tear downs the BPF program. * @brief Tear downs the BPF program.
* *
*/ */
void tearDown(); void tearDown();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Update program int map. * @brief Update program int map.
* *
...@@ -68,7 +68,7 @@ class PFCP_Session_LookupProgram { ...@@ -68,7 +68,7 @@ class PFCP_Session_LookupProgram {
*/ */
void updateProgramMap(uint32_t key, uint32_t fd); void updateProgramMap(uint32_t key, uint32_t fd);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Remove program in map. * @brief Remove program in map.
* *
...@@ -76,7 +76,7 @@ class PFCP_Session_LookupProgram { ...@@ -76,7 +76,7 @@ class PFCP_Session_LookupProgram {
*/ */
void removeProgramMap(uint32_t key); void removeProgramMap(uint32_t key);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the TEID to session Map object. * @brief Get the TEID to session Map object.
* *
...@@ -84,7 +84,7 @@ class PFCP_Session_LookupProgram { ...@@ -84,7 +84,7 @@ class PFCP_Session_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getTeidSessionMap() const; std::shared_ptr<BPFMap> getTeidSessionMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the UE IP to session Map object. * @brief Get the UE IP to session Map object.
* *
...@@ -92,7 +92,7 @@ class PFCP_Session_LookupProgram { ...@@ -92,7 +92,7 @@ class PFCP_Session_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getUeIpSessionMap() const; std::shared_ptr<BPFMap> getUeIpSessionMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the NextProgRule Map object. * @brief Get the NextProgRule Map object.
* *
...@@ -100,7 +100,7 @@ class PFCP_Session_LookupProgram { ...@@ -100,7 +100,7 @@ class PFCP_Session_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getNextProgRuleMap() const; std::shared_ptr<BPFMap> getNextProgRuleMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the NextProgRuleIndex Map object. * @brief Get the NextProgRuleIndex Map object.
* *
...@@ -108,7 +108,7 @@ class PFCP_Session_LookupProgram { ...@@ -108,7 +108,7 @@ class PFCP_Session_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getNextProgRuleIndexMap() const; std::shared_ptr<BPFMap> getNextProgRuleIndexMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Traffic Map object. * @brief Get the Traffic Map object.
* *
...@@ -116,7 +116,7 @@ class PFCP_Session_LookupProgram { ...@@ -116,7 +116,7 @@ class PFCP_Session_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getTrafficMap() const; std::shared_ptr<BPFMap> getTrafficMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Session Mapping Map object. * @brief Get the Session Mapping Map object.
* *
...@@ -124,7 +124,7 @@ class PFCP_Session_LookupProgram { ...@@ -124,7 +124,7 @@ class PFCP_Session_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getSessionMappingMap() const; std::shared_ptr<BPFMap> getSessionMappingMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the UE QFI TEID Map object. * @brief Get the UE QFI TEID Map object.
* *
...@@ -139,7 +139,7 @@ class PFCP_Session_LookupProgram { ...@@ -139,7 +139,7 @@ class PFCP_Session_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getQosFlowMap() const; std::shared_ptr<BPFMap> getQosFlowMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
private: private:
/** /**
...@@ -151,61 +151,61 @@ class PFCP_Session_LookupProgram { ...@@ -151,61 +151,61 @@ class PFCP_Session_LookupProgram {
// void instrementQfiFlowMappingTable( // void instrementQfiFlowMappingTable(
// e_resource_type type, uint32_t qos, uint8_t qfi, uint8_t dscp); // e_resource_type type, uint32_t qos, uint8_t qfi, uint8_t dscp);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The reference of the bpf maps. // The reference of the bpf maps.
std::shared_ptr<BPFMaps> mpMaps; std::shared_ptr<BPFMaps> mpMaps;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The skeleton of the UPF program generated by bpftool. // The skeleton of the UPF program generated by bpftool.
// ProgramLifeCycle is the owner of the pointer. // ProgramLifeCycle is the owner of the pointer.
pfcp_session_lookup_ebpf_xdp_prgrm_kernel_c* spSkeleton; pfcp_session_lookup_ebpf_xdp_prgrm_kernel_c* spSkeleton;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The program eBPF map. // The program eBPF map.
std::shared_ptr<BPFMap> mpTeidSessionMap; std::shared_ptr<BPFMap> mpTeidSessionMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The program eBPF map. // The program eBPF map.
std::shared_ptr<BPFMap> mpUeIpSessionMap; std::shared_ptr<BPFMap> mpUeIpSessionMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The pdi key to program index map. // The pdi key to program index map.
std::shared_ptr<BPFMap> mpNextProgRuleIndexMap; std::shared_ptr<BPFMap> mpNextProgRuleIndexMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The next prog rule map. // The next prog rule map.
std::shared_ptr<BPFMap> mpNextProgRuleMap; std::shared_ptr<BPFMap> mpNextProgRuleMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The traffic map. // The traffic map.
// std::shared_ptr<BPFMap> mpTrafficMap; // std::shared_ptr<BPFMap> mpTrafficMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The session mapping map. // The session mapping map.
std::shared_ptr<BPFMap> mpSessionMappingMap; std::shared_ptr<BPFMap> mpSessionMappingMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The UE-QFI-TEID map. // The UE-QFI-TEID map.
// std::shared_ptr<BPFMap> mpUeQfiTeidMap; // std::shared_ptr<BPFMap> mpUeQfiTeidMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The QOS Flow map. // The QOS Flow map.
// std::shared_ptr<BPFMap> mpQosFlowMap; // std::shared_ptr<BPFMap> mpQosFlowMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The BPF lifecycle program. // The BPF lifecycle program.
std::shared_ptr<PFCP_Session_LookupProgramLifeCycle> mpLifeCycle; std::shared_ptr<PFCP_Session_LookupProgramLifeCycle> mpLifeCycle;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The GTP interface. // The GTP interface.
std::string mGTPInterface; std::string mGTPInterface;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The UDP interface. // The UDP interface.
std::string mUDPInterface; std::string mUDPInterface;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
}; };
#endif // __PFCP_SESSION_LOOKUP_EBPF_XDP_PRGRM_USER_H__ #endif // __PFCP_SESSION_LOOKUP_EBPF_XDP_PRGRM_USER_H__
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <wrappers/BPFMaps.h> #include <wrappers/BPFMaps.h>
#include <wrappers/BPFMap.hpp> #include <wrappers/BPFMap.hpp>
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
PFCP_Session_PDR_LookupProgram::PFCP_Session_PDR_LookupProgram( PFCP_Session_PDR_LookupProgram::PFCP_Session_PDR_LookupProgram(
const std::string& gtpInterface, const std::string& udpInterface) const std::string& gtpInterface, const std::string& udpInterface)
: mGTPInterface(gtpInterface), mUDPInterface(udpInterface) { : mGTPInterface(gtpInterface), mUDPInterface(udpInterface) {
...@@ -18,10 +18,10 @@ PFCP_Session_PDR_LookupProgram::PFCP_Session_PDR_LookupProgram( ...@@ -18,10 +18,10 @@ PFCP_Session_PDR_LookupProgram::PFCP_Session_PDR_LookupProgram(
pfcp_session_pdr_lookup_ebpf_xdp_prgrm_kernel_c__destroy); pfcp_session_pdr_lookup_ebpf_xdp_prgrm_kernel_c__destroy);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
PFCP_Session_PDR_LookupProgram::~PFCP_Session_PDR_LookupProgram() {} PFCP_Session_PDR_LookupProgram::~PFCP_Session_PDR_LookupProgram() {}
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// TODO: Pass configuration throught args. // TODO: Pass configuration throught args.
void PFCP_Session_PDR_LookupProgram::setup() { void PFCP_Session_PDR_LookupProgram::setup() {
mpLifeCycle->open(); mpLifeCycle->open();
...@@ -30,57 +30,57 @@ void PFCP_Session_PDR_LookupProgram::setup() { ...@@ -30,57 +30,57 @@ void PFCP_Session_PDR_LookupProgram::setup() {
mpLifeCycle->attach(); mpLifeCycle->attach();
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void PFCP_Session_PDR_LookupProgram::tearDown() { void PFCP_Session_PDR_LookupProgram::tearDown() {
mpLifeCycle->tearDown(); mpLifeCycle->tearDown();
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
int PFCP_Session_PDR_LookupProgram::getUplinkFileDescriptor() const { int PFCP_Session_PDR_LookupProgram::getUplinkFileDescriptor() const {
return bpf_program__fd( return bpf_program__fd(
mpLifeCycle->getBPFSkeleton()->progs.uplink_entry_point); mpLifeCycle->getBPFSkeleton()->progs.uplink_entry_point);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
int PFCP_Session_PDR_LookupProgram::getDownlinkFileDescriptor() const { int PFCP_Session_PDR_LookupProgram::getDownlinkFileDescriptor() const {
return bpf_program__fd( return bpf_program__fd(
mpLifeCycle->getBPFSkeleton()->progs.downlink_entry_point); mpLifeCycle->getBPFSkeleton()->progs.downlink_entry_point);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getFARMap() const { std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getFARMap() const {
return mpFARMap; return mpFARMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getUplinkPDRsMap() std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getUplinkPDRsMap()
const { const {
return mpUplinkPDRsMap; return mpUplinkPDRsMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getDownlinkPDRsMap() std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getDownlinkPDRsMap()
const { const {
return mpDownlinkPDRsMap; return mpDownlinkPDRsMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getCounterMap() const { std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getCounterMap() const {
return mpCounterMap; return mpCounterMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getEgressInterfaceMap() std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getEgressInterfaceMap()
const { const {
return mpEgressInterfaceMap; return mpEgressInterfaceMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getArpTableMap() const { std::shared_ptr<BPFMap> PFCP_Session_PDR_LookupProgram::getArpTableMap() const {
return mpArpTableMap; return mpArpTableMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void PFCP_Session_PDR_LookupProgram::initializeMaps() { void PFCP_Session_PDR_LookupProgram::initializeMaps() {
// Store all maps available in the program. // Store all maps available in the program.
mpMaps = std::make_shared<BPFMaps>(mpLifeCycle->getBPFSkeleton()->skeleton); mpMaps = std::make_shared<BPFMaps>(mpLifeCycle->getBPFSkeleton()->skeleton);
...@@ -95,4 +95,4 @@ void PFCP_Session_PDR_LookupProgram::initializeMaps() { ...@@ -95,4 +95,4 @@ void PFCP_Session_PDR_LookupProgram::initializeMaps() {
std::make_shared<BPFMap>(mpMaps->getMap("m_redirect_interfaces")); std::make_shared<BPFMap>(mpMaps->getMap("m_redirect_interfaces"));
mpArpTableMap = std::make_shared<BPFMap>(mpMaps->getMap("m_arp_table")); mpArpTableMap = std::make_shared<BPFMap>(mpMaps->getMap("m_arp_table"));
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
\ No newline at end of file \ No newline at end of file
...@@ -18,7 +18,7 @@ class BPFMap; ...@@ -18,7 +18,7 @@ class BPFMap;
*/ */
class PFCP_Session_PDR_LookupProgram { class PFCP_Session_PDR_LookupProgram {
public: public:
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Construct a new Session Program object. * @brief Construct a new Session Program object.
* *
...@@ -26,28 +26,28 @@ class PFCP_Session_PDR_LookupProgram { ...@@ -26,28 +26,28 @@ class PFCP_Session_PDR_LookupProgram {
PFCP_Session_PDR_LookupProgram( PFCP_Session_PDR_LookupProgram(
const std::string& gtpInterface, const std::string& udpInterface); const std::string& gtpInterface, const std::string& udpInterface);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Destroy the Session Program object. * @brief Destroy the Session Program object.
* *
*/ */
virtual ~PFCP_Session_PDR_LookupProgram(); virtual ~PFCP_Session_PDR_LookupProgram();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Setup the program. * @brief Setup the program.
* *
*/ */
void setup(); void setup();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Tear down the program. * @brief Tear down the program.
* *
*/ */
void tearDown(); void tearDown();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Downlink File Descriptor (entry point) object. * @brief Get the Downlink File Descriptor (entry point) object.
* *
...@@ -55,7 +55,7 @@ class PFCP_Session_PDR_LookupProgram { ...@@ -55,7 +55,7 @@ class PFCP_Session_PDR_LookupProgram {
*/ */
int getUplinkFileDescriptor() const; int getUplinkFileDescriptor() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Uplink File Descriptor (entry point) object. * @brief Get the Uplink File Descriptor (entry point) object.
* *
...@@ -63,7 +63,7 @@ class PFCP_Session_PDR_LookupProgram { ...@@ -63,7 +63,7 @@ class PFCP_Session_PDR_LookupProgram {
*/ */
int getDownlinkFileDescriptor() const; int getDownlinkFileDescriptor() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get PDR maps reference. * @brief Get PDR maps reference.
* *
...@@ -71,7 +71,7 @@ class PFCP_Session_PDR_LookupProgram { ...@@ -71,7 +71,7 @@ class PFCP_Session_PDR_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getPDRMap() const; std::shared_ptr<BPFMap> getPDRMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the FAR Map object. * @brief Get the FAR Map object.
* *
...@@ -79,7 +79,7 @@ class PFCP_Session_PDR_LookupProgram { ...@@ -79,7 +79,7 @@ class PFCP_Session_PDR_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getFARMap() const; std::shared_ptr<BPFMap> getFARMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Uplink PDRs Map object. * @brief Get the Uplink PDRs Map object.
* *
...@@ -87,7 +87,7 @@ class PFCP_Session_PDR_LookupProgram { ...@@ -87,7 +87,7 @@ class PFCP_Session_PDR_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getUplinkPDRsMap() const; std::shared_ptr<BPFMap> getUplinkPDRsMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Downlink PDRs Map object. * @brief Get the Downlink PDRs Map object.
* *
...@@ -95,7 +95,7 @@ class PFCP_Session_PDR_LookupProgram { ...@@ -95,7 +95,7 @@ class PFCP_Session_PDR_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getDownlinkPDRsMap() const; std::shared_ptr<BPFMap> getDownlinkPDRsMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Counter Map object. * @brief Get the Counter Map object.
* *
...@@ -103,7 +103,7 @@ class PFCP_Session_PDR_LookupProgram { ...@@ -103,7 +103,7 @@ class PFCP_Session_PDR_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getCounterMap() const; std::shared_ptr<BPFMap> getCounterMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Egress Interface Map object. * @brief Get the Egress Interface Map object.
* *
...@@ -111,7 +111,7 @@ class PFCP_Session_PDR_LookupProgram { ...@@ -111,7 +111,7 @@ class PFCP_Session_PDR_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getEgressInterfaceMap() const; std::shared_ptr<BPFMap> getEgressInterfaceMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Arp Table Map object. * @brief Get the Arp Table Map object.
* *
...@@ -119,7 +119,7 @@ class PFCP_Session_PDR_LookupProgram { ...@@ -119,7 +119,7 @@ class PFCP_Session_PDR_LookupProgram {
*/ */
std::shared_ptr<BPFMap> getArpTableMap() const; std::shared_ptr<BPFMap> getArpTableMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
private: private:
/** /**
* @brief Initialize BPF maps wrappers references. * @brief Initialize BPF maps wrappers references.
......
...@@ -8,15 +8,16 @@ ...@@ -8,15 +8,16 @@
#include <wrappers/BPFMaps.h> #include <wrappers/BPFMaps.h>
#include "interfaces.h" #include "interfaces.h"
#include "logger.hpp" #include "logger.hpp"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netlink/route/link.h>
#include <netlink/route/qdisc/htb.h>
/*****************************************************************************************************************/
int is_little_endian2() {
u32 value = 1;
u8* byte = (u8*) &value;
return (*byte == 1);
}
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
QERProgram::QERProgram( QERProgram::QERProgram(
const std::string& gtpInterface, const std::string& udpInterface) const std::string& gtpInterface, const std::string& udpInterface)
: mGTPInterface(gtpInterface), mUDPInterface(udpInterface) { : mGTPInterface(gtpInterface), mUDPInterface(udpInterface) {
...@@ -27,10 +28,10 @@ QERProgram::QERProgram( ...@@ -27,10 +28,10 @@ QERProgram::QERProgram(
qer_ebpf_tc_prgrm_kernel_c__destroy); qer_ebpf_tc_prgrm_kernel_c__destroy);
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
QERProgram::~QERProgram() {} QERProgram::~QERProgram() {}
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void QERProgram::setup() { void QERProgram::setup() {
spSkeleton = mpLifeCycle->open(); spSkeleton = mpLifeCycle->open();
initializeMaps(); initializeMaps();
...@@ -38,29 +39,29 @@ void QERProgram::setup() { ...@@ -38,29 +39,29 @@ void QERProgram::setup() {
mpLifeCycle->attach(); mpLifeCycle->attach();
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMaps> QERProgram::getMaps() { std::shared_ptr<BPFMaps> QERProgram::getMaps() {
return mpMaps; return mpMaps;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// TODO: Check when kill when running. // TODO: Check when kill when running.
// It was noted the infinity loop. // It was noted the infinity loop.
void QERProgram::tearDown() { void QERProgram::tearDown() {
mpLifeCycle->tearDown(); mpLifeCycle->tearDown();
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> QERProgram::geGtpUTunnelMap() const { std::shared_ptr<BPFMap> QERProgram::geGtpUTunnelMap() const {
return mpGtpUTunnelMap; return mpGtpUTunnelMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> QERProgram::getFilterMap() const { std::shared_ptr<BPFMap> QERProgram::getFilterMap() const {
return mpFilterMap; return mpFilterMap;
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
void QERProgram::initializeMaps() { void QERProgram::initializeMaps() {
// Store all maps available in the program. // Store all maps available in the program.
...@@ -71,4 +72,171 @@ void QERProgram::initializeMaps() { ...@@ -71,4 +72,171 @@ void QERProgram::initializeMaps() {
mpFilterMap = std::make_shared<BPFMap>(mpMaps->getMap("m_filter")); mpFilterMap = std::make_shared<BPFMap>(mpMaps->getMap("m_filter"));
} }
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
\ No newline at end of file /*---------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------------------------*/
struct nl_sock *create_socket(){
// Initialize Netlink socket
struct nl_sock *sock = nl_socket_alloc();
if (!sock) {
perror("nl_socket_alloc");
exit(EXIT_FAILURE);
}
// Connect to Netlink socket
if (nl_connect(sock, NETLINK_ROUTE) < 0) {
perror("nl_connect");
nl_socket_free(sock);
exit(EXIT_FAILURE);
}
return sock;
}
/*---------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------------------------*/
struct rtnl_tc *allocate_tc(struct rtnl_tc *tc, struct nl_sock *sock, struct rtnl_qdisc *qdisc){
// Allocate a new Traffic Control object
tc = rtnl_tc_alloc();
if (!tc) {
perror("rtnl_tc_alloc");
rtnl_qdisc_delete(sock, qdisc);
nl_close(sock);
nl_socket_free(sock);
exit(EXIT_FAILURE);
}
return tc;
}
/*---------------------------------------------------------------------------------------------------------------*/
void add_qdisc_to_interface(const char *interface, struct nl_sock *sock, struct rtnl_qdisc *qdisc, struct rtnl_tc *tc){
// Add the Qdisc to the interface (replace "eth0" with your interface name)
if (rtnl_tc_add(sock, tc, NLM_F_CREATE | NLM_F_EXCL, RTM_NEWQDISC, 0, interface) < 0) {
perror("rtnl_tc_add");
rtnl_tc_free(tc);
rtnl_qdisc_delete(sock, qdisc);
nl_close(sock);
nl_socket_free(sock);
exit(EXIT_FAILURE);
}
}
// /*---------------------------------------------------------------------------------------------------------------*/
// // Function to create and configure a Qdisc hierarchy
// void qer_tc::create_configure_hierarchy(struct rtnl_qdisc *root_qdisc, struct nl_sock *sock, qdisc_pdu_to_create, qdisc_qos_flows_to_create) {
// // Create and configure parent classes and their children as needed
// struct rtnl_qdisc *parent1 = create_parent_class(sock, seid);
// struct rtnl_qdisc *child1 = create_child_class(sock, parent1, qfi[i]);
// struct rtnl_qdisc *child2 = create_child_class(sock, parent1, qfi[j]);
// // Attach parent Qdisc to root Qdisc
// if (rtnl_qdisc_set_parent(parent1, root_qdisc) < 0) {
// perror("rtnl_qdisc_set_parent");
// exit(EXIT_FAILURE);
// }
// }
// /*---------------------------------------------------------------------------------------------------------------*/
// // Function to create and configure the Qdisc hierarchy
// void qer_tc::create_configure_hierarchy(struct nl_sock *sock, const char *interface, std::vector<std::vector<uint32_t>> child_ids) {
// // Create and configure parent classes
// for (size_t i = 0; i < child_ids.size(); ++i) {
// struct rtnl_qdisc *parent = create_parent_class(sock, interface, i + 1);
// parent_qdiscs.push_back(parent);
// // Create and attach child classes
// std::vector<struct rtnl_qdisc *> children;
// for (size_t j = 0; j < child_ids[i].size(); ++j) {
// struct rtnl_qdisc *child = create_child_class(sock, parent, child_ids[i][j]);
// children.push_back(child);
// }
// child_qdiscs.push_back(children);
// // Attach parent Qdisc to root Qdisc
// if (rtnl_qdisc_set_parent(parent, root_qdisc) < 0) {
// perror("rtnl_qdisc_set_parent");
// exit(EXIT_FAILURE);
// }
// }
// }
// /*---------------------------------------------------------------------------------------------------------------*/
// // Function to create a parent class
// struct rtnl_qdisc *qer_tc::create_parent_class(struct nl_sock *sock, const char *interface, uint32_t parent_id) {
// // Create parent Qdisc
// struct rtnl_qdisc *parent_qdisc = rtnl_qdisc_alloc();
// if (!parent_qdisc) {
// perror("rtnl_qdisc_alloc");
// exit(EXIT_FAILURE);
// }
// // Configure parent Qdisc as needed
// rtnl_htb_set_rate(parent_qdisc, rate);
// // Add parent Qdisc to the interface
// if (rtnl_tc_add(sock, parent_qdisc, NLM_F_CREATE | NLM_F_REPLACE, RTM_NEWQDISC, 0, interface) < 0) {
// perror("rtnl_tc_add");
// rtnl_qdisc_free(parent_qdisc);
// exit(EXIT_FAILURE);
// }
// return parent_qdisc;
// }
// /*---------------------------------------------------------------------------------------------------------------*/
// // Function to create a child class
// struct rtnl_qdisc *qer_tc::create_child_class(struct nl_sock *sock, struct rtnl_qdisc *parent, uint32_t child_id) {
// // Create child Qdisc
// struct rtnl_qdisc *child_qdisc = rtnl_qdisc_alloc();
// if (!child_qdisc) {
// perror("rtnl_qdisc_alloc");
// exit(EXIT_FAILURE);
// }
// // Configure child Qdisc as needed
// rtnl_htb_set_rate(child_qdisc, rate);
// // Add child Qdisc to the parent
// if (rtnl_qdisc_set_parent(child_qdisc, parent) < 0) {
// perror("rtnl_qdisc_set_parent");
// rtnl_qdisc_free(child_qdisc);
// exit(EXIT_FAILURE);
// }
// return child_qdisc;
// }
// #include "qer_tc.hpp"
// #include <stdio.h>
// #include <stdlib.h>
// #include <string.h>
// #include <netlink/route/link.h>
// // Constructor
// qer_tc::qer_tc(const char *kind, uint32_t rate) {
// params.kind = kind;
// params.rate = rate;
// // Initialize other parameters as needed
// }
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
#include "interfaces.h" #include "interfaces.h"
#include <netlink/netlink.h>
#include <netlink/route/qdisc.h>
class BPFMaps; class BPFMaps;
class BPFMap; class BPFMap;
class SessionManager; class SessionManager;
...@@ -21,6 +26,7 @@ class RulesUtilities; ...@@ -21,6 +26,7 @@ class RulesUtilities;
using QERProgramLifeCycle = ProgramLifeCycle<qer_ebpf_tc_prgrm_kernel_c>; using QERProgramLifeCycle = ProgramLifeCycle<qer_ebpf_tc_prgrm_kernel_c>;
/** /**
* @brief Singleton class to abstract the UPF bpf tc program. * @brief Singleton class to abstract the UPF bpf tc program.
*/ */
...@@ -30,15 +36,15 @@ class QERProgram : public BPFProgram { ...@@ -30,15 +36,15 @@ class QERProgram : public BPFProgram {
* @brief Construct a new QERProgram object. * @brief Construct a new QERProgram object.
* *
*/ */
explicit QERProgram(); explicit QERProgram(const std::string& gtpInterface, const std::string& udpInterface);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Destroy the QERProgram object * @brief Destroy the QERProgram object
*/ */
virtual ~QERProgram(); virtual ~QERProgram();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Setup the BPF program. * @brief Setup the BPF program.
...@@ -46,7 +52,7 @@ class QERProgram : public BPFProgram { ...@@ -46,7 +52,7 @@ class QERProgram : public BPFProgram {
*/ */
void setup(); void setup();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the BPFMaps object. * @brief Get the BPFMaps object.
* *
...@@ -54,13 +60,13 @@ class QERProgram : public BPFProgram { ...@@ -54,13 +60,13 @@ class QERProgram : public BPFProgram {
*/ */
std::shared_ptr<BPFMaps> getMaps(); std::shared_ptr<BPFMaps> getMaps();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Tear downs the BPF program. * @brief Tear downs the BPF program.
* *
*/ */
void tearDown(); void tearDown();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Update program int map. * @brief Update program int map.
...@@ -70,15 +76,14 @@ class QERProgram : public BPFProgram { ...@@ -70,15 +76,14 @@ class QERProgram : public BPFProgram {
*/ */
void updateProgramMap(uint32_t key, uint32_t fd); void updateProgramMap(uint32_t key, uint32_t fd);
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Remove program in map. * @brief Remove program in map.
* *
* @param key The key which will be remove in the program map. * @param key The key which will be remove in the program map.
*/ */
void removeProgramMap(uint32_t key); void removeProgramMap(uint32_t key);
/*---------------------------------------------------------------------------------------------------------------*/
/*****************************************************************************************************************/
/** /**
* @brief Get the TEID to session Map object. * @brief Get the TEID to session Map object.
* *
...@@ -86,7 +91,7 @@ class QERProgram : public BPFProgram { ...@@ -86,7 +91,7 @@ class QERProgram : public BPFProgram {
*/ */
std::shared_ptr<BPFMap> getQERMap() const; std::shared_ptr<BPFMap> getQERMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Egress Interface Map object. * @brief Get the Egress Interface Map object.
* *
...@@ -94,7 +99,7 @@ class QERProgram : public BPFProgram { ...@@ -94,7 +99,7 @@ class QERProgram : public BPFProgram {
*/ */
std::shared_ptr<BPFMap> getEgressInterfaceMap() const; std::shared_ptr<BPFMap> getEgressInterfaceMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the n3 GTP-U Tunnel Map object. * @brief Get the n3 GTP-U Tunnel Map object.
* *
...@@ -103,7 +108,7 @@ class QERProgram : public BPFProgram { ...@@ -103,7 +108,7 @@ class QERProgram : public BPFProgram {
*/ */
std::shared_ptr<BPFMap> geGtpUTunnelMap() const; std::shared_ptr<BPFMap> geGtpUTunnelMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
* @brief Get the Filter Map object. * @brief Get the Filter Map object.
* *
...@@ -111,7 +116,46 @@ class QERProgram : public BPFProgram { ...@@ -111,7 +116,46 @@ class QERProgram : public BPFProgram {
*/ */
std::shared_ptr<BPFMap> getFilterMap() const; std::shared_ptr<BPFMap> getFilterMap() const;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------------------------*/
/**
* @brief Create a configure hierarchy object
*
* @param sock
* @param interface
* @param child_ids
*/
void create_configure_hierarchy(struct nl_sock *sock, const char *interface, std::vector<std::vector<uint32_t>> child_ids);
/*---------------------------------------------------------------------------------------------------------------*/
/**
* @brief Create a parent parent class object
*
* @param sock
* @param interface
* @param parent_id
* @return * struct rtnl_qdisc*
*/
struct rtnl_qdisc *create_parent_class(struct nl_sock *sock, const char *interface, uint32_t parent_id);
/*---------------------------------------------------------------------------------------------------------------*/
/**
* @brief Create a child class object
*
* @param sock
* @param parent
* @param child_id
* @return struct rtnl_qdisc*
*/
struct rtnl_qdisc *create_child_class(struct nl_sock *sock, struct rtnl_qdisc *parent, uint32_t child_id);
/*---------------------------------------------------------------------------------------------------------------*/
private: private:
/** /**
* @brief Initialize BPF wrappers maps. * @brief Initialize BPF wrappers maps.
...@@ -119,24 +163,42 @@ class QERProgram : public BPFProgram { ...@@ -119,24 +163,42 @@ class QERProgram : public BPFProgram {
*/ */
void initializeMaps(); void initializeMaps();
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The reference of the bpf maps. // The reference of the bpf maps.
std::shared_ptr<BPFMaps> mpMaps; std::shared_ptr<BPFMaps> mpMaps;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The skeleton of the UPF program generated by bpftool. // The skeleton of the UPF program generated by bpftool.
// ProgramLifeCycle is the owner of the pointer. // ProgramLifeCycle is the owner of the pointer.
qer_ebpf_tc_prgrm_kernel_c* spSkeleton; qer_ebpf_tc_prgrm_kernel_c* spSkeleton;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The GTP-U Tunnel map. // The GTP-U Tunnel map.
std::shared_ptr<BPFMap> mpGtpUTunnelMap; std::shared_ptr<BPFMap> mpGtpUTunnelMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The BPF lifecycle program.
std::shared_ptr<QERProgramLifeCycle> mpLifeCycle;
/*---------------------------------------------------------------------------------------------------------------*/
// The Filter map. // The Filter map.
std::shared_ptr<BPFMap> mpFilterMap; std::shared_ptr<BPFMap> mpFilterMap;
/*****************************************************************************************************************/ /*---------------------------------------------------------------------------------------------------------------*/
// The GTP interface.
std::string mGTPInterface;
/*---------------------------------------------------------------------------------------------------------------*/
// The UDP interface.
std::string mUDPInterface;
/*---------------------------------------------------------------------------------------------------------------*/
std::vector<struct rtnl_qdisc *> parent_qdiscs;
std::vector<std::vector<struct rtnl_qdisc *>> child_qdiscs;
}; };
#endif // __QER_EBPF_TC_PRGRM_USER_H__ #endif // __QER_EBPF_TC_PRGRM_USER_H__
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