Commit aaac0a0b authored by Franck Messaoudi's avatar Franck Messaoudi

Update: cleanup some code

parent c909aec9
......@@ -44,6 +44,8 @@
#include <SessionProgramManager.h>
#include <UserPlaneComponent.h>
#include "helpers/ConfigLoader.hpp"
using namespace oai::upf::app;
using namespace oai::config;
using namespace oai::utils;
......@@ -126,11 +128,23 @@ void setup_bpf() {
//------------------------------------------------------------------------------
int main(int argc, char** argv) {
// Command line options
// std::string configPath =
// "/home/messaoudi/workspace/project-oai-qos/oai-cn5g-upf/etc/"
// "ebpf_maps.conf";
if (!Options::parse(argc, argv)) {
std::cout << "Options::parse() failed" << std::endl;
return 1;
}
// if (!ConfigLoader::getInstance().loadConfig(configPath)) {
// std::cerr << "Failed to load ebpf map sizes config file" << std::endl;
// return 1; // Exit if config fails
// }
// printFileContents(configPath);
// Logger
// Config
std::string conf_file_name = Options::getlibconfigConfig();
......
......@@ -269,18 +269,6 @@ void SessionProgramManager::initializeNextRuleProgIndexKey(
key.source_value = sourceInterface;
}
//---------------------------------------------------------------------------------------------------------------
// void SessionProgramManager::storeFarProgramIndexInNextProgRuleIndexMap(
// std::shared_ptr<pfcp::pfcp_far> pFar, const next_rule_prog_index_key&
// key, std::shared_ptr<PFCP_Session_LookupProgram>
// pPFCP_Session_LookupProgram) {
// pfcp_far_t_ far = createFar(pFar);
// pPFCP_Session_LookupProgram->getNextProgRuleIndexMap()->update(
// key, far, BPF_ANY);
// // pPFCP_Session_LookupProgram->getNextProgRuleMap()->update(id, fd,
// BPF_ANY);
// }
//---------------------------------------------------------------------------------------------------------------
// Helper function to store Session mapping
void SessionProgramManager::storePduSessionInMap(
......@@ -738,145 +726,6 @@ void SessionProgramManager::modifyPipeline(
pPFCP_Session_LookupProgram->getSessionPdrsMap()->update(seid, pdrs, BPF_ANY);
}
//---------------------------------------------------------------------------------------------------------------
// void SessionProgramManager::createPipeline(
// uint64_t seid, uint32_t teid1, uint8_t sourceInterface,
// uint32_t ueIpAddress, std::shared_ptr<pfcp::pfcp_far> pFar,
// std::vector<std::shared_ptr<pfcp::pfcp_qer>> pQer,
// std::vector<std::shared_ptr<pfcp::pfcp_pdr>> pdrs, bool isModification,
// uint32_t teid2) {
// uint32_t dnIP = upf_cfg.remote_n6.s_addr;
// uint32_t upfn3IP = upf_cfg.n3.addr4.s_addr;
// uint32_t upfn6IP = upf_cfg.n6.addr4.s_addr;
// uint32_t far_id = pFar->far_id.far_id;
// next_rule_prog_index_key key;
// // for each PDR get the key and save the appropriate FAR
// initializeNextRuleProgIndexKey(key, teid1, ueIpAddress, sourceInterface);
// bool enforcing_qos = !pQer.empty();
// const bool isBpfAccelerationEnabled = upf_cfg.enable_bpf_datapath;
// const bool isQosEnabled = isBpfAccelerationEnabled && upf_cfg.enable_qos;
// if (isQosEnabled && enforcing_qos) {
// Logger::upf_app().debug("Instantiate a new QERProgram ");
// std::shared_ptr<QERProgram> pQERProgram = std::make_shared<QERProgram>();
// Logger::upf_app().debug("PDRs Vector size %d", pdrs.size());
// pQERProgram->setup(seid, pQer, pdrs);
// }
// auto pPFCP_Session_LookupProgram =
// UserPlaneComponent::getInstance().getPFCP_Session_LookupProgram();
// storeFarProgramIndexInNextProgRuleIndexMap(
// pFar, key, pPFCP_Session_LookupProgram);
// // until here the for loop over pdrs to save key and far
// if (isModification) {
// storePduSessionInMap(
// pPFCP_Session_LookupProgram, ueIpAddress, 0, teid1, seid);
// uint32_t gNodeBIP = getGnodebIp(pFar);
// std::thread arpUpdateThread1([this, pPFCP_Session_LookupProgram, seid,
// gNodeBIP, dnIP, upfn3IP, upfn6IP]() {
// updateARPTableForN6(pPFCP_Session_LookupProgram, dnIP, upfn6IP);
// updateARPTableForN3(pPFCP_Session_LookupProgram, gNodeBIP, upfn3IP,
// seid);
// });
// // Detach the thread since we don't need to join it
// arpUpdateThread1.detach();
// } else {
// storePduSessionInMap(
// pPFCP_Session_LookupProgram, ueIpAddress, teid1, 0, seid);
// // Launch a separate thread to update ARP table map
// std::thread arpUpdateThread2(
// [this, pPFCP_Session_LookupProgram, dnIP, upfn6IP]() {
// updateARPTableForN6(pPFCP_Session_LookupProgram, dnIP, upfn6IP);
// });
// arpUpdateThread2.detach();
// saveSeidWithinFARProgram(seid, pPFCP_Session_LookupProgram, key);
// }
// }
// // void SessionProgramManager::createPipeline(
// // uint64_t seid, uint32_t teid1, uint8_t sourceInterface,
// // uint32_t ueIpAddress, std::shared_ptr<pfcp::pfcp_far> pFar,
// // std::vector<std::shared_ptr<pfcp::pfcp_qer>> pQer,
// // std::vector<std::shared_ptr<pfcp::pfcp_pdr>> pdrs, bool
// isModification,
// // uint32_t teid2) {
// // uint32_t dnIP = upf_cfg.remote_n6.s_addr;
// // uint32_t upfn3IP = upf_cfg.n3.addr4.s_addr;
// // uint32_t upfn6IP = upf_cfg.n6.addr4.s_addr;
// // uint32_t far_id = pFar->far_id.far_id;
// // next_rule_prog_index_key key;
// // // for each PDR get the key and save the appropriate FAR
// // initializeNextRuleProgIndexKey(key, teid1, ueIpAddress,
// sourceInterface);
// // bool enforcing_qos = !pQer.empty();
// // const bool isBpfAccelerationEnabled = upf_cfg.enable_bpf_datapath;
// // const bool isQosEnabled = isBpfAccelerationEnabled &&
// upf_cfg.enable_qos;
// // if (isQosEnabled && enforcing_qos) {
// // Logger::upf_app().debug("Instantiate a new QERProgram ");
// // std::shared_ptr<QERProgram> pQERProgram =
// // std::make_shared<QERProgram>(); Logger::upf_app().debug("PDRs Vector
// // size %d", pdrs.size()); pQERProgram->setup(seid, pQer, pdrs);
// // }
// // auto pPFCP_Session_LookupProgram =
// // UserPlaneComponent::getInstance().getPFCP_Session_LookupProgram();
// // storeFarProgramIndexInNextProgRuleIndexMap(
// // pFar, key, pPFCP_Session_LookupProgram);
// // // until here the for loop over pdrs to save key and far
// // if (isModification) {
// // storePduSessionInMap(
// // pPFCP_Session_LookupProgram, ueIpAddress, 0, teid1, seid);
// // uint32_t gNodeBIP = getGnodebIp(pFar);
// // std::thread arpUpdateThread1([this, pPFCP_Session_LookupProgram, seid,
// // gNodeBIP, dnIP, upfn3IP, upfn6IP]() {
// // updateARPTableForN6(pPFCP_Session_LookupProgram, dnIP, upfn6IP);
// // updateARPTableForN3(pPFCP_Session_LookupProgram, gNodeBIP, upfn3IP,
// // seid);
// // });
// // // Detach the thread since we don't need to join it
// // arpUpdateThread1.detach();
// // } else {
// // storePduSessionInMap(
// // pPFCP_Session_LookupProgram, ueIpAddress, teid1, 0, seid);
// // // Launch a separate thread to update ARP table map
// // std::thread arpUpdateThread2(
// // [this, pPFCP_Session_LookupProgram, dnIP, upfn6IP]() {
// // updateARPTableForN6(pPFCP_Session_LookupProgram, dnIP, upfn6IP);
// // });
// // arpUpdateThread2.detach();
// // saveSeidWithinFARProgram(seid, pPFCP_Session_LookupProgram, key);
// // }
// // }
// // void SessionProgramManager::addPdrPipeline(pdr) {}
// // void SessionProgramManager::addFarPipeline(far) {}
// // void SessionProgramManager::addQerPipeline(qer) {}
// // void SessionProgramManager::updatePdrPipeline(pdr) {}
// // void SessionProgramManager::updateFarPipeline(far) {}
// // void SessionProgramManager::updateQerPipeline(qer) {}
// // void SessionProgramManager::deletePdrPipeline(pdr) {}
// // void SessionProgramManager::deleteFarPipeline(far) {}
// // void SessionProgramManager::deleteQerPipeline(qer) {}
//---------------------------------------------------------------------------------------------------------------
void SessionProgramManager::removePipeline(uint64_t seid) {
Logger::upf_app().debug("Clean the different eBPF maps");
......@@ -901,48 +750,6 @@ void SessionProgramManager::removePipeline(uint64_t seid) {
// pPFCP_Session_LookupProgram->getNextProgRuleIndexMap()->remove(key);
}
//---------------------------------------------------------------------------------------------------------------
// void SessionProgramManager::create(uint64_t seid) {
// // Check if there is a key with seid value.
// // TODO: Check if can be abstract the programMap.
// if (mSessionProgramMap.find(seid) != mSessionProgramMap.end()) {
// Logger::upf_app().error(
// "PDU Session {} Already Exists. Cannot Create a New eBPF Program
// " "with " "the same " "key", seid);
// throw std::runtime_error(
// "Cannot Create a New eBPF program with Key (seid)");
// }
// // Instantiate a new PFCP_Session_PDR_LookupProgram
// auto udpInterface =
// UserPlaneComponent::getInstance().getUDPInterface(); auto gtpInterface
// = UserPlaneComponent::getInstance().getGTPInterface();
// std::shared_ptr<PFCP_Session_PDR_LookupProgram>
// pPFCP_Session_PDR_LookupProgram =
// std::make_shared<PFCP_Session_PDR_LookupProgram>(
// gtpInterface, udpInterface);
// // pPFCP_Session_PDR_LookupProgram->setup();
// // Initialize key egress interface map.
// uint32_t udpInterfaceIndex = if_nametoindex(udpInterface.c_str());
// uint32_t gtpInterfaceIndex = if_nametoindex(gtpInterface.c_str());
// uint32_t uplinkId = static_cast<uint32_t>(FlowDirection::UPLINK);
// uint32_t downlinkId = static_cast<uint32_t>(FlowDirection::DOWNLINK);
// pPFCP_Session_PDR_LookupProgram->getEgressInterfaceMap()->update(
// uplinkId, udpInterfaceIndex, BPF_ANY);
// pPFCP_Session_PDR_LookupProgram->getEgressInterfaceMap()->update(
// downlinkId, gtpInterfaceIndex, BPF_ANY);
// // Update the PFCP_Session_PDR_LookupProgram map.
// mSessionProgramMap.insert(
// std::pair<uint32_t,
// std::shared_ptr<PFCP_Session_PDR_LookupProgram>>(
// seid, pPFCP_Session_PDR_LookupProgram));
// }
//---------------------------------------------------------------------------------------------------------------
void SessionProgramManager::remove(uint64_t seid) {
// auto sessionProgram = findSessionProgram(seid);
......
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