Commit 4b30f688 authored by Franck Messaoudi's avatar Franck Messaoudi

Update: remove unused eBPF maps

parent 933aff46
This diff is collapsed.
...@@ -270,14 +270,16 @@ void SessionProgramManager::initializeNextRuleProgIndexKey( ...@@ -270,14 +270,16 @@ void SessionProgramManager::initializeNextRuleProgIndexKey(
} }
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
void SessionProgramManager::storeFarProgramIndexInNextProgRuleIndexMap( // void SessionProgramManager::storeFarProgramIndexInNextProgRuleIndexMap(
std::shared_ptr<pfcp::pfcp_far> pFar, const next_rule_prog_index_key& key, // std::shared_ptr<pfcp::pfcp_far> pFar, const next_rule_prog_index_key&
std::shared_ptr<PFCP_Session_LookupProgram> pPFCP_Session_LookupProgram) { // key, std::shared_ptr<PFCP_Session_LookupProgram>
pfcp_far_t_ far = createFar(pFar); // pPFCP_Session_LookupProgram) {
pPFCP_Session_LookupProgram->getNextProgRuleIndexMap()->update( // pfcp_far_t_ far = createFar(pFar);
key, far, BPF_ANY); // pPFCP_Session_LookupProgram->getNextProgRuleIndexMap()->update(
// pPFCP_Session_LookupProgram->getNextProgRuleMap()->update(id, fd, BPF_ANY); // key, far, BPF_ANY);
} // // pPFCP_Session_LookupProgram->getNextProgRuleMap()->update(id, fd,
// BPF_ANY);
// }
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
// Helper function to store Session mapping // Helper function to store Session mapping
...@@ -737,66 +739,6 @@ void SessionProgramManager::modifyPipeline( ...@@ -737,66 +739,6 @@ void SessionProgramManager::modifyPipeline(
} }
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
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( // void SessionProgramManager::createPipeline(
// uint64_t seid, uint32_t teid1, uint8_t sourceInterface, // uint64_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,
...@@ -816,12 +758,11 @@ void SessionProgramManager::createPipeline( ...@@ -816,12 +758,11 @@ void SessionProgramManager::createPipeline(
// bool enforcing_qos = !pQer.empty(); // bool enforcing_qos = !pQer.empty();
// const bool isBpfAccelerationEnabled = upf_cfg.enable_bpf_datapath; // const bool isBpfAccelerationEnabled = upf_cfg.enable_bpf_datapath;
// const bool isQosEnabled = isBpfAccelerationEnabled && upf_cfg.enable_qos; // const bool isQosEnabled = isBpfAccelerationEnabled && upf_cfg.enable_qos;
// if (isQosEnabled && enforcing_qos) { // if (isQosEnabled && enforcing_qos) {
// Logger::upf_app().debug("Instantiate a new QERProgram "); // Logger::upf_app().debug("Instantiate a new QERProgram ");
// std::shared_ptr<QERProgram> pQERProgram = // std::shared_ptr<QERProgram> pQERProgram = std::make_shared<QERProgram>();
// std::make_shared<QERProgram>(); Logger::upf_app().debug("PDRs Vector // Logger::upf_app().debug("PDRs Vector size %d", pdrs.size());
// size %d", pdrs.size()); pQERProgram->setup(seid, pQer, pdrs); // pQERProgram->setup(seid, pQer, pdrs);
// } // }
// auto pPFCP_Session_LookupProgram = // auto pPFCP_Session_LookupProgram =
...@@ -859,17 +800,82 @@ void SessionProgramManager::createPipeline( ...@@ -859,17 +800,82 @@ void SessionProgramManager::createPipeline(
// } // }
// } // }
// void SessionProgramManager::addPdrPipeline(pdr) {} // // void SessionProgramManager::createPipeline(
// void SessionProgramManager::addFarPipeline(far) {} // // uint64_t seid, uint32_t teid1, uint8_t sourceInterface,
// void SessionProgramManager::addQerPipeline(qer) {} // // uint32_t ueIpAddress, std::shared_ptr<pfcp::pfcp_far> pFar,
// // std::vector<std::shared_ptr<pfcp::pfcp_qer>> pQer,
// void SessionProgramManager::updatePdrPipeline(pdr) {} // // std::vector<std::shared_ptr<pfcp::pfcp_pdr>> pdrs, bool
// void SessionProgramManager::updateFarPipeline(far) {} // isModification,
// void SessionProgramManager::updateQerPipeline(qer) {} // // uint32_t teid2) {
// // uint32_t dnIP = upf_cfg.remote_n6.s_addr;
// void SessionProgramManager::deletePdrPipeline(pdr) {} // // uint32_t upfn3IP = upf_cfg.n3.addr4.s_addr;
// void SessionProgramManager::deleteFarPipeline(far) {} // // uint32_t upfn6IP = upf_cfg.n6.addr4.s_addr;
// void SessionProgramManager::deleteQerPipeline(qer) {} // // 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) { void SessionProgramManager::removePipeline(uint64_t seid) {
......
...@@ -83,9 +83,10 @@ class SessionProgramManager { ...@@ -83,9 +83,10 @@ class SessionProgramManager {
uint64_t seid, uint64_t seid,
std::shared_ptr<PFCP_Session_LookupProgram> pPFCP_Session_LookupProgram); std::shared_ptr<PFCP_Session_LookupProgram> pPFCP_Session_LookupProgram);
void storeFarProgramIndexInNextProgRuleIndexMap( // void storeFarProgramIndexInNextProgRuleIndexMap(
std::shared_ptr<pfcp::pfcp_far> pFar, const next_rule_prog_index_key& key, // std::shared_ptr<pfcp::pfcp_far> pFar, const next_rule_prog_index_key&
std::shared_ptr<PFCP_Session_LookupProgram> pPFCP_Session_LookupProgram); // key, std::shared_ptr<PFCP_Session_LookupProgram>
// pPFCP_Session_LookupProgram);
void storePduSessionInMap( void storePduSessionInMap(
std::shared_ptr<PFCP_Session_LookupProgram> pPFCP_Session_LookupProgram, std::shared_ptr<PFCP_Session_LookupProgram> pPFCP_Session_LookupProgram,
...@@ -140,7 +141,7 @@ class SessionProgramManager { ...@@ -140,7 +141,7 @@ class SessionProgramManager {
int32_t getEmptySlot(); int32_t getEmptySlot();
std::shared_ptr<BPFMap> mpTeidSessionMap; std::shared_ptr<BPFMap> mpTeidSessionMap;
std::shared_ptr<BPFMap> mpUeIpSessionMap; // std::shared_ptr<BPFMap> mpUeIpSessionMap;
// The observer which will be notified when a PFCP_Session_PDR_LookupProgram // The observer which will be notified when a PFCP_Session_PDR_LookupProgram
// is created. // is created.
......
...@@ -47,7 +47,7 @@ std::string UserPlaneComponent::getUDPInterface() const { ...@@ -47,7 +47,7 @@ std::string UserPlaneComponent::getUDPInterface() const {
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
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);
} }
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
#define MAX_FAR_PROGRAMS 10000 #define MAX_FAR_PROGRAMS 10000
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
struct { // struct {
__uint(type, BPF_MAP_TYPE_HASH); // __uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, FAR_TAILS_MAX); // __uint(max_entries, FAR_TAILS_MAX);
__type(key, u8); // __type(key, u8);
__type(value, pfcp_far_t_); // __type(value, pfcp_far_t_);
} m_far SEC(".maps"); // } m_far SEC(".maps");
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
struct { struct {
......
...@@ -212,8 +212,8 @@ int far_entry_point(struct xdp_md* ctx) { ...@@ -212,8 +212,8 @@ int far_entry_point(struct xdp_md* ctx) {
void* data = (void*) (long) ctx->data; void* data = (void*) (long) ctx->data;
void* data_end = (void*) (long) ctx->data_end; void* data_end = (void*) (long) ctx->data_end;
u32 key = 0; u32 key = 0;
pfcp_far_t_* p_far = bpf_map_lookup_elem(&m_far, &key); pfcp_far_t_* p_far; //= bpf_map_lookup_elem(&m_far, &key);
if (p_far) { if (p_far) {
struct ethhdr* ethh = data; struct ethhdr* ethh = data;
......
...@@ -36,42 +36,44 @@ struct { ...@@ -36,42 +36,44 @@ struct {
} m_sdf_filter SEC(".maps"); } m_sdf_filter SEC(".maps");
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
struct { // struct {
__uint( // __uint(
type, // type,
BPF_MAP_TYPE_PROG_ARRAY); //!< Must have the key and value with 4 bytes // BPF_MAP_TYPE_PROG_ARRAY); //!< Must have the key and value with 4
__type(key, teid_t_); //!< program identifier. // bytes
__type(value, s32); //!< program which represents the session. // __type(key, teid_t_); //!< program identifier.
// TODO: Check how the management works. The size should be equal // __type(value, s32); //!< program which represents the session.
// to the maximum number of sessions. // // TODO: Check how the management works. The size should be equal
__uint(max_entries, MAX_LENGTH); // 10000, //!< TODO: Is it enought? // // to the maximum number of sessions.
} m_teid_session SEC(".maps"); // __uint(max_entries, MAX_LENGTH); // 10000, //!< TODO: Is it enought?
// } m_teid_session SEC(".maps");
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
struct { // struct {
__uint( // __uint(
type, // type,
BPF_MAP_TYPE_PROG_ARRAY); //!< Must have the key and value with 4 bytes // BPF_MAP_TYPE_PROG_ARRAY); //!< Must have the key and value with 4
__type(key, u32); //!< program identifier. // bytes
__type(value, s32); //!< program which represents the session. // __type(key, u32); //!< program identifier.
// TODO Check how the management works. The size should be equal // __type(value, s32); //!< program which represents the session.
// to the maximum number of sessions. // // TODO Check how the management works. The size should be equal
__uint(max_entries, MAX_UEs); //!< TODO: Is it enought? // // to the maximum number of sessions.
} m_ueip_session SEC(".maps"); // __uint(max_entries, MAX_UEs); //!< TODO: Is it enought?
// } m_ueip_session SEC(".maps");
struct { // struct {
__uint(type, BPF_MAP_TYPE_HASH); // __uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, MAX_UEs); // __uint(max_entries, MAX_UEs);
__type(key, u32); //!< UE IP // __type(key, u32); //!< UE IP
__type(value, u32); //!< PDR // __type(value, u32); //!< PDR
} m_ue_ip_pdr SEC(".maps"); // } m_ue_ip_pdr SEC(".maps");
struct { // struct {
__uint(type, BPF_MAP_TYPE_HASH); // __uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, MAX_LENGTH); // 10, // __uint(max_entries, MAX_LENGTH); // 10,
__type(key, struct next_rule_prog_index_key); // __type(key, struct next_rule_prog_index_key);
__type(value, pfcp_far_t_); // // __type(value, pfcp_far_t_); //
} m_next_rule_prog_index SEC(".maps"); // } m_next_rule_prog_index SEC(".maps");
struct { struct {
__uint(type, BPF_MAP_TYPE_HASH); __uint(type, BPF_MAP_TYPE_HASH);
......
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
* +--------------------------+---------------------------+ * +--------------------------+---------------------------+
*/ */
struct { // struct {
__uint(type, BPF_MAP_TYPE_PROG_ARRAY); // __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
__uint(max_entries, MAX_LENGTH); // __uint(max_entries, MAX_LENGTH);
__type(key, u32); // __type(key, u32);
__type(value, s32); // __type(value, s32);
} m_next_rule_prog SEC(".maps"); // } m_next_rule_prog SEC(".maps");
// BPF_ANNOTATE_KV_PAIR(m_next_rule_prog, u32, s32); // BPF_ANNOTATE_KV_PAIR(m_next_rule_prog, u32, s32);
......
...@@ -13,20 +13,20 @@ ...@@ -13,20 +13,20 @@
#define MAX_INTERFACES 10 #define MAX_INTERFACES 10
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
struct { // struct {
__uint(type, BPF_MAP_TYPE_HASH); // __uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, QOS_FLOWS_MAX_ENTRIES); // __uint(max_entries, QOS_FLOWS_MAX_ENTRIES);
__type(key, u32); // __type(key, u32);
__type(value, struct s_fiveQosFlow); // __type(value, struct s_fiveQosFlow);
} m_qos_flow SEC(".maps"); // } m_qos_flow SEC(".maps");
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
struct { // struct {
__uint(type, BPF_MAP_TYPE_ARRAY); // __uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1); // __uint(max_entries, 1);
__type(key, u32); // __type(key, u32);
__type(value, u8); // __type(value, u8);
} m_default_qfi SEC(".maps"); // } m_default_qfi SEC(".maps");
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
struct { struct {
......
...@@ -29,106 +29,12 @@ ...@@ -29,106 +29,12 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/pkt_sched.h> #include <linux/pkt_sched.h>
//--------------------------------------------------------------------------------------------------------------- #define TC_H_MAKE(major, minor) (((major) << 16) | (minor))
// static __always_inline u32 egress_sdf_classifier(struct __sk_buff* skb) {
// void* data = (void*) (long) skb->data;
// void* data_end = (void*) (long) skb->data_end;
// void* data_meta = (void*) (long) skb->data_meta;
// // struct packet_filter* filter = data_meta;
// struct session_qfi* qos_class_metadata = data_meta;
// struct ethhdr* ethh = data;
// if ((void*) (ethh + 1) > data_end) {
// bpf_debug("Error: Invalid Ethernet header");
// return TC_ACT_SHOT;
// }
// struct iphdr* iph = (struct iphdr*) (ethh + 1);
// if ((void*) (iph + 1) > data_end) {
// bpf_debug("Error: Invalid IPv4 header");
// return TC_ACT_SHOT;
// }
// struct udphdr* udph = (struct udphdr*) (iph + 1);
// if ((void*) (udph + 1) > data_end) {
// bpf_debug("Error: Invalid UDP header");
// return TC_ACT_SHOT;
// }
// struct gtpuhdr* gtpuh = (struct gtpuhdr*) (udph + 1);
// if ((void*) (gtpuh + 1) > data_end) {
// bpf_debug("Error: Invalid GTPU packet");
// return TC_ACT_SHOT;
// }
// struct gtpu_extn_pdu_session_container* gtpu_ext_h =
// (struct gtpu_extn_pdu_session_container*) ((void*) (gtpuh + 1));
// if ((void*) (gtpu_ext_h + 1) > data_end) {
// bpf_debug("Error: Invalid GTPU Extension packet");
// return TC_ACT_SHOT;
// }
// /* Check XDP gave us some data_meta */
// if ((void*) (qos_class_metadata + 1) > data) {
// bpf_debug("Error: Failed to load metadata from XDP");
// return TC_ACT_SHOT;
// }
// bpf_debug(
// "TC: Received XDP Metadata - seid: %llu, qfi: %u",
// qos_class_metadata->seid, qos_class_metadata->qfi);
// u16 minor_id =
// generate_minor_id(qos_class_metadata->seid, qos_class_metadata->qfi);
// skb->tc_classid = minor_id;
// skb->priority =
// TC_H_MAKE(1, minor_id); // 1 is the HTB root handle's major number
// bpf_debug("TC: classid %d", skb->tc_classid);
// bpf_debug("TC: skb->priority set to 0x%x", skb->priority);
// return TC_ACT_OK;
// }
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
// static __always_inline u32 ipv4_sdf_filter(struct __sk_buff* skb) {
// void* data = (void*) (long) skb->data;
// void* data_end = (void*) (long) skb->data_end;
// struct ethhdr* ethh = data;
// if ((void*) (ethh + 1) > data_end) {
// bpf_debug("Error: Invalid Ethernet header");
// return TC_ACT_SHOT;
// }
// struct iphdr* iph = (struct iphdr*) (ethh + 1);
// if ((void*) (iph + 1) > data_end) {
// bpf_debug("Error: Invalid IPv4 header");
// return TC_ACT_SHOT;
// }
// if (iph->protocol == IPPROTO_UDP) {
// struct udphdr* udph = (struct udphdr*) (iph + 1);
// if ((void*) (udph + 1) > data_end) {
// bpf_debug("Error: Invalid UDP header");
// return TC_ACT_SHOT;
// }
// if (htons(udph->dest) == GTP_UDP_PORT) {
// bpf_debug("IPv4 SDF Filter: This is a GTP traffic");
// return egress_sdf_classifier(skb);
// }
// }
// return TC_ACT_SHOT;
// }
// SEC("tc/egress") // SEC("tc/egress")
// egress_cls_func is called for packets that are going out of the network
// SEC("classifier/egress")
SEC("classifier") SEC("classifier")
int tc_filter_traffic(struct __sk_buff* skb) { int tc_filter_traffic(struct __sk_buff* skb) {
bpf_debug("==========< tc/egress: Filter Traffic >=========="); bpf_debug("==========< tc/egress: Filter Traffic >==========");
...@@ -197,13 +103,22 @@ int tc_filter_traffic(struct __sk_buff* skb) { ...@@ -197,13 +103,22 @@ int tc_filter_traffic(struct __sk_buff* skb) {
bpf_debug( bpf_debug(
"TC: Received XDP Metadata - seid: %llu, qfi: %u", "TC: Received XDP Metadata - seid: %llu, qfi: %u",
qos_class_metadata->seid, qos_class_metadata->qfi); qos_class_metadata->seid, qos_class_metadata->qfi);
u16 minor_id = generate_minor_id( u16 minor_id = generate_minor_id(
qos_class_metadata->seid, qos_class_metadata->qfi); qos_class_metadata->seid, qos_class_metadata->qfi);
skb->tc_classid = minor_id; __u32 classid = TC_H_MAKE(1, minor_id);
skb->priority = TC_H_MAKE(
1, minor_id); // 1 is the HTB root handle's major number skb->tc_index = classid;
bpf_debug("TC: classid %d", skb->tc_classid); skb->tc_classid = classid;
bpf_debug("TC: skb->priority set to 0x%x", skb->priority);
// skb->tc_index = (1 << 16) | minor_id;
// skb->tc_classid = (1 << 16) | minor_id;
// skb->priority = TC_H_MAKE(
// 1, minor_id); // 1 is the HTB root handle's major number
bpf_debug("classid = 0x%x", classid);
// bpf_debug("TC: classid 0x%x", skb->tc_classid);
// bpf_debug("TC: indexid 0x%x", skb->tc_index);
return TC_ACT_OK; return TC_ACT_OK;
} }
} }
...@@ -222,42 +137,6 @@ int tc_filter_traffic(struct __sk_buff* skb) { ...@@ -222,42 +137,6 @@ int tc_filter_traffic(struct __sk_buff* skb) {
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
// // SEC("tc/egress")
// SEC("classifier")
// int tc_filter_traffic(struct __sk_buff* skb) {
// bpf_debug("==========< tc/egress: Filter Traffic >==========");
// void* data = (void*) (long) skb->data;
// void* data_end = (void*) (long) skb->data_end;
// struct ethhdr* ethh = data;
// if ((void*) (ethh + 1) > data_end) {
// bpf_debug("Error: Invalid Ethernet header");
// return TC_ACT_SHOT;
// }
// u16 l3_protocol = htons(ethh->h_proto);
// bpf_debug("SDF FILTER: l3_protocol: 0x%x", l3_protocol);
// switch (l3_protocol) {
// case ETH_P_IP: {
// bpf_debug("SDF Filter: This is an IPv4 Packet");
// return ipv4_sdf_filter(skb);
// // return TC_ACT_OK;
// }
// case ETH_P_IPV6:
// case ETH_P_8021Q:
// case ETH_P_8021AD:
// case ETH_P_ARP:
// return TC_ACT_OK;
// default:
// return TC_ACT_OK;
// }
// }
//---------------------------------------------------------------------------------------------------------------
SEC("tc/ingress") SEC("tc/ingress")
int tc_redirect_traffic(struct __sk_buff* skb) { int tc_redirect_traffic(struct __sk_buff* skb) {
bpf_debug("==========< tc/ingress: Redirect Traffic >=========="); bpf_debug("==========< tc/ingress: Redirect Traffic >==========");
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
#include <bpf/libbpf.h> #include <bpf/libbpf.h>
#include <bpf/bpf.h> #include <bpf/bpf.h>
#define EGRESS_HANDLE 0x1 // #define EGRESS_HANDLE 0x1
#define EGRESS_HANDLE 0x10000
#define EGRESS_PRIORITY 0xC02F #define EGRESS_PRIORITY 0xC02F
#define INGRESS_HANDLE 0x1 #define INGRESS_HANDLE 0x1
......
...@@ -159,9 +159,10 @@ void PFCP_Session_LookupProgram::tearDown() { ...@@ -159,9 +159,10 @@ void PFCP_Session_LookupProgram::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) {
...@@ -173,25 +174,28 @@ void PFCP_Session_LookupProgram::removeProgramMap(uint32_t key) { ...@@ -173,25 +174,28 @@ 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()
return mpNextProgRuleMap; // const {
} // 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()
...@@ -239,12 +243,14 @@ void PFCP_Session_LookupProgram::initializeMaps() { ...@@ -239,12 +243,14 @@ void PFCP_Session_LookupProgram::initializeMaps() {
mpMaps = std::make_shared<BPFMaps>(mpLifeCycle->getBPFSkeleton()->skeleton); mpMaps = std::make_shared<BPFMaps>(mpLifeCycle->getBPFSkeleton()->skeleton);
// Warning - The name of the map must be the same of the BPF program. // Warning - The name of the map must be the same of the BPF program.
mpTeidSessionMap = std::make_shared<BPFMap>(mpMaps->getMap("m_teid_session")); // mpTeidSessionMap =
mpUeIpSessionMap = std::make_shared<BPFMap>(mpMaps->getMap("m_ueip_session")); // std::make_shared<BPFMap>(mpMaps->getMap("m_teid_session"));
mpNextProgRuleMap = // mpUeIpSessionMap =
std::make_shared<BPFMap>(mpMaps->getMap("m_next_rule_prog")); // std::make_shared<BPFMap>(mpMaps->getMap("m_ueip_session"));
mpNextProgRuleIndexMap = // mpNextProgRuleMap =
std::make_shared<BPFMap>(mpMaps->getMap("m_next_rule_prog_index")); // std::make_shared<BPFMap>(mpMaps->getMap("m_next_rule_prog"));
// mpNextProgRuleIndexMap =
// std::make_shared<BPFMap>(mpMaps->getMap("m_next_rule_prog_index"));
mpSessionMappingMap = mpSessionMappingMap =
std::make_shared<BPFMap>(mpMaps->getMap("m_session_mapping")); std::make_shared<BPFMap>(mpMaps->getMap("m_session_mapping"));
mpArpTableMap = std::make_shared<BPFMap>(mpMaps->getMap("m_arp_table")); mpArpTableMap = std::make_shared<BPFMap>(mpMaps->getMap("m_arp_table"));
......
...@@ -35,7 +35,7 @@ class PFCP_Session_LookupProgram { ...@@ -35,7 +35,7 @@ class PFCP_Session_LookupProgram {
void tearDown(); void tearDown();
void updateProgramMap(uint32_t key, uint32_t fd); // void updateProgramMap(uint32_t key, uint32_t fd);
void create_upf_interface_map_entry(e_reference_point s); void create_upf_interface_map_entry(e_reference_point s);
...@@ -44,10 +44,10 @@ class PFCP_Session_LookupProgram { ...@@ -44,10 +44,10 @@ class PFCP_Session_LookupProgram {
std::shared_ptr<BPFMap> getEgressInterfaceMap() const; std::shared_ptr<BPFMap> getEgressInterfaceMap() const;
std::shared_ptr<BPFMap> getArpTableMap() const; std::shared_ptr<BPFMap> getArpTableMap() const;
std::shared_ptr<BPFMap> getIfaceMap() const; std::shared_ptr<BPFMap> getIfaceMap() const;
std::shared_ptr<BPFMap> getTeidSessionMap() const; // std::shared_ptr<BPFMap> getTeidSessionMap() const;
std::shared_ptr<BPFMap> getUeIpSessionMap() const; // std::shared_ptr<BPFMap> getUeIpSessionMap() const;
std::shared_ptr<BPFMap> getNextProgRuleMap() const; // std::shared_ptr<BPFMap> getNextProgRuleMap() const;
std::shared_ptr<BPFMap> getNextProgRuleIndexMap() const; // std::shared_ptr<BPFMap> getNextProgRuleIndexMap() const;
std::shared_ptr<BPFMap> getTrafficMap() const; std::shared_ptr<BPFMap> getTrafficMap() const;
std::shared_ptr<BPFMap> getSessionMappingMap() const; std::shared_ptr<BPFMap> getSessionMappingMap() const;
std::shared_ptr<BPFMap> getRulesMatchPdrMap() const; std::shared_ptr<BPFMap> getRulesMatchPdrMap() const;
...@@ -55,7 +55,7 @@ class PFCP_Session_LookupProgram { ...@@ -55,7 +55,7 @@ class PFCP_Session_LookupProgram {
std::shared_ptr<BPFMap> getSdfFilterMap() const; std::shared_ptr<BPFMap> getSdfFilterMap() const;
std::shared_ptr<BPFMap> getQosEnablingMap() const; std::shared_ptr<BPFMap> getQosEnablingMap() const;
std::shared_ptr<BPFMap> getUeQfiTeidMap() const; std::shared_ptr<BPFMap> getUeQfiTeidMap() const;
std::shared_ptr<BPFMap> getQosFlowMap() const; // std::shared_ptr<BPFMap> getQosFlowMap() const;
private: private:
void initializeMaps(); void initializeMaps();
...@@ -66,9 +66,9 @@ class PFCP_Session_LookupProgram { ...@@ -66,9 +66,9 @@ class PFCP_Session_LookupProgram {
std::string mUDPInterface; std::string mUDPInterface;
std::shared_ptr<BPFMaps> mpMaps; std::shared_ptr<BPFMaps> mpMaps;
std::shared_ptr<BPFMap> mpTeidSessionMap; std::shared_ptr<BPFMap> mpTeidSessionMap;
std::shared_ptr<BPFMap> mpUeIpSessionMap; // std::shared_ptr<BPFMap> mpUeIpSessionMap;
std::shared_ptr<BPFMap> mpNextProgRuleIndexMap; // std::shared_ptr<BPFMap> mpNextProgRuleIndexMap;
std::shared_ptr<BPFMap> mpNextProgRuleMap; // std::shared_ptr<BPFMap> mpNextProgRuleMap;
std::shared_ptr<BPFMap> mpSessionMappingMap; std::shared_ptr<BPFMap> mpSessionMappingMap;
std::shared_ptr<BPFMap> mpEgressInterfaceMap; std::shared_ptr<BPFMap> mpEgressInterfaceMap;
std::shared_ptr<BPFMap> mpArpTableMap; std::shared_ptr<BPFMap> mpArpTableMap;
......
This diff is collapsed.
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include <BPFProgram.h> #include <BPFProgram.h>
#include "interfaces.h" #include "interfaces.h"
#include <netlink/netlink.h> // #include <netlink/netlink.h>
#include <netlink/route/qdisc.h> // #include <netlink/route/qdisc.h>
#include <qos_flow.h> #include <qos_flow.h>
#include <pfcp_session.hpp> #include <pfcp_session.hpp>
class BPFMaps; class BPFMaps;
...@@ -97,8 +97,8 @@ class QERProgram : public BPFProgram { ...@@ -97,8 +97,8 @@ class QERProgram : public BPFProgram {
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
std::shared_ptr<BPFMap> getQoSFlowMap() const; // std::shared_ptr<BPFMap> getQoSFlowMap() const;
std::shared_ptr<BPFMap> getDefaultQfiMap() const; // std::shared_ptr<BPFMap> getDefaultQfiMap() const;
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
...@@ -131,7 +131,7 @@ class QERProgram : public BPFProgram { ...@@ -131,7 +131,7 @@ class QERProgram : public BPFProgram {
std::unordered_map<uint32_t, std::shared_ptr<pfcp::pfcp_pdr>> pdr_map; std::unordered_map<uint32_t, std::shared_ptr<pfcp::pfcp_pdr>> pdr_map;
void storeQosFlow(std::shared_ptr<pfcp::pfcp_qer> pQer); // void storeQosFlow(std::shared_ptr<pfcp::pfcp_qer> pQer);
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
// The reference of the bpf maps. // The reference of the bpf maps.
std::shared_ptr<BPFMaps> mpMaps; std::shared_ptr<BPFMaps> mpMaps;
...@@ -157,9 +157,9 @@ class QERProgram : public BPFProgram { ...@@ -157,9 +157,9 @@ class QERProgram : public BPFProgram {
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
// The 5G QoS Flow. // The 5G QoS Flow.
std::shared_ptr<BPFMap> mpQoSFlowMap; // std::shared_ptr<BPFMap> mpQoSFlowMap;
std::shared_ptr<BPFMap> mpDefaultQfiMap; // std::shared_ptr<BPFMap> mpDefaultQfiMap;
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
std::vector<struct s_fiveQosFlow> qosFlowsQfis; std::vector<struct s_fiveQosFlow> qosFlowsQfis;
}; };
......
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