Commit fd562224 authored by Lukas Rotheneder's avatar Lukas Rotheneder

Merge branch 'develop' into 'framed_routing_ebpf'

# Conflicts:
#   src/upf_app/SessionManager.cpp
#   src/upf_app/SessionProgramManager.cpp
#   src/upf_app/bpf/rules/pdr/pfcp_session_lookup_xdp_kernel.c
parents b361ba2a d45313f5
common @ 0a944b75
Subproject commit 3b119a93f7009d09036466f97f4f50e2738baae2
Subproject commit 0a944b75fcd2a87c7831ed89a266061b9bae6531
......@@ -77,7 +77,7 @@ class HtmlReport():
gitInfoAppended = True
newFile += gitInfo
if re.search('OAI-CN5G-RobotTest -- Build-ID', line) is not None:
result = re.search('href="(?P<build_url>[a-zA-Z0-9\-\:\/\.]+)"', line)
result = re.search('href="(?P<build_url>[a-zA-Z0-9\\-\\:\\/\\.]+)"', line)
if result is not None:
robotBuildUrl = result.group('build_url')
if re.search('archives/log.html', line) is not None:
......
......@@ -213,9 +213,9 @@ smf:
upf:
support_features:
enable_bpf_datapath: no # If "on": BPF is used as datapath else simpleswitch is used, DEFAULT= off
enable_qos: no # Only supported for BPF datapath. If "on" we use qdiscs to manage the QoS
enable_snat: no # If "on": Source natting is done for UE, DEFAULT= off
enable_bpf_datapath: yes # If "yes": BPF is used as datapath else simpleswitch is used, DEFAULT= no
enable_qos: no # Only supported for BPF datapath. If "yes" we use qdisc to manage the QoS
enable_snat: no # If "no": Source natting is done for UE, DEFAULT= no
remote_n6_gw: oai-ext-dn
smfs:
- host: oai-smf # To be used for PFCP association in case of no-NRF
......
......@@ -24,6 +24,8 @@ metadata:
name: "upf-build-cfg"
spec:
runPolicy: "Serial"
nodeSelector:
node-role.kubernetes.io/worker: ""
source:
type: "Binary"
secrets:
......
......@@ -24,21 +24,21 @@ SessionManager::SessionManager() {}
/*---------------------------------------------------------------------------------------------------------------*/
SessionManager::~SessionManager() {}
/*****************************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
// Helper function to extract PDI
bool SessionManager::extractPdi(
std::shared_ptr<pfcp::pfcp_pdr> pdr, pfcp::pdi& pdi) {
return (pdr->get(pdi));
}
/*****************************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
// Helper function to extract source interface
bool SessionManager::extractSourceIface(
pfcp::pdi& pdi, pfcp::source_interface_t& sourceInterface) {
return (pdi.get(sourceInterface));
}
/*****************************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
// Helper function to extract source interface
bool SessionManager::extractUeIpv4(
pfcp::pdi& pdi, pfcp::ue_ip_address_t& ueIpAddress) {
......@@ -107,7 +107,7 @@ void SessionManager::createSession(std::shared_ptr<SessionBpf> pSession) {
"Session %d Has Been Created Successfully", pSession->getSeid());
}
/*****************************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
/*
* Document: ETSI TS 129 244 V15.8.0 (2020-01)
* PDI is a Mandatory IE within the Establishment request
......@@ -197,6 +197,8 @@ void SessionManager::createBPFSession(
auto& logger = Logger::upf_n4();
uint64_t seid = pSession_establishment->get_up_seid();
sessions.push_back(pSession_establishment);
logger.debug("Session %d Received", seid);
logger.debug("Preparing the Datapath ...");
logger.debug("Find the PDR with Highest Precedence");
......@@ -227,7 +229,7 @@ void SessionManager::createBPFSession(
mSeidToSession[seid] = pSession_establishment;
}
/*****************************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
void SessionManager::processPDRs(
std::shared_ptr<pfcp::pfcp_session> pSession_establishment) {
auto& pdrs_uplink = pSession_establishment->pdrs_uplink;
......@@ -288,7 +290,7 @@ void SessionManager::processPDRs(
}
}
/*****************************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
void SessionManager::sortPDRs(
std::vector<std::shared_ptr<pfcp::pfcp_pdr>>& pdrs_uplink,
std::vector<std::shared_ptr<pfcp::pfcp_pdr>>& pdrs_downlink) {
......@@ -297,7 +299,7 @@ void SessionManager::sortPDRs(
std::sort(pdrs_downlink.begin(), pdrs_downlink.end(), comparePDR);
}
/*****************************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
void SessionManager::createSessionDirection(
std::shared_ptr<pfcp::pfcp_session> pSession_establishment,
std::vector<std::shared_ptr<pfcp::pfcp_pdr>>& pdrs,
......@@ -317,7 +319,7 @@ void SessionManager::createSessionDirection(
}
}
/*****************************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
void SessionManager::createBPFSessionUL(
std::shared_ptr<pfcp::pfcp_session> pSession,
std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedenceUl) {
......@@ -339,7 +341,7 @@ void SessionManager::createBPFSessionDL(
pSession, pdrHighPrecedenceDl, INTERFACE_VALUE_CORE, "Downlink");
}
/*****************************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
void SessionManager::processPDRDetails(
std::shared_ptr<pfcp::pfcp_session> pSession,
std::shared_ptr<pfcp::pfcp_pdr> pdrHighPrecedence, int interfaceValue,
......@@ -628,7 +630,7 @@ void SessionManager::updateBPFSessionDL(
seidul, fteid.teid, INTERFACE_VALUE_CORE,
ueIpAddress.ipv4_address.s_addr, pFar, pSession->qers, true, teid_ul);
} else {
Logger::upf_app().error("Uplink TEID not found for session: 0x%x", seidul);
Logger::upf_app().info("Uplink TEID not used for session: 0x%x", seidul);
SessionProgramManager::getInstance().createPipeline(
seidul, fteid.teid, INTERFACE_VALUE_CORE,
ueIpAddress.ipv4_address.s_addr, pFar, pSession->qers, true, 0);
......
This diff is collapsed.
......@@ -63,11 +63,7 @@ class SessionProgramManager {
void create(uint64_t seid);
/*---------------------------------------------------------------------------------------------------------------*/
/**
* @brief Remove program session context.
*
* @param seid The session identifier.
*/
void remove(uint64_t seid);
/*---------------------------------------------------------------------------------------------------------------*/
......@@ -141,7 +137,8 @@ class SessionProgramManager {
/*---------------------------------------------------------------------------------------------------------------*/
void storeSessionMappingMap(
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, uint32_t teid_ul,
uint32_t seid);
/*---------------------------------------------------------------------------------------------------------------*/
void storeFARInFARMap(
......@@ -169,17 +166,6 @@ class SessionProgramManager {
void updatePipeline(
uint64_t seid, uint32_t teid, uint32_t gNBIpAddress, bool isModification);
/*---------------------------------------------------------------------------------------------------------------*/
// void storeUeQfiTeidMap(
// std::shared_ptr<PFCP_Session_LookupProgram>
// pPFCP_Session_LookupProgram, uint32_t ue_ip_address, uint8_t qfi,
// uint32_t teid_ul);
/*---------------------------------------------------------------------------------------------------------------*/
// void updateMap(std::shared_ptr<PFCP_Session_LookupProgram>
// pPFCP_Session_LookupProgram,
// uint64_t seid, uint32_t teid_ul, uint32_t src_ip, uint32_t teid_dl);
/*---------------------------------------------------------------------------------------------------------------*/
void removePipeline(uint64_t seid);
std::shared_ptr<SessionPrograms> findSessionPrograms(uint64_t seid);
......@@ -196,10 +182,7 @@ class SessionProgramManager {
SessionProgramManager();
int32_t getEmptySlot();
// The program eBPF map.
std::shared_ptr<BPFMap> mpTeidSessionMap;
// The program eBPF map.
std::shared_ptr<BPFMap> mpUeIpSessionMap;
// The observer which will be notified when a PFCP_Session_PDR_LookupProgram
......@@ -210,9 +193,6 @@ class SessionProgramManager {
std::map<uint32_t, std::shared_ptr<PFCP_Session_PDR_LookupProgram>>
mSessionProgramMap;
// The Maps to store the instance of the FARs programs.
// std::map<uint32_t, std::shared_ptr<FARProgram>> mFARProgramMap;
// The Maps to store the PFCP session deployed in datapath.
std::map<uint32_t, std::shared_ptr<SessionPrograms>> mSessionProgramsMap;
......
......@@ -4,7 +4,7 @@
#include <types.h>
#include <pfcp/pfcp_pdr.h>
#define PDRS_MAX_SIZE 10
#define PDRS_MAX_SIZE 10000
typedef struct pfcp_pdrs_s {
u32 pdrs_counter;
......
......@@ -5,8 +5,8 @@
#include <pfcp/pfcp_pdr.h>
#include <pfcp/pfcp_far.h>
#define SESSION_PDRS_MAX_SIZE 5000 // 10
#define SESSION_FARS_MAX_SIZE 5000 // 10
#define SESSION_PDRS_MAX_SIZE 100
#define SESSION_FARS_MAX_SIZE 100
typedef struct pfcp_session_s {
seid_t_ seid;
......
......@@ -7,15 +7,15 @@
#include <types.h>
#include "arp_table_maps.h"
#define ARP_ENTRIES_MAX_SIZE 12
#define FAR_TAILS_MAX 1
#define ARP_ENTRIES_MAX_SIZE 10000
#define FAR_TAILS_MAX 20
#define MAX_INTERFACES 10
#define MAX_FAR_PROGRAMS 100
#define MAX_FAR_PROGRAMS 10000
/*---------------------------------------------------------------------------------------------------------------*/
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, FAR_TAILS_MAX); // 1,
__uint(max_entries, FAR_TAILS_MAX);
__type(key, u8);
__type(value, pfcp_far_t_);
} m_far SEC(".maps");
......@@ -23,23 +23,23 @@ struct {
/*---------------------------------------------------------------------------------------------------------------*/
struct {
__uint(type, BPF_MAP_TYPE_DEVMAP);
__uint(max_entries, MAX_INTERFACES); // 10,
__type(key, u32); // id
__type(value, u32); // tx port
__uint(max_entries, MAX_INTERFACES);
__type(key, u32); // id
__type(value, u32); // tx port
} m_redirect_interfaces SEC(".maps");
/*---------------------------------------------------------------------------------------------------------------*/
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, ARP_ENTRIES_MAX_SIZE); // 2,
__type(key, u32); // IPv4 address
__type(value, struct s_arp_mapping); // <IP Address, MAC address>
__uint(max_entries, ARP_ENTRIES_MAX_SIZE);
__type(key, u32); // IPv4 address
__type(value, struct s_arp_mapping); // <IP Address, MAC address>
} m_arp_table SEC(".maps");
/*---------------------------------------------------------------------------------------------------------------*/
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, MAX_FAR_PROGRAMS); // 1,
__uint(max_entries, MAX_FAR_PROGRAMS);
__type(key, u32);
__type(value, u32);
} m_enforcing_qos SEC(".maps");
......
......@@ -12,9 +12,9 @@
/*---------------------------------------------------------------------------------------------------------------*/
struct {
__uint(type, BPF_MAP_TYPE_DEVMAP);
__uint(max_entries, MAX_INTERFACES); // 10,
__type(key, u32); // id
__type(value, u32); // tx port
__uint(max_entries, MAX_INTERFACES);
__type(key, u32); // id
__type(value, u32); // tx port
} m_redirect_interfaces SEC(".maps");
/*---------------------------------------------------------------------------------------------------------------*/
......@@ -22,7 +22,7 @@ struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, INTERFACE_ENTRIES_MAX);
__type(key, e_reference_point);
__type(value, struct s_interface); // 6,
__type(value, struct s_interface);
} m_upf_interfaces SEC(".maps");
#endif // __INTERFACES_MAP_H__
\ No newline at end of file
......@@ -12,9 +12,9 @@
#include "interfaces.h"
#include "session_id.h"
#define MAX_LENGTH 5000 // 10
#define MAX_LENGTH 10000
#define INTERFACE_ENTRIES_MAX 12
#define MAX_UEs 100000
#define MAX_UEs 10000
/*---------------------------------------------------------------------------------------------------------------*/
struct {
......@@ -59,7 +59,7 @@ struct {
/*---------------------------------------------------------------------------------------------------------------*/
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, INTERFACE_ENTRIES_MAX); // 6,
__uint(max_entries, INTERFACE_ENTRIES_MAX);
__type(key, e_reference_point);
__type(value, struct s_interface);
} m_upf_interfaces SEC(".maps");
......
......@@ -8,9 +8,9 @@
#include <ie/fteid.h>
#include <ie/fseid.h>
#define MAX_LENGTH 5000 // 10
#define PDR_ENTRIES_MAX_SIZE 5000 // 10
#define FAR_ENTRIES_MAX_SIZE 5000 // 10
#define MAX_LENGTH 10000
#define PDR_ENTRIES_MAX_SIZE 10000
#define FAR_ENTRIES_MAX_SIZE 10000
#define ARP_ENTRIES_MAX_SIZE 12
/*---------------------------------------------------------------------------------------------------------------*/
......@@ -24,33 +24,33 @@ struct {
/*---------------------------------------------------------------------------------------------------------------*/
struct {
__uint(type, BPF_MAP_TYPE_DEVMAP);
__uint(max_entries, MAX_LENGTH); // 10,
__type(key, u32); // id
__type(value, u32); // tx port
__uint(max_entries, MAX_LENGTH);
__type(key, u32); // id
__type(value, u32); // tx port
} m_redirect_interfaces SEC(".maps");
/*---------------------------------------------------------------------------------------------------------------*/
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, PDR_ENTRIES_MAX_SIZE); // 10,
__type(key, teid_t_); // teid
__type(value, pfcp_pdr_t_); // assuming only one PDR
__uint(max_entries, PDR_ENTRIES_MAX_SIZE);
__type(key, teid_t_); // teid
__type(value, pfcp_pdr_t_); // assuming only one PDR
} m_teid_pdr SEC(".maps");
/*---------------------------------------------------------------------------------------------------------------*/
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, PDR_ENTRIES_MAX_SIZE); // 10,
__type(key, u32); // UE IP address
__type(value, pfcp_pdr_t_); // assuming only one PDR
__uint(max_entries, PDR_ENTRIES_MAX_SIZE);
__type(key, u32); // UE IP address
__type(value, pfcp_pdr_t_); // assuming only one PDR
} m_ueip_pdr SEC(".maps");
/*---------------------------------------------------------------------------------------------------------------*/
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, ARP_ENTRIES_MAX_SIZE); // 2,
__type(key, u32); // IPv4 address
__type(value, unsigned char[8]); // MAC address
__uint(max_entries, ARP_ENTRIES_MAX_SIZE);
__type(key, u32); // IPv4 address
__type(value, unsigned char[8]); // MAC address
} m_arp_table SEC(".maps");
#endif // __PFCP_SESSION_PDR_LOOKUP_MAPS_H__
......@@ -5,7 +5,7 @@
#include <linux/bpf.h>
#include <types.h>
#define MAX_LENGTH 5000 // 10
#define MAX_LENGTH 10000
/*
* +------------------------------------------------------+
......@@ -21,7 +21,7 @@
struct {
__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
__uint(max_entries, MAX_LENGTH); // 10,
__uint(max_entries, MAX_LENGTH);
__type(key, u32);
__type(value, s32);
} m_next_rule_prog SEC(".maps");
......
......@@ -92,12 +92,15 @@ static __always_inline u32 tail_call_next_prog(
static __always_inline u32
handle_downlink_traffic(struct xdp_md* ctx, u32 ue_ip_address) {
u32* teid_dl = bpf_map_lookup_elem(&m_session_mapping, &ue_ip_address);
if (teid_dl) {
struct session_id* session =
bpf_map_lookup_elem(&m_session_mapping, &ue_ip_address);
if (session) {
u32 teid_dl = session->teid_dl;
bpf_debug(
"TEID downlink: 0x%x was found for UE IP: 0x%x", *teid_dl,
"TEID downlink: 0x%x was found for UE IP: 0x%x", teid_dl,
ue_ip_address);
tail_call_next_prog(ctx, *teid_dl, INTERFACE_VALUE_CORE, ue_ip_address);
tail_call_next_prog(ctx, teid_dl, INTERFACE_VALUE_CORE, ue_ip_address);
}
// Framed Routing
......
......@@ -7,9 +7,9 @@
#include "filter_key.h"
#include "qos_flow.h"
#define QFI_MAX_ENTRIES 5000
#define QFI_MAX_ENTRIES 10000
#define FIVE_QI_MAX_ENTRIES 100
#define QOS_FLOWS_MAX_ENTRIES 100
#define QOS_FLOWS_MAX_ENTRIES 10000
#define MAX_INTERFACES 10
/*---------------------------------------------------------------------------------------------------------------*/
......
......@@ -6,13 +6,13 @@
#include <bpf/libbpf.h>
#include "logger.hpp"
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
/**
* @brief This class abstracts the communication with a specific BPF map.
*/
class BPFMap {
public:
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
/**
* @brief Construct a new BPFMap object.
*
......@@ -21,13 +21,13 @@ class BPFMap {
*/
BPFMap(struct bpf_map* pBPFMap, std::string name);
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
/**
* @brief Destroy the BPFMap object.
*/
virtual ~BPFMap();
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
/**
* @brief Lookup a element in a specific position.
* Wrappers the bpf_map_lookup function.
......@@ -39,7 +39,7 @@ class BPFMap {
template<class KeyType>
int lookup(KeyType& key, void* pValue);
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
/**
* @brief Get the nex element in the map.
* Wrappers the bpf_get_next_key function.
......@@ -51,7 +51,7 @@ class BPFMap {
template<class KeyType>
int get_next_elem(KeyType& key, KeyType& next_key);
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
/**
* @brief Update a element in a specific position.
* Wrappers the bpf_map_update function.
......@@ -64,7 +64,7 @@ class BPFMap {
template<class KeyType, class ValueType>
int update(KeyType& key, ValueType& value, int flags);
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
/**
* @brief Remove a element in a specific position.
* Wrappers the bpf_map_delete function.
......@@ -75,7 +75,7 @@ class BPFMap {
template<class KeyType>
int remove(KeyType& key);
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
/**
* @brief Get the Name of the BPF Map.
*
......@@ -83,7 +83,7 @@ class BPFMap {
*/
std::string getName() const;
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
private:
// TODO: Change to unique.
// The bpf map.
......@@ -93,23 +93,15 @@ class BPFMap {
std::string mName;
};
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
template<class KeyType>
int BPFMap::lookup(KeyType& key, void* pValue) {
// Do not put here.
int mapFd = bpf_map__fd(mpBPFMap);
int lookupReturn = bpf_map_lookup_elem(mapFd, &key, pValue);
if (lookupReturn != 0) {
Logger::upf_app().warn(
"The key is not found in the map: %s", mName.c_str());
} else {
Logger::upf_app().debug("The key is found in the map: %s", mName.c_str());
}
return lookupReturn;
int mapFd = bpf_map__fd(mpBPFMap);
return bpf_map_lookup_elem(mapFd, &key, pValue);
}
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
template<class KeyType, class ValueType>
int BPFMap::update(KeyType& key, ValueType& value, int flags) {
int mapFd = bpf_map__fd(mpBPFMap);
......@@ -127,7 +119,7 @@ int BPFMap::update(KeyType& key, ValueType& value, int flags) {
return updateReturn;
}
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
template<class KeyType>
int BPFMap::remove(KeyType& key) {
// Do not put here.
......@@ -145,7 +137,7 @@ int BPFMap::remove(KeyType& key) {
return deleteReturn;
}
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
template<class KeyType>
int BPFMap::get_next_elem(KeyType& key, KeyType& next_key) {
int mapFd = bpf_map__fd(mpBPFMap);
......@@ -159,5 +151,5 @@ int BPFMap::get_next_elem(KeyType& key, KeyType& next_key) {
return ret_val;
}
/**************************************************************************************************/
//---------------------------------------------------------------------------------------------------------------
#endif // __BPFMAP_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